- (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/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