- (bal) Whitespace resync w/ OpenBSD for uidswap.c
diff --git a/ChangeLog b/ChangeLog
index 4fb7781..1e1ad34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
- markus@cvs.openbsd.org 2001/04/23 22:14:13
[ssh-keygen.c]
remove debug
+ - (bal) Whitespace resync w/ OpenBSD for uidswap.c
20010424
- OpenBSD CVS Sync
@@ -5245,4 +5246,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
-$Id: ChangeLog,v 1.1167 2001/04/24 16:59:28 mouring Exp $
+$Id: ChangeLog,v 1.1168 2001/04/25 06:27:59 mouring Exp $
diff --git a/uidswap.c b/uidswap.c
index e297901..39952e2 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -28,7 +28,7 @@
/* Lets assume that posix saved ids also work with seteuid, even though that
is not part of the posix specification. */
-
+
/* Saved effective uid. */
static int privileged = 0;
static int temporarily_use_uid_effective = 0;
@@ -36,7 +36,7 @@
static gid_t saved_egid;
static gid_t saved_egroups[NGROUPS_MAX], user_groups[NGROUPS_MAX];
static int saved_egroupslen = -1, user_groupslen = -1;
-
+
/*
* Temporarily changes to the given uid. If the effective user
* id is not root, this does nothing. This call cannot be nested.
@@ -44,42 +44,42 @@
void
temporarily_use_uid(struct passwd *pw)
{
- /* Save the current euid, and egroups. */
- saved_euid = geteuid();
- debug("temporarily_use_uid: %d/%d (e=%d)",
- pw->pw_uid, pw->pw_gid, saved_euid);
- 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));
-
- /* set and save the user's groups */
- if (user_groupslen == -1) {
- if (initgroups(pw->pw_name, pw->pw_gid) < 0)
- fatal("initgroups: %s: %.100s", pw->pw_name,
- strerror(errno));
- user_groupslen = getgroups(NGROUPS_MAX, user_groups);
- if (user_groupslen < 0)
- fatal("getgroups: %.100s", strerror(errno));
- }
- /* Set the effective uid to the given (unprivileged) uid. */
+ /* Save the current euid, and egroups. */
+ saved_euid = geteuid();
+ debug("temporarily_use_uid: %d/%d (e=%d)",
+ pw->pw_uid, pw->pw_gid, saved_euid);
+ 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));
+
+ /* set and save the user's groups */
+ if (user_groupslen == -1) {
+ if (initgroups(pw->pw_name, pw->pw_gid) < 0)
+ fatal("initgroups: %s: %.100s", pw->pw_name,
+ strerror(errno));
+ user_groupslen = getgroups(NGROUPS_MAX, user_groups);
+ if (user_groupslen < 0)
+ fatal("getgroups: %.100s", strerror(errno));
+ }
+ /* Set the effective uid to the given (unprivileged) uid. */
if (setgroups(user_groupslen, user_groups) < 0)
fatal("setgroups: %.100s", strerror(errno));
pw->pw_gid = pw->pw_gid;
if (setegid(pw->pw_gid) < 0)
- fatal("setegid %u: %.100s", (u_int) pw->pw_gid,
- strerror(errno));
- if (seteuid(pw->pw_uid) == -1)
- fatal("seteuid %u: %.100s", (u_int) pw->pw_uid,
- strerror(errno));
+ fatal("setegid %u: %.100s", (u_int) pw->pw_gid,
+ strerror(errno));
+ if (seteuid(pw->pw_uid) == -1)
+ fatal("seteuid %u: %.100s", (u_int) pw->pw_uid,
+ strerror(errno));
}
-
+
/*
* Restores to the original (privileged) uid.
*/