dovecot-2.2: auth: if passwd-file isn't the only userdb, don't c...

dovecot at dovecot.org dovecot at dovecot.org
Fri Aug 10 05:24:41 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/f74557336910
changeset: 14818:f74557336910
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jul 31 20:59:22 2012 +0300
description:
auth: if passwd-file isn't the only userdb, don't complain about missing userdb fields

diffstat:

 src/auth/db-passwd-file.c |  18 +++++++++++++++---
 src/auth/db-passwd-file.h |   1 +
 2 files changed, 16 insertions(+), 3 deletions(-)

diffs (65 lines):

diff -r fac6b994e869 -r f74557336910 src/auth/db-passwd-file.c
--- a/src/auth/db-passwd-file.c	Tue Jul 31 18:34:53 2012 +0300
+++ b/src/auth/db-passwd-file.c	Tue Jul 31 20:59:22 2012 +0300
@@ -7,6 +7,7 @@
 #include "userdb.h"
 #include "db-passwd-file.h"
 
+#include "array.h"
 #include "buffer.h"
 #include "istream.h"
 #include "hash.h"
@@ -90,7 +91,7 @@
 	}
 
 	if (*args == NULL) {
-		if (pw->db->userdb) {
+		if (pw->db->userdb_warn_missing) {
 			i_error("passwd-file %s: User %s is missing "
 				"userdb info", pw->path, username);
 		}
@@ -290,6 +291,15 @@
 	return NULL;
 }
 
+static void db_passwd_file_set_userdb(struct db_passwd_file *db)
+{
+	db->userdb = TRUE;
+	/* warn about missing userdb fields only when there aren't any other
+	   userdbs. */
+	db->userdb_warn_missing =
+		array_count(&global_auth_settings->userdbs) == 1;
+}
+
 struct db_passwd_file *
 db_passwd_file_init(const char *path, bool userdb, bool debug)
 {
@@ -300,13 +310,15 @@
 	db = db_passwd_file_find(path);
 	if (db != NULL) {
 		db->refcount++;
-		db->userdb = TRUE;
+		if (userdb)
+			db_passwd_file_set_userdb(db);
 		return db;
 	}
 
 	db = i_new(struct db_passwd_file, 1);
 	db->refcount = 1;
-	db->userdb = userdb;
+	if (userdb)
+		db_passwd_file_set_userdb(db);
 	db->debug = debug;
 
 	for (p = path; *p != '\0'; p++) {
diff -r fac6b994e869 -r f74557336910 src/auth/db-passwd-file.h
--- a/src/auth/db-passwd-file.h	Tue Jul 31 18:34:53 2012 +0300
+++ b/src/auth/db-passwd-file.h	Tue Jul 31 20:59:22 2012 +0300
@@ -37,6 +37,7 @@
 
 	unsigned int vars:1;
 	unsigned int userdb:1;
+	unsigned int userdb_warn_missing:1;
 	unsigned int debug:1;
 };
 


More information about the dovecot-cvs mailing list