Hi,
I think that the wu-ftp style chroot /./ should be a configurable
option.
In our servers we have some home directories in /chroot-web/./username
(where web users can upload their web sites in a chrooted environment)
and all imap mail in /mail-disk/username.
We are planning a dovecot migration from our modified version of uw-imap
and we noticed that the chroot in /chroot-web/ can't be disabled.
This patch adds the bool option home_slash_dot_slash_chroot (feel free
to change this name to something easier to understand). Setting this to
"no" disables the wu-ftp style /./ chroot.
I hope this feature can be considered useful and soon included in
dovecot.
Regards,
Diego Liziero.
diff -dur dovecot-1.0.10/dovecot-example.conf dovecot-1.0.10-disable-slash-dot-slash-chroot/dovecot-example.conf
--- dovecot-1.0.10/dovecot-example.conf 2007-12-11 19:52:08.000000000 +0100
+++ dovecot-1.0.10-disable-slash-dot-slash-chroot/dovecot-example.conf 2008-02-15 10:44:39.000000000 +0100
@@ -354,6 +354,14 @@
# their mail directory anyway. <doc/wiki/Chrooting.txt>
#mail_chroot =
+# Enable checking /./ in user's home directory for chrooting.
+# With this enabled (default), when user's home contains /./ (eg.
+# /newroot/./newhome/user) two things are changed:
+# - mail_chroot is overridden and set to the path before /./
+# - %h (home) is set to the path after /.
+#
+#home_slash_dot_slash_chroot = yes
+
##
## Mailbox handling optimizations
##
diff -dur dovecot-1.0.10/src/master/mail-process.c dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/mail-process.c
--- dovecot-1.0.10/src/master/mail-process.c 2007-12-20 21:51:23.000000000 +0100
+++ dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/mail-process.c 2008-02-15 09:42:53.000000000 +0100
@@ -477,7 +477,7 @@
}
}
- if (*chroot_dir == '\0' && (p = strstr(home_dir, "/./")) != NULL) {
+ if (set->home_slash_dot_slash_chroot && *chroot_dir == '\0' && (p = strstr(home_dir, "/./")) != NULL) {
/* wu-ftpd like <chroot>/./<home> */
chroot_dir = t_strdup_until(home_dir, p);
home_dir = p + 2;
diff -dur dovecot-1.0.10/src/master/master-settings-defs.c dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/master-settings-defs.c
--- dovecot-1.0.10/src/master/master-settings-defs.c 2007-12-11 19:52:09.000000000 +0100
+++ dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/master-settings-defs.c 2008-02-15 09:13:30.000000000 +0100
@@ -50,6 +50,7 @@
/* mail */
DEF(SET_STR, valid_chroot_dirs),
DEF(SET_STR, mail_chroot),
+ DEF(SET_BOOL, home_slash_dot_slash_chroot),
DEF(SET_INT, max_mail_processes),
DEF(SET_BOOL, verbose_proctitle),
diff -dur dovecot-1.0.10/src/master/master-settings.c dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/master-settings.c
--- dovecot-1.0.10/src/master/master-settings.c 2007-12-21 16:10:24.000000000 +0100
+++ dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/master-settings.c 2008-02-15 09:12:21.000000000 +0100
@@ -199,6 +199,7 @@
/* mail */
MEMBER(valid_chroot_dirs) "",
MEMBER(mail_chroot) "",
+ MEMBER(home_slash_dot_slash_chroot) TRUE,
MEMBER(max_mail_processes) 1024,
MEMBER(verbose_proctitle) FALSE,
diff -dur dovecot-1.0.10/src/master/master-settings.h dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/master-settings.h
--- dovecot-1.0.10/src/master/master-settings.h 2007-12-11 19:52:09.000000000 +0100
+++ dovecot-1.0.10-disable-slash-dot-slash-chroot/src/master/master-settings.h 2008-02-15 09:12:36.000000000 +0100
@@ -60,6 +60,7 @@
/* mail */
const char *valid_chroot_dirs;
const char *mail_chroot;
+ bool home_slash_dot_slash_chroot;
unsigned int max_mail_processes;
bool verbose_proctitle;