dovecot-2.0: Fixed passing settings from userdb to mail processes.
dovecot at dovecot.org
dovecot at dovecot.org
Fri May 1 02:18:54 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/f86e83fa9dd4
changeset: 9187:f86e83fa9dd4
user: Timo Sirainen <tss at iki.fi>
date: Thu Apr 30 19:18:48 2009 -0400
description:
Fixed passing settings from userdb to mail processes.
diffstat:
2 files changed, 36 insertions(+), 9 deletions(-)
src/lib-master/master-service-settings.c | 19 +++++++++++++------
src/master/service-process.c | 26 +++++++++++++++++++++++---
diffs (81 lines):
diff -r dcad675890c1 -r f86e83fa9dd4 src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c Thu Apr 30 18:49:26 2009 -0400
+++ b/src/lib-master/master-service-settings.c Thu Apr 30 19:18:48 2009 -0400
@@ -130,7 +130,7 @@ int master_service_settings_read(struct
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;
@@ -173,11 +173,18 @@ int master_service_settings_read(struct
*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) {
diff -r dcad675890c1 -r f86e83fa9dd4 src/master/service-process.c
--- a/src/master/service-process.c Thu Apr 30 18:49:26 2009 -0400
+++ b/src/master/service-process.c Thu Apr 30 19:18:48 2009 -0400
@@ -146,6 +146,11 @@ static void auth_args_apply(const char *
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);
@@ -165,11 +170,26 @@ static void auth_args_apply(const char *
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)
More information about the dovecot-cvs
mailing list