# HG changeset patch # User Timo Sirainen # Date 1247006162 14400 # Node ID 072a44932976e884cd4a1e2b593bdb2365716a73 # Parent 9b8c606eb611fac8c8da1ae2d5e1776210548117 mail_location: Added support back for ~user/ expansion in paths. 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 @@ } 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 @@ 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 @@ /* */ 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 @@ *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; } }