dovecot-2.2: lib-dict: file backend now expands ~/ paths if home...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 28 13:11:50 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/58c3676c116c
changeset: 17752:58c3676c116c
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 28 21:57:34 2014 +0900
description:
lib-dict: file backend now expands ~/ paths if home_dir setting is set.

diffstat:

 src/lib-dict/dict-file.c |  10 ++++++----
 src/lib-dict/dict.h      |   2 ++
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (50 lines):

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);


More information about the dovecot-cvs mailing list