# HG changeset patch # User Timo Sirainen # Date 1409230654 -32400 # Node ID 58c3676c116cdd505bee18b07d397918cd6e1f3c # Parent 77e71a45a4755fd02ddeaf44656501a54424d8de lib-dict: file backend now expands ~/ paths if home_dir setting is set. diff -r 77e71a45a475 -r 58c3676c116c src/lib-dict/dict-file.c --- 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); diff -r 77e71a45a475 -r 58c3676c116c src/lib-dict/dict.h --- 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);