}
struct db_passwd_file *
-db_passwd_file_init(const char *path, const char *username_format,
- bool userdb, bool debug)
+db_passwd_file_init(const char *path, bool userdb, bool debug)
{
struct db_passwd_file *db;
const char *p;
db->refcount = 1;
db->userdb = userdb;
db->debug = debug;
- db->username_format = username_format;
for (p = path; *p != '\0'; p++) {
if (*p == '%' && p[1] != '\0') {
}
struct passwd_user *
-db_passwd_file_lookup(struct db_passwd_file *db, struct auth_request *request)
+db_passwd_file_lookup(struct db_passwd_file *db, struct auth_request *request,
+ const char *username_format)
{
struct passwd_file *pw;
struct passwd_user *pu;
username = t_str_new(256);
table = auth_request_get_var_expand_table(request,
auth_request_str_escape);
- var_expand(username, db->username_format, table);
+ var_expand(username, username_format, table);
auth_request_log_debug(request, "passwd-file",
"lookup: user=%s file=%s",
char *path;
struct hash_table *files;
struct passwd_file *default_file;
- const char *username_format;
unsigned int vars:1;
unsigned int userdb:1;
};
struct passwd_user *
-db_passwd_file_lookup(struct db_passwd_file *db, struct auth_request *request);
+db_passwd_file_lookup(struct db_passwd_file *db, struct auth_request *request,
+ const char *username_format);
struct db_passwd_file *
-db_passwd_file_init(const char *path, const char *username_format,
- bool userdb, bool debug);
+db_passwd_file_init(const char *path, bool userdb, bool debug);
void db_passwd_file_parse(struct db_passwd_file *db);
void db_passwd_file_unref(struct db_passwd_file **db);
struct passdb_module module;
struct db_passwd_file *pwf;
+ const char *username_format;
};
static void passwd_file_save_results(struct auth_request *request,
const char *scheme, *crypted_pass;
int ret;
- pu = db_passwd_file_lookup(module->pwf, request);
+ pu = db_passwd_file_lookup(module->pwf, request,
+ module->username_format);
if (pu == NULL) {
callback(PASSDB_RESULT_USER_UNKNOWN, request);
return;
struct passwd_user *pu;
const char *crypted_pass, *scheme;
- pu = db_passwd_file_lookup(module->pwf, request);
+ pu = db_passwd_file_lookup(module->pwf, request,
+ module->username_format);
if (pu == NULL) {
callback(PASSDB_RESULT_USER_UNKNOWN, NULL, 0, request);
return;
i_fatal("passdb passwd-file: Missing args");
module = p_new(pool, struct passwd_file_passdb_module, 1);
- module->pwf = db_passwd_file_init(args, format, FALSE,
+ 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;
struct userdb_module module;
struct db_passwd_file *pwf;
+ const char *username_format;
};
static void passwd_file_lookup(struct auth_request *auth_request,
const char *key, *value;
char **p;
- pu = db_passwd_file_lookup(module->pwf, auth_request);
+ pu = db_passwd_file_lookup(module->pwf, auth_request,
+ module->username_format);
if (pu == NULL) {
callback(USERDB_RESULT_USER_UNKNOWN, auth_request);
return;
args += 16;
p = strchr(args, ' ');
if (p == NULL) {
- format = args;
+ format = p_strdup(pool, args);
args = "";
} else {
format = p_strdup_until(pool, args, p);
i_fatal("userdb passwd-file: Missing args");
module = p_new(pool, struct passwd_file_userdb_module, 1);
- module->pwf = db_passwd_file_init(args, format, TRUE,
+ 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;