changeset 5446:ce1e1fab1e1d HEAD

When using chrooting, force the home directory to have '/' prefix so it's not treated as relative.
author Timo Sirainen <tss@iki.fi>
date Wed, 28 Mar 2007 23:06:37 +0300
parents 3a7ec48f8808
children 04404fd54cf6
files src/master/mail-process.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/mail-process.c	Wed Mar 28 23:05:14 2007 +0300
+++ b/src/master/mail-process.c	Wed Mar 28 23:06:37 2007 +0300
@@ -477,7 +477,11 @@
 	if (*chroot_dir == '\0' && (p = strstr(home_dir, "/./")) != NULL) {
 		/* wu-ftpd like <chroot>/./<home> */
 		chroot_dir = t_strdup_until(home_dir, p);
-		home_dir = p + 3;
+		home_dir = p + 2;
+	} else if (*chroot_dir != '\0' && *home_dir != '/') {
+		/* home directories should never be relative, but force this
+		   with chroots. */
+		home_dir = t_strconcat("/", home_dir, NULL);
 	}
 
 	if (!dump_capability) {
@@ -596,7 +600,7 @@
 		ret = -1;
 	} else {
 		full_home_dir = *chroot_dir == '\0' ? home_dir :
-			t_strconcat(chroot_dir, "/", home_dir, NULL);
+			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 and GID
 		   temporarily to make it work. */