dovecot-2.0: lib-lda: Fixed handling duplicate database when use...

dovecot at dovecot.org dovecot at dovecot.org
Thu Sep 23 18:07:19 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/75e466740c57
changeset: 12155:75e466740c57
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Sep 23 16:06:28 2010 +0100
description:
lib-lda: Fixed handling duplicate database when user has no home dir.
Now it gives a clear error message and doesn't crash with some OSes.

diffstat:

 src/lib-lda/duplicate.c |  23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diffs (57 lines):

diff -r 6d6d9f49f61b -r 75e466740c57 src/lib-lda/duplicate.c
--- a/src/lib-lda/duplicate.c	Thu Sep 23 15:53:09 2010 +0100
+++ b/src/lib-lda/duplicate.c	Thu Sep 23 16:06:28 2010 +0100
@@ -203,6 +203,8 @@
 	struct duplicate_file *file;
 	pool_t pool;
 
+	i_assert(ctx->path != NULL);
+
 	pool = pool_alloconly_create("duplicates", 10240);
 
 	file = p_new(pool, struct duplicate_file, 1);
@@ -235,8 +237,13 @@
 {
 	struct duplicate d;
 
-	if (ctx->file == NULL)
+	if (ctx->file == NULL) {
+		if (ctx->path == NULL) {
+			/* duplicate database disabled */
+			return 0;
+		}
 		ctx->file = duplicate_file_new(ctx);
+	}
 
 	d.id = id;
 	d.id_size = id_size;
@@ -252,8 +259,13 @@
 	struct duplicate *d;
 	void *new_id;
 
-	if (ctx->file == NULL)
+	if (ctx->file == NULL) {
+		if (ctx->path == NULL) {
+			/* duplicate database disabled */
+			return;
+		}
 		ctx->file = duplicate_file_new(ctx);
+	}
 
 	new_id = p_malloc(ctx->file->pool, id_size);
 	memcpy(new_id, id, id_size);
@@ -313,9 +325,12 @@
 	struct duplicate_context *ctx;
 	const struct mail_storage_settings *mail_set;
 	const char *home;
+	int ret;
 
-	if (mail_user_get_home(user, &home) < 0)
-		i_fatal("User %s doesn't have home dir set", user->username);
+	if ((ret = mail_user_get_home(user, &home)) <= 0) {
+		i_error("User %s doesn't have home dir set, "
+			"disabling duplicate database", user->username);
+	}
 
 	ctx = i_new(struct duplicate_context, 1);
 	ctx->path = i_strconcat(home, "/"DUPLICATE_FNAME, NULL);


More information about the dovecot-cvs mailing list