diff options
Diffstat (limited to 'uidswap.c')
-rw-r--r-- | uidswap.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: uidswap.c,v 1.14 2001/04/06 21:00:16 markus Exp $"); | 15 | RCSID("$OpenBSD: uidswap.c,v 1.15 2001/04/08 11:24:33 markus Exp $"); |
16 | 16 | ||
17 | #include "log.h" | 17 | #include "log.h" |
18 | #include "uidswap.h" | 18 | #include "uidswap.h" |
@@ -54,8 +54,8 @@ temporarily_use_uid(struct passwd *pw) | |||
54 | } | 54 | } |
55 | privileged = 1; | 55 | privileged = 1; |
56 | temporarily_use_uid_effective = 1; | 56 | temporarily_use_uid_effective = 1; |
57 | saved_egid = getegid(); | 57 | saved_egid = getegid(); |
58 | saved_egroupslen = getgroups(NGROUPS_MAX, saved_egroups); | 58 | saved_egroupslen = getgroups(NGROUPS_MAX, saved_egroups); |
59 | if (saved_egroupslen < 0) | 59 | if (saved_egroupslen < 0) |
60 | fatal("getgroups: %.100s", strerror(errno)); | 60 | fatal("getgroups: %.100s", strerror(errno)); |
61 | 61 | ||
@@ -69,10 +69,10 @@ temporarily_use_uid(struct passwd *pw) | |||
69 | fatal("getgroups: %.100s", strerror(errno)); | 69 | fatal("getgroups: %.100s", strerror(errno)); |
70 | } | 70 | } |
71 | /* Set the effective uid to the given (unprivileged) uid. */ | 71 | /* Set the effective uid to the given (unprivileged) uid. */ |
72 | if (setgroups(user_groupslen, user_groups) < 0) | 72 | if (setgroups(user_groupslen, user_groups) < 0) |
73 | fatal("setgroups: %.100s", strerror(errno)); | 73 | fatal("setgroups: %.100s", strerror(errno)); |
74 | pw->pw_gid = pw->pw_gid; | 74 | pw->pw_gid = pw->pw_gid; |
75 | if (setegid(pw->pw_gid) < 0) | 75 | if (setegid(pw->pw_gid) < 0) |
76 | fatal("setegid %u: %.100s", (u_int) pw->pw_gid, | 76 | fatal("setegid %u: %.100s", (u_int) pw->pw_gid, |
77 | strerror(errno)); | 77 | strerror(errno)); |
78 | if (seteuid(pw->pw_uid) == -1) | 78 | if (seteuid(pw->pw_uid) == -1) |
@@ -95,9 +95,9 @@ restore_uid(void) | |||
95 | /* Set the effective uid back to the saved uid. */ | 95 | /* Set the effective uid back to the saved uid. */ |
96 | if (seteuid(saved_euid) < 0) | 96 | if (seteuid(saved_euid) < 0) |
97 | fatal("seteuid %u: %.100s", (u_int) saved_euid, strerror(errno)); | 97 | fatal("seteuid %u: %.100s", (u_int) saved_euid, strerror(errno)); |
98 | if (setgroups(saved_egroupslen, saved_egroups) < 0) | 98 | if (setgroups(saved_egroupslen, saved_egroups) < 0) |
99 | fatal("setgroups: %.100s", strerror(errno)); | 99 | fatal("setgroups: %.100s", strerror(errno)); |
100 | if (setegid(saved_egid) < 0) | 100 | if (setegid(saved_egid) < 0) |
101 | fatal("setegid %u: %.100s", (u_int) saved_egid, strerror(errno)); | 101 | fatal("setegid %u: %.100s", (u_int) saved_egid, strerror(errno)); |
102 | temporarily_use_uid_effective = 0; | 102 | temporarily_use_uid_effective = 0; |
103 | } | 103 | } |