- (dtucker) [Makefile.in ssh-keysign.c ssh.c] Use permanently_set_uid() since
it does the right thing on all platforms. ok djm@
diff --git a/ChangeLog b/ChangeLog
index 00f38b4..d1936ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+20040815
+ - (dtucker) [Makefile.in ssh-keysign.c ssh.c] Use permanently_set_uid() since
+ it does the right thing on all platforms. ok djm@
+
20040814
- (dtucker) [auth-krb5.c gss-serv-krb5.c openbsd-compat/xmmap.c]
Explicitly set umask for mkstemp; ok djm@
@@ -1631,4 +1635,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
-$Id: ChangeLog,v 1.3508 2004/08/14 14:09:11 dtucker Exp $
+$Id: ChangeLog,v 1.3509 2004/08/15 07:23:34 dtucker Exp $
diff --git a/Makefile.in b/Makefile.in
index 95b4311..194da90 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.261 2004/06/23 03:21:54 mouring Exp $
+# $Id: Makefile.in,v 1.262 2004/08/15 07:23:34 dtucker Exp $
# uncomment if you run a non bourne compatable shell. Ie. csh
#SHELL = @SH@
@@ -67,7 +67,7 @@
compat.o compress.o crc32.o deattack.o fatal.o hostfile.o \
log.o match.o moduli.o mpaux.o nchan.o packet.o \
readpass.o rsa.o tildexpand.o ttymodes.o xmalloc.o \
- atomicio.o key.o dispatch.o kex.o mac.o uuencode.o misc.o \
+ atomicio.o key.o dispatch.o kex.o mac.o uidswap.c uuencode.o misc.o \
monitor_fdpass.o rijndael.o ssh-dss.o ssh-rsa.o dh.o kexdh.o \
kexgex.o kexdhc.o kexgexc.o scard.o msg.o progressmeter.o dns.o \
entropy.o scard-opensc.o gss-genr.o
@@ -76,7 +76,7 @@
sshconnect.o sshconnect1.o sshconnect2.o
SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
- sshpty.o sshlogin.o servconf.o serverloop.o uidswap.o \
+ sshpty.o sshlogin.o servconf.o serverloop.o \
auth.o auth1.o auth2.o auth-options.o session.o \
auth-chall.o auth2-chall.o groupaccess.o \
auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
diff --git a/ssh-keysign.c b/ssh-keysign.c
index cf8b0c2..5176557 100644
--- a/ssh-keysign.c
+++ b/ssh-keysign.c
@@ -41,6 +41,7 @@
#include "canohost.h"
#include "pathnames.h"
#include "readconf.h"
+#include "uidswap.h"
/* XXX readconf.c needs these */
uid_t original_real_uid;
@@ -150,8 +151,11 @@
key_fd[0] = open(_PATH_HOST_RSA_KEY_FILE, O_RDONLY);
key_fd[1] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY);
- seteuid(getuid());
- setuid(getuid());
+ if ((pw = getpwuid(getuid())) == NULL)
+ fatal("getpwuid failed");
+ pw = pwcopy(pw);
+
+ permanently_set_uid(pw);
init_rng();
seed_rng();
@@ -173,10 +177,6 @@
if (key_fd[0] == -1 && key_fd[1] == -1)
fatal("could not open any host key");
- if ((pw = getpwuid(getuid())) == NULL)
- fatal("getpwuid failed");
- pw = pwcopy(pw);
-
SSLeay_add_all_algorithms();
for (i = 0; i < 256; i++)
rnd[i] = arc4random();
diff --git a/ssh.c b/ssh.c
index edf8f2c..1419f98 100644
--- a/ssh.c
+++ b/ssh.c
@@ -71,6 +71,7 @@
#include "match.h"
#include "msg.h"
#include "monitor_fdpass.h"
+#include "uidswap.h"
#ifdef SMARTCARD
#include "scard.h"
@@ -644,8 +645,10 @@
* user's home directory if it happens to be on a NFS volume where
* root is mapped to nobody.
*/
- seteuid(original_real_uid);
- setuid(original_real_uid);
+ if (original_effective_uid == 0) {
+ PRIV_START;
+ permanently_set_uid(pw);
+ }
/*
* Now that we are back to our own permissions, create ~/.ssh