]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Support wu-ftpd-like chrooting in /etc/passwd. If home directory ends with
authorTimo Sirainen <tss@iki.fi>
Thu, 8 May 2003 03:36:21 +0000 (06:36 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 8 May 2003 03:36:21 +0000 (06:36 +0300)
"/./", it's chrooted to.

--HG--
branch : HEAD

src/auth/userdb-passwd.c

index 601463d20241d371b83da32cdc7e7142ce348fcc..f1f5de762d9c9d770997ed928f0f112a8eb06219 100644 (file)
@@ -15,6 +15,7 @@ static void passwd_lookup(const char *user, userdb_callback_t *callback,
 {
        struct user_data data;
        struct passwd *pw;
+       size_t len;
 
        pw = getpwnam(user);
        if (pw == NULL) {
@@ -31,7 +32,16 @@ static void passwd_lookup(const char *user, userdb_callback_t *callback,
        data.gid = pw->pw_gid;
 
        data.virtual_user = data.system_user = pw->pw_name;
-       data.home = pw->pw_dir;
+
+       len = strlen(pw->pw_dir);
+       if (len < 3 || strcmp(pw->pw_dir + len - 3, "/./") != 0)
+               data.home = pw->pw_dir;
+       else {
+               /* wu-ftpd uses <chroot>/./<dir>. We don't support
+                  the dir after chroot, but this should work well enough. */
+               data.home = t_strndup(pw->pw_dir, len-3);
+               data.chroot = TRUE;
+       }
 
        callback(&data, context);
 }