summaryrefslogtreecommitdiff
path: root/uidswap.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2018-07-18 11:34:04 +0000
committerDamien Miller <djm@mindrot.org>2018-07-19 21:41:42 +1000
commit258dc8bb07dfb35a46e52b0822a2c5b7027df60a (patch)
tree0076c7e0f10f5f525efbd9f7499e5707203b743f /uidswap.c
parentac590760b251506b0a152551abbf8e8d6dc2f527 (diff)
upstream: Remove support for running ssh(1) setuid and fatal if
attempted. Do not link uidwap.c into ssh any more. Neuters UsePrivilegedPort, which will be marked as deprecated shortly. ok markus@ djm@ OpenBSD-Commit-ID: c4ba5bf9c096f57a6ed15b713a1d7e9e2e373c42
Diffstat (limited to 'uidswap.c')
-rw-r--r--uidswap.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/uidswap.c b/uidswap.c
index 1430b822a..49f76d818 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: uidswap.c,v 1.40 2018/06/15 07:01:11 djm Exp $ */ 1/* $OpenBSD: uidswap.c,v 1.41 2018/07/18 11:34:04 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -135,37 +135,6 @@ temporarily_use_uid(struct passwd *pw)
135 strerror(errno)); 135 strerror(errno));
136} 136}
137 137
138void
139permanently_drop_suid(uid_t uid)
140{
141#ifndef NO_UID_RESTORATION_TEST
142 uid_t old_uid = getuid();
143#endif
144
145 debug("permanently_drop_suid: %u", (u_int)uid);
146 if (setresuid(uid, uid, uid) < 0)
147 fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno));
148
149#ifndef NO_UID_RESTORATION_TEST
150 /*
151 * Try restoration of UID if changed (test clearing of saved uid).
152 *
153 * Note that we don't do this on Cygwin, or on Solaris-based platforms
154 * where fine-grained privileges are available (the user might be
155 * deliberately allowed the right to setuid back to root).
156 */
157 if (old_uid != uid &&
158 (setuid(old_uid) != -1 || seteuid(old_uid) != -1))
159 fatal("%s: was able to restore old [e]uid", __func__);
160#endif
161
162 /* Verify UID drop was successful */
163 if (getuid() != uid || geteuid() != uid) {
164 fatal("%s: euid incorrect uid:%u euid:%u (should be %u)",
165 __func__, (u_int)getuid(), (u_int)geteuid(), (u_int)uid);
166 }
167}
168
169/* 138/*
170 * Restores to the original (privileged) uid. 139 * Restores to the original (privileged) uid.
171 */ 140 */