]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: if passwd-file isn't the only userdb, don't complain about missing userdb fields
authorTimo Sirainen <tss@iki.fi>
Tue, 31 Jul 2012 17:59:22 +0000 (20:59 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 31 Jul 2012 17:59:22 +0000 (20:59 +0300)
src/auth/db-passwd-file.c
src/auth/db-passwd-file.h

index 5c44f0f6fd4aeb55a654107e391792f52a3ceed0..7b980e9a3af80694ec50b2bb2024a2994ad758a4 100644 (file)
@@ -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 @@ static void passwd_file_add(struct passwd_file *pw, const char *username,
        }
 
        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 @@ static struct db_passwd_file *db_passwd_file_find(const char *path)
        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_passwd_file_init(const char *path, bool userdb, bool debug)
        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++) {
index 3bf97f7bf265ab362411020df49594befef53c4b..8f00bfa9b658a2e2ca9c67796907b133e942b6ae 100644 (file)
@@ -37,6 +37,7 @@ struct db_passwd_file {
 
        unsigned int vars:1;
        unsigned int userdb:1;
+       unsigned int userdb_warn_missing:1;
        unsigned int debug:1;
 };