summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorKevin Steves <stevesk@cvs.openbsd.org>2002-07-15 17:15:32 +0000
committerKevin Steves <stevesk@cvs.openbsd.org>2002-07-15 17:15:32 +0000
commit63aaf5a58ca55550c9e573eee30d7e484cd9e745 (patch)
tree50960a25838dac3a994d10f1cc389f4c783db12a /usr.bin/ssh
parenta5c62c10ddfb67b500526130156e9332227c562e (diff)
little more debugging; ok markus@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/uidswap.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/ssh/uidswap.c b/usr.bin/ssh/uidswap.c
index ab43cbadd20..791f368256d 100644
--- a/usr.bin/ssh/uidswap.c
+++ b/usr.bin/ssh/uidswap.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: uidswap.c,v 1.22 2002/05/28 21:24:00 stevesk Exp $");
+RCSID("$OpenBSD: uidswap.c,v 1.23 2002/07/15 17:15:31 stevesk Exp $");
#include "log.h"
#include "uidswap.h"
@@ -46,15 +46,16 @@ temporarily_use_uid(struct passwd *pw)
{
/* Save the current euid, and egroups. */
saved_euid = geteuid();
- debug("temporarily_use_uid: %u/%u (e=%u)",
- (u_int)pw->pw_uid, (u_int)pw->pw_gid, (u_int)saved_euid);
+ saved_egid = getegid();
+ debug("temporarily_use_uid: %u/%u (e=%u/%u)",
+ (u_int)pw->pw_uid, (u_int)pw->pw_gid,
+ (u_int)saved_euid, (u_int)saved_egid);
if (saved_euid != 0) {
privileged = 0;
return;
}
privileged = 1;
temporarily_use_uid_effective = 1;
- saved_egid = getegid();
saved_egroupslen = getgroups(NGROUPS_MAX, saved_egroups);
if (saved_egroupslen < 0)
fatal("getgroups: %.100s", strerror(errno));
@@ -85,12 +86,14 @@ temporarily_use_uid(struct passwd *pw)
void
restore_uid(void)
{
- debug("restore_uid");
/* it's a no-op unless privileged */
- if (!privileged)
+ if (!privileged) {
+ debug("restore_uid: (unprivileged)");
return;
+ }
if (!temporarily_use_uid_effective)
fatal("restore_uid: temporarily_use_uid not effective");
+ debug("restore_uid: %u/%u", (u_int)saved_euid, (u_int)saved_egid);
/* Set the effective uid back to the saved privileged uid. */
if (seteuid(saved_euid) < 0)
fatal("seteuid %u: %.100s", (u_int)saved_euid, strerror(errno));
@@ -110,6 +113,8 @@ permanently_set_uid(struct passwd *pw)
{
if (temporarily_use_uid_effective)
fatal("permanently_set_uid: temporarily_use_uid effective");
+ debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid,
+ (u_int)pw->pw_gid);
if (setgid(pw->pw_gid) < 0)
fatal("setgid %u: %.100s", (u_int)pw->pw_gid, strerror(errno));
if (setuid(pw->pw_uid) < 0)