passdb-pam.c \
passdb-sql.c \
passdb-static.c \
- passdb-template.c \
userdb.c \
userdb-blocking.c \
userdb-passwd.c \
userdb-prefetch.c \
userdb-static.c \
userdb-sql.c \
- userdb-template.c \
$(ldap_sources) \
$(lua_sources)
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
#include "str-sanitize.h"
#include "base64.h"
#include "auth-request.h"
-#include "userdb-template.h"
void auth_request_fields_init(struct auth_request *request)
{
#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"
#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"
#include "mech.h"
#include "userdb.h"
#include "passdb.h"
-#include "passdb-template.h"
-#include "userdb-template.h"
#include "auth.h"
#include "dns-lookup.h"
#include "auth-common.h"
#include "passdb.h"
-#include "passdb-template.h"
#include "password-scheme.h"
#include "settings.h"
#include "auth-settings.h"
+++ /dev/null
-/* 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, ¶ms,
- 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);
-}
+++ /dev/null
-#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
#include "array.h"
#include "str.h"
#include "userdb.h"
-#include "userdb-template.h"
#include "settings.h"
+++ /dev/null
-/* 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, ¶ms,
- 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);
-}
+++ /dev/null
-#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