| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sfluid.h" int set_uid_gid (char *new_uid, char *new_gid)
Sets the program's uid and gid to new values as specified (as names). The program must be currently running as 'root'. Returns 0 if the new names could be correctly used. Returns -1 if the specified user id or group id was not valid, or -2 if the process was unable to change to the new uid/gid as specified. The gid may be null or empty.
{ #if (defined (DOES_UID)) struct passwd *pwdbuf; struct group *grpbuf; # if (defined (__VMS__)) return (0); # else if (new_gid && *new_gid) { if ((grpbuf = getgrnam (new_gid)) == NULL) return (-1); else if (setgid (grpbuf-> gr_gid) == -1) return (-2); } if ((pwdbuf = getpwnam (new_uid)) == NULL) return (-1); else if (setuid (pwdbuf-> pw_uid) == -1) return (-2); # endif #endif return (0); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |