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