]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Avoid unnecessary work if passdb/userdb { override_fields, default_fields ...
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 24 Jan 2016 20:10:01 +0000 (22:10 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 24 Jan 2016 20:10:01 +0000 (22:10 +0200)
src/auth/passdb-template.c
src/auth/passdb-template.h
src/auth/userdb-template.c

index b3be9f9b55821306f0d46beff99876ccd1ff2351..6153af4111a34b7a71d8c2ad28359041f178cdd8 100644 (file)
@@ -43,6 +43,9 @@ void passdb_template_export(struct passdb_template *tmpl,
        const char *const *args, *value;
        unsigned int i, count;
 
+       if (passdb_template_is_empty(tmpl))
+               return;
+
        str = t_str_new(256);
        table = auth_request_get_var_expand_table(auth_request, NULL);
 
@@ -79,3 +82,8 @@ bool passdb_template_remove(struct passdb_template *tmpl,
        }
        return FALSE;
 }
+
+bool passdb_template_is_empty(struct passdb_template *tmpl)
+{
+       return array_count(&tmpl->args) == 0;
+}
index e9d325f899874e28c7471585965578f2a0ee5ef3..b4a1f00357cd96d0f9ec0e9d2f62938130196bea 100644 (file)
@@ -8,5 +8,6 @@ void passdb_template_export(struct passdb_template *tmpl,
                            struct auth_request *auth_request);
 bool passdb_template_remove(struct passdb_template *tmpl,
                            const char *key, const char **value_r);
+bool passdb_template_is_empty(struct passdb_template *tmpl);
 
 #endif
index 1bf2abb468b550e8b02f8b91406e2b461a4ad3fa..840f303b0322acd7796b5d0e27fab20727483fc4 100644 (file)
@@ -66,6 +66,9 @@ void userdb_template_export(struct userdb_template *tmpl,
        const char *const *args, *value;
        unsigned int i, count;
 
+       if (userdb_template_is_empty(tmpl))
+               return;
+
        str = t_str_new(256);
        table = auth_request_get_var_expand_table(auth_request, NULL);