static struct passdb_module * vpopmail_preinit(pool_t pool, const char *args) { static bool vauth_load_initialized = FALSE; struct vpopmail_passdb_module *module; const char *const *tmp; module = p_new(pool, struct vpopmail_passdb_module, 1); module->module.default_pass_scheme = VPOPMAIL_DEFAULT_PASS_SCHEME; module->module.blocking = TRUE; tmp = t_strsplit_spaces(args, " "); for (; *tmp != NULL; tmp++) { if (strncmp(*tmp, "cache_key=", 10) == 0) { module->module.default_cache_key = auth_cache_parse_key(pool, *tmp + 10); } else if (strncmp(*tmp, "webmail=", 8) == 0) { if (net_addr2ip(*tmp + 8, &module->webmail_ip) < 0) i_fatal("vpopmail: Invalid webmail IP address"); } else if (strcmp(*tmp, "blocking=no") == 0) { module->module.blocking = FALSE; } else { i_fatal("passdb vpopmail: Unknown setting: %s", *tmp); } } if (!vauth_load_initialized) { vauth_load_initialized = TRUE; if (vauth_open(0) != 0) i_fatal("vpopmail: vauth_open() failed"); } return &module->module; }
static struct passdb_module * passwd_file_preinit(pool_t pool, const char *args) { struct passwd_file_passdb_module *module; const char *scheme = PASSWD_FILE_DEFAULT_SCHEME; const char *format = PASSWD_FILE_DEFAULT_USERNAME_FORMAT; const char *key, *value; while (*args != '\0') { if (*args == '/') break; key = args; value = strchr(key, '='); if (value == NULL) { value = ""; args = strchr(key, ' '); } else { key = t_strdup_until(key, value); args = strchr(++value, ' '); if (args != NULL) value = t_strdup_until(value, args); } if (args == NULL) args = ""; else args++; if (strcmp(key, "scheme") == 0) scheme = p_strdup(pool, value); else if (strcmp(key, "username_format") == 0) format = p_strdup(pool, value); else i_fatal("passdb passwd-file: Unknown setting: %s", key); } if (*args == '\0') i_fatal("passdb passwd-file: Missing args"); module = p_new(pool, struct passwd_file_passdb_module, 1); module->pwf = db_passwd_file_init(args, FALSE, global_auth_settings->debug); module->username_format = format; if (!module->pwf->vars) module->module.cache_key = format; else { module->module.cache_key = auth_cache_parse_key(pool, t_strconcat(format, module->pwf->path, NULL)); } module->module.default_pass_scheme = scheme; return &module->module; }
static struct userdb_module * userdb_sql_preinit(pool_t pool, const char *args) { struct sql_userdb_module *module; module = p_new(pool, struct sql_userdb_module, 1); module->conn = db_sql_init(args, TRUE); module->module.cache_key = auth_cache_parse_key(pool, module->conn->set.user_query); return &module->module; }
static struct userdb_module * userdb_dict_preinit(pool_t pool, const char *args) { struct dict_userdb_module *module; struct dict_connection *conn; module = p_new(pool, struct dict_userdb_module, 1); module->conn = conn = db_dict_init(args); module->module.blocking = TRUE; module->module.default_cache_key = auth_cache_parse_key(pool, db_dict_parse_cache_key(&conn->set.keys, &conn->set.userdb_fields, &conn->set.parsed_userdb_objects)); return &module->module; }
static struct passdb_module * bsdauth_preinit(pool_t pool, const char *args) { struct passdb_module *module; module = p_new(pool, struct passdb_module, 1); module->default_pass_scheme = "PLAIN"; /* same reason as PAM */ module->blocking = TRUE; if (strcmp(args, "blocking=no") == 0) module->blocking = FALSE; else if (strncmp(args, "cache_key=", 10) == 0) module->cache_key = auth_cache_parse_key(pool, args + 10); else if (*args != '\0') i_fatal("passdb bsdauth: Unknown setting: %s", args); return module; }
static struct userdb_module * userdb_lua_preinit(pool_t pool, const char *args) { struct dlua_userdb_module *module; const char *cache_key = "%u"; bool blocking = TRUE; module = p_new(pool, struct dlua_userdb_module, 1); const char *const *fields = t_strsplit_spaces(args, " "); while(*fields != NULL) { if (str_begins(*fields, "file=")) { module->file = p_strdup(pool, (*fields)+5); } else if (str_begins(*fields, "blocking=")) { const char *value = (*fields)+9; if (strcmp(value, "yes") == 0) { blocking = TRUE; } else if (strcmp(value, "no") == 0) { blocking = FALSE; } else { i_fatal("Invalid value %s. " "Field blocking must be yes or no", value); } } else if (str_begins(*fields, "cache_key=")) { if (*((*fields)+10) != '\0') cache_key = (*fields)+10; else /* explicitly disable auth caching for lua */ cache_key = NULL; } else { i_fatal("Unsupported parameter %s", *fields); } fields++; } if (module->file == NULL) i_fatal("userdb-lua: Missing mandatory file= parameter"); module->module.blocking = blocking; if (cache_key != NULL) { module->module.default_cache_key = auth_cache_parse_key(pool, cache_key); } return &module->module; }
static struct userdb_module * passwd_file_preinit(pool_t pool, const char *args) { struct passwd_file_userdb_module *module; const char *format = PASSWD_FILE_DEFAULT_USERNAME_FORMAT; const char *p; if (strncmp(args, "username_format=", 16) == 0) { args += 16; p = strchr(args, ' '); if (p == NULL) { format = p_strdup(pool, args); args = ""; } else { format = p_strdup_until(pool, args, p); args = p + 1; } } if (*args == '\0') i_fatal("userdb passwd-file: Missing args"); module = p_new(pool, struct passwd_file_userdb_module, 1); module->pwf = db_passwd_file_init(args, TRUE, global_auth_settings->debug); module->username_format = format; if (!module->pwf->vars) module->module.cache_key = PASSWD_FILE_CACHE_KEY; else { module->module.cache_key = auth_cache_parse_key(pool, t_strconcat(PASSWD_FILE_CACHE_KEY, module->pwf->path, NULL)); } return &module->module; }
static struct userdb_module * userdb_ldap_preinit(pool_t pool, const char *args) { struct ldap_userdb_module *module; struct ldap_connection *conn; module = p_new(pool, struct ldap_userdb_module, 1); module->conn = conn = db_ldap_init(args, TRUE); p_array_init(&conn->user_attr_map, pool, 16); p_array_init(&conn->iterate_attr_map, pool, 16); db_ldap_set_attrs(conn, conn->set.user_attrs, &conn->user_attr_names, &conn->user_attr_map, NULL); db_ldap_set_attrs(conn, conn->set.iterate_attrs, &conn->iterate_attr_names, &conn->iterate_attr_map, NULL); module->module.blocking = conn->set.blocking; module->module.cache_key = auth_cache_parse_key(pool, t_strconcat(conn->set.base, conn->set.user_filter, NULL)); return &module->module; }