2 ** Copyright 1998 - 2002 Double Precision, Inc. See COPYING for
3 ** distribution information.
23 void libmail_changegroup(gid_t gid)
32 if ( getuid() == 0 && setgroups(1, &gid) )
40 void libmail_changeuidgid(uid_t uid, gid_t gid)
42 libmail_changegroup(gid);
50 void libmail_changeusername(const char *uname, const gid_t *forcegrp)
56 /* uname might be a pointer returned from a previous called to getpw(),
57 ** and libc has a problem getting it back.
59 char *p=malloc(strlen(uname)+1);
69 if ((pw=getpwnam(p)) == 0)
79 if ( !forcegrp ) forcegrp= &pw->pw_gid;
83 if ( setgid( changegid ))
90 if ( getuid() == 0 && initgroups(pw->pw_name, changegid) )
97 if ( getuid() == 0 && setgroups(1, &changegid) )
105 if (setuid(changeuid))