[dovecot-cvs] dovecot/src/master mail-process.c,1.69,1.70

cras at dovecot.org cras at dovecot.org
Thu Jan 13 22:33:44 EET 2005


Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv9951

Modified Files:
	mail-process.c 
Log Message:
Change effective GID as well before trying chdir() to mail directory.



Index: mail-process.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/mail-process.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- mail-process.c	9 Jan 2005 20:12:35 -0000	1.69
+++ mail-process.c	13 Jan 2005 20:33:41 -0000	1.70
@@ -403,11 +403,18 @@
 		full_home_dir = *chroot_dir == '\0' ? home_dir :
 			t_strconcat(chroot_dir, "/", home_dir, NULL);
 		/* NOTE: if home directory is NFS-mounted, we might not
-		   have access to it as root. Change the effective UID
+		   have access to it as root. Change the effective UID and GID
 		   temporarily to make it work. */
-		if (uid != master_uid && seteuid(uid) < 0)
-			i_fatal("seteuid(%s) failed: %m", dec2str(uid));
+		if (uid != master_uid) {
+			if (setegid(gid) < 0)
+				i_fatal("setegid(%s) failed: %m", dec2str(gid));
+			if (seteuid(uid) < 0)
+				i_fatal("seteuid(%s) failed: %m", dec2str(uid));
+		}
 		ret = chdir(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));
 



More information about the dovecot-cvs mailing list