5
/* set real, effective and saved user and group attributes
7
/* #include <set_ugid.h>
9
/* void set_ugid(uid, gid)
13
/* set_ugid() sets the real, effective and saved user and group process
14
/* attributes and updates the process group access list to be just the
15
/* user's primary group. This operation is irreversible.
17
/* All system call errors are fatal.
19
/* setuid(2), setgid(2), setgroups(2)
23
/* The Secure Mailer license must be distributed with this software.
26
/* IBM T.J. Watson Research
28
/* Yorktown Heights, NY 10598, USA
38
/* Utility library. */
43
/* set_ugid - set real, effective and saved user and group attributes */
45
void set_ugid(uid_t uid, gid_t gid)
47
int saved_errno = errno;
51
msg_fatal("seteuid(0): %m");
53
msg_fatal("setgid(%ld): %m", (long) gid);
54
if (setgroups(1, &gid) < 0)
55
msg_fatal("setgroups(1, &%ld): %m", (long) gid);
57
msg_fatal("setuid(%ld): %m", (long) uid);
59
msg_info("setugid: uid %ld gid %ld", (long) uid, (long) gid);