dovecot-2.2: lib-storage: Added struct mail_user.nonexistent fla...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 15:31:15 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/5d465a3eceb2
changeset: 15276:5d465a3eceb2
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 29 15:29:52 2012 +0200
description:
lib-storage: Added struct mail_user.nonexistent flag, which is filled by userdb lookup.

diffstat:

 src/lib-storage/mail-user.c |  19 +++++++++++--------
 src/lib-storage/mail-user.h |   3 +++
 2 files changed, 14 insertions(+), 8 deletions(-)

diffs (50 lines):

diff -r 4c84efce3a94 -r 5d465a3eceb2 src/lib-storage/mail-user.c
--- a/src/lib-storage/mail-user.c	Mon Oct 29 15:18:34 2012 +0200
+++ b/src/lib-storage/mail-user.c	Mon Oct 29 15:29:52 2012 +0200
@@ -296,9 +296,6 @@
 	if (user->remote_ip != NULL)
 		info.remote_ip = *user->remote_ip;
 
-	if (mail_user_auth_master_conn == NULL)
-		return 0;
-
 	userdb_pool = pool_alloconly_create("userdb lookup", 2048);
 	ret = auth_master_user_lookup(mail_user_auth_master_conn,
 				      user->username, &info, userdb_pool,
@@ -320,12 +317,18 @@
 		return user->_home != NULL ? 1 : 0;
 	}
 
-	ret = mail_user_userdb_lookup_home(user);
-	if (ret < 0)
+	if (mail_user_auth_master_conn == NULL) {
+		/* no userdb connection. we can only use mail_home setting. */
+		user->_home = user->set->mail_home;
+	} else if ((ret = mail_user_userdb_lookup_home(user)) < 0) {
+		/* userdb lookup failed */
 		return -1;
-
-	if (ret > 0 && user->_home == NULL && *user->set->mail_home != '\0') {
-		/* no home in userdb, fallback to mail_home setting */
+	} else if (ret == 0) {
+		/* user doesn't exist */
+		user->nonexistent = TRUE;
+	} else if (user->_home == NULL && *user->set->mail_home != '\0') {
+		/* no home returned by userdb lookup, fallback to mail_home
+		   setting. */
 		user->_home = user->set->mail_home;
 	}
 	user->home_looked_up = TRUE;
diff -r 4c84efce3a94 -r 5d465a3eceb2 src/lib-storage/mail-user.h
--- a/src/lib-storage/mail-user.h	Mon Oct 29 15:18:34 2012 +0200
+++ b/src/lib-storage/mail-user.h	Mon Oct 29 15:29:52 2012 +0200
@@ -46,6 +46,9 @@
 	/* Module-specific contexts. See mail_storage_module_id. */
 	ARRAY(union mail_user_module_context *) module_contexts;
 
+	/* User doesn't exist (as reported by userdb lookup when looking
+	   up home) */
+	unsigned int nonexistent:1;
 	/* Either home is set or there is no home for the user. */
 	unsigned int home_looked_up:1;
 	/* User is an administrator. Allow operations not normally allowed


More information about the dovecot-cvs mailing list