[dovecot-cvs] dovecot/src/master mail-process.c,1.29,1.30

cras at procontrol.fi cras at procontrol.fi
Sun Aug 3 22:54:59 EEST 2003


Update of /home/cvs/dovecot/src/master
In directory danu:/tmp/cvs-serv1638

Modified Files:
	mail-process.c 
Log Message:
If user's home dir doesn't exist, fallback to chdiring /tmp.



Index: mail-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/mail-process.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- mail-process.c	27 Jul 2003 05:37:58 -0000	1.29
+++ mail-process.c	3 Aug 2003 18:54:56 -0000	1.30
@@ -193,7 +193,9 @@
 
 	restrict_process_size(group->set->mail_process_size, (unsigned int)-1);
 
-	if (*home_dir != '\0') {
+	if (*home_dir == '\0')
+		ret = -1;
+	else {
 		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
@@ -204,11 +206,16 @@
 		ret = chdir(full_home_dir);
 		if (reply->uid != master_uid && seteuid(master_uid) < 0)
 			i_fatal("seteuid(%s) failed: %m", dec2str(master_uid));
-		if (ret < 0) {
+
+		/* 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. */
+		if (ret < 0 && (errno != ENOENT || *chroot_dir != '\0')) {
 			i_fatal("chdir(%s) failed with uid %s: %m",
 				full_home_dir, dec2str(reply->uid));
 		}
-	} else {
+	}
+	if (ret < 0) {
 		/* We still have to change to some directory where we have
 		   rx-access. /tmp should exist everywhere. */
 		if (chdir("/tmp") < 0)



More information about the dovecot-cvs mailing list