const struct setting_parser_info *tmp_root;
struct setting_parser_context *parser;
struct istream *input;
- const char *error;
+ const char *error, *env, *const *keys;
void **sets;
unsigned int i;
int ret, fd = -1;
*error_r = settings_parser_get_error(parser);
return -1;
}
- } else {
- if (settings_parse_environ(parser) < 0) {
- *error_r = settings_parser_get_error(parser);
- return -1;
- }
+ }
+ /* let environment override settings. especially useful for the
+ settings from userdb. */
+ if (settings_parse_environ(parser) < 0) {
+ *error_r = settings_parser_get_error(parser);
+ return -1;
+ }
+ env = getenv("VARS_EXPANDED");
+ if (env != NULL) {
+ keys = t_strsplit(env, " ");
+ settings_parse_set_keys_expandeded(parser, service->set_pool,
+ keys);
}
if (settings_parser_check(parser, service->set_pool, &error) < 0) {
struct restrict_access_settings *rset,
const char **home)
{
+ const char *key, *value;
+ string_t *expanded_vars;
+
+ expanded_vars = t_str_new(128);
+ str_append(expanded_vars, "VARS_EXPANDED=");
for (; *args != NULL; args++) {
if (strncmp(*args, "uid=", 4) == 0)
rset->uid = (uid_t)strtoul(*args + 4, NULL, 10);
rset->extra_groups, NULL);
} else {
/* unknown, set as environment */
- //FIXME
- env_put(t_strconcat("set_", *args, NULL));
+ value = strchr(*args, '=');
+ if (value == NULL) {
+ /* boolean */
+ key = *args;
+ value = "=1";
+ } else {
+ key = t_strdup_until(*args, value);
+ if (strcmp(key, "mail") == 0) {
+ /* FIXME: kind of ugly to have it
+ here.. */
+ key = "mail_location";
+ }
+ }
+ str_append(expanded_vars, key);
+ str_append_c(expanded_vars, ' ');
+ env_put(t_strconcat(t_str_ucase(key), value, NULL));
}
}
-}
+ env_put(str_c(expanded_vars));
+}
static void drop_privileges(struct service *service,
const char *const *auth_args)