ctx->ctx.context = context;
ctx->skip_passdb_entries = !module->pwf->userdb_warn_missing;
if (module->pwf->default_file == NULL) {
- e_error(authdb_event(auth_request),
- "passwd-file: User iteration isn't currently supported "
- "with %%variable paths");
- ctx->ctx.failed = TRUE;
- return &ctx->ctx;
+ const struct var_expand_params params = {
+ .table = auth_request_get_var_expand_table(auth_request),
+ .providers = auth_request_var_expand_providers,
+ .context = auth_request,
+ .event = authdb_event(auth_request),
+ };
+ const char *error;
+ string_t *dest = t_str_new(32);
+ if (var_expand_program_execute(dest, module->pwf->prog, ¶ms,
+ &error) < 0) {
+ e_error(authdb_event(auth_request),
+ "passwd-file: User iteration failed: "
+ "Cannot expand '%s': %s", module->pwf->path, error);
+ ctx->ctx.failed = TRUE;
+ return &ctx->ctx;
+ }
+ const char *path;
+ if (db_passwd_fix_path(str_c(dest), &path, module->pwf->path, &error) < 0) {
+ e_error(authdb_event(auth_request),
+ "passwd-file: User iteration failed: "
+ "Cannot normalize '%s': %s", str_c(dest), error);
+ ctx->ctx.failed = TRUE;
+ return &ctx->ctx;
+ }
+ ctx->path = i_strdup(path);
+ } else {
+ ctx->path = i_strdup(module->pwf->default_file->path);
}
- ctx->path = i_strdup(module->pwf->default_file->path);
/* for now we support only a single passwd-file */
fd = open(ctx->path, O_RDONLY);