]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Remove unused passdb/userdb-template.[ch]
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 14 Feb 2025 08:12:04 +0000 (10:12 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 18 Feb 2025 06:52:10 +0000 (06:52 +0000)
src/auth/Makefile.am
src/auth/auth-request-fields.c
src/auth/auth-request.c
src/auth/auth-worker-server.c
src/auth/auth.c
src/auth/passdb-static.c
src/auth/passdb-template.c [deleted file]
src/auth/passdb-template.h [deleted file]
src/auth/userdb-static.c
src/auth/userdb-template.c [deleted file]
src/auth/userdb-template.h [deleted file]

index f8a0d153bc39900cc31475d875642d8005336bcf..7c185ee0e8e4632a5a2620fdf231f697bfb52fdd 100644 (file)
@@ -120,7 +120,6 @@ auth_common_sources = \
        passdb-pam.c \
        passdb-sql.c \
        passdb-static.c \
-       passdb-template.c \
        userdb.c \
        userdb-blocking.c \
        userdb-passwd.c \
@@ -128,7 +127,6 @@ auth_common_sources = \
        userdb-prefetch.c \
        userdb-static.c \
        userdb-sql.c \
-       userdb-template.c \
        $(ldap_sources) \
        $(lua_sources)
 
@@ -162,10 +160,8 @@ headers = \
        passdb.h \
        passdb-blocking.h \
        passdb-cache.h \
-       passdb-template.h \
        userdb.h \
-       userdb-blocking.h \
-       userdb-template.h
+       userdb-blocking.h
 
 if GSSAPI_PLUGIN
 libmech_gssapi_la_LDFLAGS = -module -avoid-version
index bd545462fba3501950687714b18a78e4eb3126d3..b7bfb00b1caf060670f6f15f7c5c0e1219ec0389 100644 (file)
@@ -8,7 +8,6 @@
 #include "str-sanitize.h"
 #include "base64.h"
 #include "auth-request.h"
-#include "userdb-template.h"
 
 void auth_request_fields_init(struct auth_request *request)
 {
index c20a35cad79a7920b6c0feb1ffa621bdaf7b74eb..b81e65b4b8f722f539e4203cd0089d4f01a6816e 100644 (file)
@@ -25,9 +25,7 @@
 #include "passdb.h"
 #include "passdb-blocking.h"
 #include "passdb-cache.h"
-#include "passdb-template.h"
 #include "userdb-blocking.h"
-#include "userdb-template.h"
 #include "password-scheme.h"
 #include "wildcard-match.h"
 
index 8faac6905875f0740bbcb29d120404176a8acfcf..ffeaca43a821bb5f48294212e4618914e34cd7f6 100644 (file)
@@ -13,7 +13,6 @@
 #include "process-title.h"
 #include "master-service.h"
 #include "auth-request.h"
-#include "userdb-template.h"
 #include "auth-worker-server.h"
 #include "db-oauth2.h"
 
index a8fbab3d776a958419a1d13667808cbacfd75a15..d1c3a99d5a5b2099608bca83eb02492f8a5997f7 100644 (file)
@@ -6,8 +6,6 @@
 #include "mech.h"
 #include "userdb.h"
 #include "passdb.h"
-#include "passdb-template.h"
-#include "userdb-template.h"
 #include "auth.h"
 #include "dns-lookup.h"
 
index 78843f056a8ee350401bba37c590122855bb8184..ae3441818a5afefa81229791a60c1829e8571fb1 100644 (file)
@@ -2,7 +2,6 @@
 
 #include "auth-common.h"
 #include "passdb.h"
-#include "passdb-template.h"
 #include "password-scheme.h"
 #include "settings.h"
 #include "auth-settings.h"
diff --git a/src/auth/passdb-template.c b/src/auth/passdb-template.c
deleted file mode 100644 (file)
index 2f3da8a..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright (c) 2003-2018 Dovecot authors, see the included COPYING file */
-
-#include "auth-common.h"
-#include "array.h"
-#include "str.h"
-#include "passdb.h"
-#include "passdb-template.h"
-
-struct passdb_template_arg {
-       const char *key;
-       struct var_expand_program *program;
-};
-
-struct passdb_template {
-       ARRAY(struct passdb_template_arg) args;
-       ARRAY_TYPE(const_string) keys;
-};
-
-struct passdb_template *passdb_template_build(pool_t pool, const char *args)
-{
-       struct passdb_template *tmpl;
-       const char *const *tmp;
-
-       tmpl = p_new(pool, struct passdb_template, 1);
-
-       tmp = t_strsplit_spaces(args, " ");
-
-       p_array_init(&tmpl->args, pool, str_array_length(tmp) / 2);
-       p_array_init(&tmpl->keys, pool, str_array_length(tmp) / 2);
-
-       for (; *tmp != NULL; tmp++) {
-               const char *p = strchr(*tmp, '=');
-               const char *kp;
-               const char *error;
-
-               if (p == NULL)
-                       kp = *tmp;
-               else
-                       kp = t_strdup_until(*tmp, p++);
-
-               if (*kp == '\0')
-                       i_fatal("Invalid passdb template %s - key must not be empty",
-                               args);
-
-               char *key = p_strdup(pool, kp);
-               struct var_expand_program *prog;
-               if (var_expand_program_create(p, &prog, &error) < 0)
-                       i_fatal("Invalid passdb template value %s: %s", p, error);
-
-               struct passdb_template_arg *arg = array_append_space(&tmpl->args);
-               arg->key = key;
-               arg->program = prog;
-               array_push_back(&tmpl->keys, &arg->key);
-       }
-
-       return tmpl;
-}
-
-int passdb_template_export(struct passdb_template *tmpl,
-                          struct auth_request *auth_request,
-                          const char **error_r)
-{
-       string_t *str;
-       const struct passdb_template_arg *arg;
-       int ret = 0;
-
-       if (passdb_template_is_empty(tmpl))
-               return 0;
-
-       const struct var_expand_params params = {
-               .table = auth_request_get_var_expand_table(auth_request),
-               .providers = auth_request_var_expand_providers,
-               .context = auth_request,
-       };
-
-       str = t_str_new(256);
-
-       array_foreach(&tmpl->args, arg) {
-               str_truncate(str, 0);
-               ret = var_expand_program_execute(str, arg->program, &params,
-                                                error_r);
-               if (ret < 0)
-                       break;
-               auth_request_set_field(auth_request, arg->key, str_c(str),
-                                      STATIC_PASS_SCHEME);
-       }
-
-       return ret;
-}
-
-bool passdb_template_is_empty(struct passdb_template *tmpl)
-{
-       return array_is_empty(&tmpl->args);
-}
-
-const char *const *passdb_template_get_args(struct passdb_template *tmpl,
-                                           unsigned int *count_r)
-{
-       return array_get(&tmpl->keys, count_r);
-}
-
-void passdb_template_free(struct passdb_template **_tmpl)
-{
-       struct passdb_template *tmpl = *_tmpl;
-       if (tmpl == NULL)
-               return;
-       *_tmpl = NULL;
-
-       struct passdb_template_arg *arg;
-
-       array_foreach_modifiable(&tmpl->args, arg)
-               var_expand_program_free(&arg->program);
-}
diff --git a/src/auth/passdb-template.h b/src/auth/passdb-template.h
deleted file mode 100644 (file)
index 6bcdbc7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef PASSDB_TEMPLATE_H
-#define PASSDB_TEMPLATE_H
-
-struct passdb_template *passdb_template_build(pool_t pool, const char *args);
-int passdb_template_export(struct passdb_template *tmpl,
-                          struct auth_request *auth_request,
-                          const char **error_r);
-bool passdb_template_is_empty(struct passdb_template *tmpl);
-
-void passdb_template_free(struct passdb_template **_tmpl);
-
-const char *const *passdb_template_get_args(struct passdb_template *tmpl, unsigned int *count_r);
-
-#endif
index d95089eac862315b0b5a79cd2430fa2c4b7ae75c..3f19ca222a62d2bdade8bdb69d97f936b04931ea 100644 (file)
@@ -5,7 +5,6 @@
 #include "array.h"
 #include "str.h"
 #include "userdb.h"
-#include "userdb-template.h"
 #include "settings.h"
 
 
diff --git a/src/auth/userdb-template.c b/src/auth/userdb-template.c
deleted file mode 100644 (file)
index c95eaf8..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Copyright (c) 2003-2018 Dovecot authors, see the included COPYING file */
-
-#include "auth-common.h"
-#include "array.h"
-#include "str.h"
-#include "userdb.h"
-#include "userdb-template.h"
-
-struct userdb_template_arg {
-       const char *key;
-       struct var_expand_program *program;
-};
-
-struct userdb_template {
-       ARRAY(struct userdb_template_arg) args;
-       ARRAY_TYPE(const_string) keys;
-};
-
-struct userdb_template *
-userdb_template_build(pool_t pool, const char *userdb_name, const char *args)
-{
-       struct userdb_template *tmpl;
-       const char *const *tmp;
-       uid_t uid;
-       gid_t gid;
-
-       tmpl = p_new(pool, struct userdb_template, 1);
-
-       tmp = t_strsplit_spaces(args, " ");
-       p_array_init(&tmpl->args, pool, str_array_length(tmp) / 2);
-       p_array_init(&tmpl->keys, pool, str_array_length(tmp) / 2);
-
-       for (; *tmp != NULL; tmp++) {
-               const char *p = strchr(*tmp, '=');
-               const char *kp;
-               const char *error;
-
-               if (p == NULL)
-                       kp = *tmp;
-               else
-                       kp = t_strdup_until(*tmp, p++);
-
-               if (*kp == '\0')
-                       i_fatal("Invalid userdb template %s - key must not be empty",
-                               args);
-
-               char *key = p_strdup(pool, kp);
-               const char *nonull_value = p == NULL ? "" : p;
-               if (strcasecmp(key, "uid") == 0) {
-                       uid = userdb_parse_uid(NULL, nonull_value);
-                       if (uid == (uid_t)-1) {
-                               i_fatal("%s userdb: Invalid uid: %s",
-                                       userdb_name, nonull_value);
-                       }
-                       p = dec2str(uid);
-               } else if (strcasecmp(key, "gid") == 0) {
-                       gid = userdb_parse_gid(NULL, nonull_value);
-                       if (gid == (gid_t)-1) {
-                               i_fatal("%s userdb: Invalid gid: %s",
-                                       userdb_name, nonull_value);
-                       }
-                       p = dec2str(gid);
-               } else if (*kp == '\0') {
-                       i_fatal("%s userdb: Empty key (=%s)",
-                               userdb_name, nonull_value);
-               }
-               struct var_expand_program *prog;
-               if (var_expand_program_create(p, &prog, &error) < 0)
-                       i_fatal("Invalid userdb template value %s: %s", p, error);
-
-               struct userdb_template_arg *arg = array_append_space(&tmpl->args);
-               arg->key = key;
-               arg->program = prog;
-               array_push_back(&tmpl->keys, &arg->key);
-       }
-
-       return tmpl;
-}
-
-int userdb_template_export(struct userdb_template *tmpl,
-                          struct auth_request *auth_request,
-                          const char **error_r)
-{
-       const struct userdb_template_arg *arg;
-       string_t *str;
-       int ret = 0;
-
-       if (userdb_template_is_empty(tmpl))
-               return 0;
-
-       const struct var_expand_params params = {
-               .table = auth_request_get_var_expand_table(auth_request),
-               .providers = auth_request_var_expand_providers,
-               .context = auth_request,
-       };
-
-       str = t_str_new(256);
-
-       array_foreach(&tmpl->args, arg) {
-               str_truncate(str, 0);
-               ret = var_expand_program_execute(str, arg->program, &params,
-                                                error_r);
-               if (ret < 0)
-                       break;
-               auth_request_set_userdb_field(auth_request, arg->key, str_c(str));
-       }
-
-       return ret;
-}
-
-bool userdb_template_is_empty(struct userdb_template *tmpl)
-{
-       return array_is_empty(&tmpl->args);
-}
-
-const char *const *userdb_template_get_args(struct userdb_template *tmpl,
-                                           unsigned int *count_r)
-{
-       return array_get(&tmpl->keys, count_r);
-}
-
-void userdb_template_free(struct userdb_template **_tmpl)
-{
-       struct userdb_template *tmpl = *_tmpl;
-       if (tmpl == NULL)
-               return;
-       *_tmpl = NULL;
-
-       struct userdb_template_arg *arg;
-
-       array_foreach_modifiable(&tmpl->args, arg)
-               var_expand_program_free(&arg->program);
-}
diff --git a/src/auth/userdb-template.h b/src/auth/userdb-template.h
deleted file mode 100644 (file)
index 26f3613..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef USERDB_TEMPLATE_H
-#define USERDB_TEMPLATE_H
-
-struct userdb_template *
-userdb_template_build(pool_t pool, const char *userdb_name, const char *args);
-int userdb_template_export(struct userdb_template *tmpl,
-                          struct auth_request *auth_request,
-                          const char **error_r);
-bool userdb_template_remove(struct userdb_template *tmpl,
-                           const char *key, const char **value_r);
-bool userdb_template_is_empty(struct userdb_template *tmpl);
-const char *const *userdb_template_get_args(struct userdb_template *tmpl,
-                                           unsigned int *count_r);
-void userdb_template_free(struct userdb_template **_tmpl);
-
-#endif