Mercurial > dovecot > original-hg > dovecot-2.2
changeset 17752:58c3676c116c
lib-dict: file backend now expands ~/ paths if home_dir setting is set.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 28 Aug 2014 21:57:34 +0900 |
parents | 77e71a45a475 |
children | 866bb1354e85 |
files | src/lib-dict/dict-file.c src/lib-dict/dict.h |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-dict/dict-file.c Thu Aug 28 21:56:41 2014 +0900 +++ b/src/lib-dict/dict-file.c Thu Aug 28 21:57:34 2014 +0900 @@ -55,11 +55,11 @@ static int file_dict_init(struct dict *driver, const char *uri, - const struct dict_settings *set ATTR_UNUSED, + const struct dict_settings *set, struct dict **dict_r, const char **error_r) { struct file_dict *dict; - const char *p; + const char *p, *path; dict = i_new(struct file_dict, 1); dict->lock_method = FILE_LOCK_METHOD_DOTLOCK; @@ -67,9 +67,9 @@ p = strchr(uri, ':'); if (p == NULL) { /* no parameters */ - dict->path = i_strdup(uri); + path = uri; } else { - dict->path = i_strdup_until(uri, p++); + path = t_strdup_until(uri, p++); if (strcmp(p, "lock=fcntl") == 0) dict->lock_method = FILE_LOCK_METHOD_FCNTL; else if (strcmp(p, "lock=flock") == 0) @@ -80,6 +80,8 @@ return -1; } } + dict->path = set->home_dir == NULL ? i_strdup(path) : + i_strdup(home_expand_tilde(path, set->home_dir)); dict->dict = *driver; dict->hash_pool = pool_alloconly_create("file dict", 1024); hash_table_create(&dict->hash, dict->hash_pool, 0, str_hash, strcmp);
--- a/src/lib-dict/dict.h Thu Aug 28 21:56:41 2014 +0900 +++ b/src/lib-dict/dict.h Thu Aug 28 21:57:34 2014 +0900 @@ -22,6 +22,8 @@ enum dict_data_type value_type; const char *username; const char *base_dir; + /* home directory for the user, if known */ + const char *home_dir; }; typedef void dict_transaction_commit_callback_t(int ret, void *context);