changeset 9246:25650d7f6b85 HEAD

imap/pop3: If chdir() to home failed, euid was always logged as being root.
author Timo Sirainen <tss@iki.fi>
date Sun, 26 Jul 2009 14:21:49 -0400
parents 6a6091e473cc
children 7168ca62c556
files src/master/mail-process.c
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/mail-process.c	Sun Jul 26 14:17:30 2009 -0400
+++ b/src/master/mail-process.c	Sun Jul 26 14:21:49 2009 -0400
@@ -819,11 +819,6 @@
 				  full_home_dir, CHDIR_TIMEOUT - left);
 		}
 
-		/* Change UID back. No need to change GID back, it doesn't
-		   really matter. */
-		if (uid != master_uid && seteuid(master_uid) < 0)
-			i_fatal("seteuid(%s) failed: %m", dec2str(master_uid));
-
 		/* If user's home directory doesn't exist and we're not
 		   trying to chroot anywhere, fallback to /tmp as the mails
 		   could be stored elsewhere. The ENOTDIR check is mostly for
@@ -840,6 +835,10 @@
 							       full_home_dir));
 			}
 		}
+		/* Change UID back. No need to change GID back, it doesn't
+		   really matter. */
+		if (uid != master_uid && seteuid(master_uid) < 0)
+			i_fatal("seteuid(%s) failed: %m", dec2str(master_uid));
 	}
 	if (ret < 0) {
 		/* We still have to change to some directory where we have