changeset 3095:8f254acc036c HEAD

Change effective GID as well before trying chdir() to mail directory.
author Timo Sirainen <tss@iki.fi>
date Thu, 13 Jan 2005 22:33:41 +0200
parents d78e9a31b6d8
children 65b2d1ec3596
files src/master/mail-process.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/mail-process.c	Thu Jan 13 20:37:00 2005 +0200
+++ b/src/master/mail-process.c	Thu Jan 13 22:33:41 2005 +0200
@@ -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));