dovecot-1.2: mail_location: Added support back for ~user/ expans...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jul 8 01:36:10 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/072a44932976
changeset: 9195:072a44932976
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jul 07 18:36:02 2009 -0400
description:
mail_location: Added support back for ~user/ expansion in paths.

diffstat:

1 file changed, 22 insertions(+), 12 deletions(-)
src/lib-storage/mailbox-list.c |   34 ++++++++++++++++++++++------------

diffs (70 lines):

diff -r 9b8c606eb611 -r 072a44932976 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c	Tue Jul 07 17:29:27 2009 -0400
+++ b/src/lib-storage/mailbox-list.c	Tue Jul 07 18:36:02 2009 -0400
@@ -106,14 +106,28 @@ int mailbox_list_alloc(const char *drive
 }
 
 static int fix_path(struct mail_namespace *ns, const char *path,
-		    const char **path_r)
+		    const char **path_r, const char **error_r)
 {
 	size_t len = strlen(path);
 
 	if (len > 1 && path[len-1] == '/')
 		path = t_strndup(path, len-1);
-	if (mail_user_try_home_expand(ns->user, &path) < 0)
-		return -1;
+	if (path[0] == '~' && path[1] != '/') {
+		/* ~otheruser/dir */
+		if (home_try_expand(&path) < 0) {
+			*error_r = t_strconcat(
+				"No home directory for system user. "
+				"Can't expand ", t_strcut(path, '/'),
+				" for ", NULL);
+			return -1;
+		}
+	} else {
+		if (mail_user_try_home_expand(ns->user, &path) < 0) {
+			*error_r = "Home directory not set for user. "
+				"Can't expand ~/ for ";
+			return -1;
+		}
+	}
 	*path_r = path;
 	return 0;
 }
@@ -143,7 +157,7 @@ int mailbox_list_settings_parse(const ch
 				const char **layout, const char **alt_dir_r,
 				const char **error_r)
 {
-	const char *const *tmp, *key, *value, **dest, *str;
+	const char *const *tmp, *key, *value, **dest, *str, *error;
 
 	i_assert(*data != '\0');
 
@@ -154,10 +168,8 @@ int mailbox_list_settings_parse(const ch
 	/* <root dir> */
 	tmp = t_strsplit(data, ":");
 	str = split_next_arg(&tmp);
-	if (fix_path(ns, str, &set->root_dir) < 0) {
-		*error_r = t_strdup_printf(
-			"Home directory not set, can't expand ~/ for "
-			"mail root dir in: %s", data);
+	if (fix_path(ns, str, &set->root_dir, &error) < 0) {
+		*error_r = t_strconcat(error, "mail root dir in: ", data, NULL);
 		return -1;
 	}
 
@@ -192,10 +204,8 @@ int mailbox_list_settings_parse(const ch
 			*error_r = t_strdup_printf("Unknown setting: %s", key);
 			return -1;
 		}
-		if (fix_path(ns, value, dest) < 0) {
-			*error_r = t_strdup_printf(
-				"Home directory not set, can't expand ~/ for "
-				"%s in: %s", key, data);
+		if (fix_path(ns, value, dest, &error) < 0) {
+			*error_r = t_strconcat(error, key, " in: ", data, NULL);
 			return -1;
 		}
 	}


More information about the dovecot-cvs mailing list