summaryrefslogtreecommitdiff
path: root/uidswap.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2012-11-05 17:04:37 +1100
committerDarren Tucker <dtucker@zip.com.au>2012-11-05 17:04:37 +1100
commitf96ff18a9240e38e5d3c671f5f8f341099874aaf (patch)
treeedca765088179b1faec91fb305ce8a2487663cc9 /uidswap.c
parenta6e3f01d1e230b8acfdd6b4cf3096459d2a325e0 (diff)
- (dtucker) [uidswap.c openbsd-compat/Makefile.in
openbsd-compat/bsd-setres_id.c openbsd-compat/bsd-setres_id.h openbsd-compat/openbsd-compat.h] Move the fallback code for setting uids and gids from uidswap.c to the compat library, which allows it to work with the new setresuid calls in auth2-pubkey. with tim@, ok djm@
Diffstat (limited to 'uidswap.c')
-rw-r--r--uidswap.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/uidswap.c b/uidswap.c
index 837648396..cdd7309e3 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -138,20 +138,8 @@ permanently_drop_suid(uid_t uid)
138 uid_t old_uid = getuid(); 138 uid_t old_uid = getuid();
139 139
140 debug("permanently_drop_suid: %u", (u_int)uid); 140 debug("permanently_drop_suid: %u", (u_int)uid);
141#if defined(HAVE_SETRESUID) && !defined(BROKEN_SETRESUID)
142 if (setresuid(uid, uid, uid) < 0) 141 if (setresuid(uid, uid, uid) < 0)
143 fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno)); 142 fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno));
144#elif defined(HAVE_SETREUID) && !defined(BROKEN_SETREUID)
145 if (setreuid(uid, uid) < 0)
146 fatal("setreuid %u: %.100s", (u_int)uid, strerror(errno));
147#else
148# ifndef SETEUID_BREAKS_SETUID
149 if (seteuid(uid) < 0)
150 fatal("seteuid %u: %.100s", (u_int)uid, strerror(errno));
151# endif
152 if (setuid(uid) < 0)
153 fatal("setuid %u: %.100s", (u_int)uid, strerror(errno));
154#endif
155 143
156#ifndef HAVE_CYGWIN 144#ifndef HAVE_CYGWIN
157 /* Try restoration of UID if changed (test clearing of saved uid) */ 145 /* Try restoration of UID if changed (test clearing of saved uid) */
@@ -220,18 +208,8 @@ permanently_set_uid(struct passwd *pw)
220 debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid, 208 debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid,
221 (u_int)pw->pw_gid); 209 (u_int)pw->pw_gid);
222 210
223#if defined(HAVE_SETRESGID) && !defined(BROKEN_SETRESGID)
224 if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) < 0) 211 if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) < 0)
225 fatal("setresgid %u: %.100s", (u_int)pw->pw_gid, strerror(errno)); 212 fatal("setresgid %u: %.100s", (u_int)pw->pw_gid, strerror(errno));
226#elif defined(HAVE_SETREGID) && !defined(BROKEN_SETREGID)
227 if (setregid(pw->pw_gid, pw->pw_gid) < 0)
228 fatal("setregid %u: %.100s", (u_int)pw->pw_gid, strerror(errno));
229#else
230 if (setegid(pw->pw_gid) < 0)
231 fatal("setegid %u: %.100s", (u_int)pw->pw_gid, strerror(errno));
232 if (setgid(pw->pw_gid) < 0)
233 fatal("setgid %u: %.100s", (u_int)pw->pw_gid, strerror(errno));
234#endif
235 213
236#ifdef __APPLE__ 214#ifdef __APPLE__
237 /* 215 /*
@@ -243,20 +221,8 @@ permanently_set_uid(struct passwd *pw)
243 pw->pw_name, (u_int)pw->pw_gid, strerror(errno)); 221 pw->pw_name, (u_int)pw->pw_gid, strerror(errno));
244#endif 222#endif
245 223
246#if defined(HAVE_SETRESUID) && !defined(BROKEN_SETRESUID)
247 if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0) 224 if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0)
248 fatal("setresuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); 225 fatal("setresuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
249#elif defined(HAVE_SETREUID) && !defined(BROKEN_SETREUID)
250 if (setreuid(pw->pw_uid, pw->pw_uid) < 0)
251 fatal("setreuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
252#else
253# ifndef SETEUID_BREAKS_SETUID
254 if (seteuid(pw->pw_uid) < 0)
255 fatal("seteuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
256# endif
257 if (setuid(pw->pw_uid) < 0)
258 fatal("setuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
259#endif
260 226
261#ifndef HAVE_CYGWIN 227#ifndef HAVE_CYGWIN
262 /* Try restoration of GID if changed (test clearing of saved gid) */ 228 /* Try restoration of GID if changed (test clearing of saved gid) */