dovecot-2.0: Fixed home=/home/./user style chrooting to work again.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 16 21:52:06 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/eeaf30cfad36
changeset: 12431:eeaf30cfad36
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 16 19:51:46 2010 +0000
description:
Fixed home=/home/./user style chrooting to work again.
diffstat:
src/lib-storage/mail-storage-service.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diffs (47 lines):
diff -r f78260c108b0 -r eeaf30cfad36 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c Tue Nov 16 19:32:51 2010 +0000
+++ b/src/lib-storage/mail-storage-service.c Tue Nov 16 19:51:46 2010 +0000
@@ -167,7 +167,9 @@
const struct auth_user_reply *reply,
const char **error_r)
{
- const char *const *str, *line;
+ const char *home = reply->home;
+ const char *chroot = reply->chroot;
+ const char *const *str, *line, *p;
unsigned int i, count;
int ret = 0;
@@ -181,18 +183,26 @@
if (reply->gid != (uid_t)-1)
set_keyval(ctx, user, "mail_gid", dec2str(reply->gid));
- if (reply->home != NULL)
+ if (home != NULL && chroot == NULL &&
+ *user->user_set->valid_chroot_dirs != '\0' &&
+ (p = strstr(home, "/./")) != NULL) {
+ /* wu-ftpd like <chroot>/./<home> - check only if there's even
+ a possibility of using them (non-empty valid_chroot_dirs) */
+ chroot = t_strdup_until(home, p);
+ home = p + 2;
+ }
+
+ if (home != NULL)
set_keyval(ctx, user, "mail_home", reply->home);
- if (reply->chroot != NULL) {
- if (!validate_chroot(user->user_set, reply->chroot)) {
+ if (chroot != NULL) {
+ if (!validate_chroot(user->user_set, chroot)) {
*error_r = t_strdup_printf(
"userdb returned invalid chroot directory: %s "
- "(see valid_chroot_dirs setting)",
- reply->chroot);
+ "(see valid_chroot_dirs setting)", chroot);
return -1;
}
- set_keyval(ctx, user, "mail_chroot", reply->chroot);
+ set_keyval(ctx, user, "mail_chroot", chroot);
}
str = array_get(&reply->extra_fields, &count);
More information about the dovecot-cvs
mailing list