=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/uidswap.c,v retrieving revision 1.6 retrieving revision 1.6.2.3 diff -u -r1.6 -r1.6.2.3 --- src/usr.bin/ssh/uidswap.c 2000/04/14 10:30:34 1.6 +++ src/usr.bin/ssh/uidswap.c 2001/03/12 15:44:18 1.6.2.3 @@ -2,14 +2,19 @@ * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved - * Created: Sat Sep 9 01:56:14 1995 ylo * Code for uid-swapping. + * + * As far as I am concerned, the code I have written for this software + * can be used freely for any purpose. Any derived versions of this + * software must be clearly marked as such, and if the derived work is + * incompatible with the protocol description in the RFC file, it must be + * called by a name other than "ssh" or "Secure Shell". */ #include "includes.h" -RCSID("$Id: uidswap.c,v 1.6 2000/04/14 10:30:34 markus Exp $"); +RCSID("$OpenBSD: uidswap.c,v 1.6.2.3 2001/03/12 15:44:18 jason Exp $"); -#include "ssh.h" +#include "log.h" #include "uidswap.h" /* @@ -25,10 +30,9 @@ /* Lets assume that posix saved ids also work with seteuid, even though that is not part of the posix specification. */ #define SAVED_IDS_WORK_WITH_SETEUID -#endif /* _POSIX_SAVED_IDS */ - /* Saved effective uid. */ static uid_t saved_euid = 0; +#endif /* _POSIX_SAVED_IDS */ /* * Temporarily changes to the given uid. If the effective user @@ -43,15 +47,15 @@ /* Set the effective uid to the given (unprivileged) uid. */ if (seteuid(uid) == -1) - debug("seteuid %d: %.100s", (int) uid, strerror(errno)); -#else /* SAVED_IDS_WORK_WITH_SETUID */ + debug("seteuid %u: %.100s", (u_int) uid, strerror(errno)); +#else /* SAVED_IDS_WORK_WITH_SETEUID */ /* Propagate the privileged uid to all of our uids. */ if (setuid(geteuid()) < 0) - debug("setuid %d: %.100s", (int) geteuid(), strerror(errno)); + debug("setuid %u: %.100s", (u_int) geteuid(), strerror(errno)); /* Set the effective uid to the given (unprivileged) uid. */ if (seteuid(uid) == -1) - debug("seteuid %d: %.100s", (int) uid, strerror(errno)); + debug("seteuid %u: %.100s", (u_int) uid, strerror(errno)); #endif /* SAVED_IDS_WORK_WITH_SETEUID */ } @@ -59,12 +63,12 @@ * Restores to the original uid. */ void -restore_uid() +restore_uid(void) { #ifdef SAVED_IDS_WORK_WITH_SETEUID /* Set the effective uid back to the saved uid. */ if (seteuid(saved_euid) < 0) - debug("seteuid %d: %.100s", (int) saved_euid, strerror(errno)); + debug("seteuid %u: %.100s", (u_int) saved_euid, strerror(errno)); #else /* SAVED_IDS_WORK_WITH_SETEUID */ /* * We are unable to restore the real uid to its unprivileged value. @@ -83,5 +87,5 @@ permanently_set_uid(uid_t uid) { if (setuid(uid) < 0) - debug("setuid %d: %.100s", (int) uid, strerror(errno)); + debug("setuid %u: %.100s", (u_int) uid, strerror(errno)); }