]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Fixed passing settings from userdb to mail processes.
authorTimo Sirainen <tss@iki.fi>
Thu, 30 Apr 2009 23:18:48 +0000 (19:18 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 30 Apr 2009 23:18:48 +0000 (19:18 -0400)
--HG--
branch : HEAD

src/lib-master/master-service-settings.c
src/master/service-process.c

index 4051a35f44645e7acbd7aca7e469dff0934a5866..3eb8978b7206cd9ec688c318929990c190877fe5 100644 (file)
@@ -130,7 +130,7 @@ int master_service_settings_read(struct master_service *service,
        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 master_service *service,
                        *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) {
index 4804c36b80c253a52230038941c11eeacaf935a8..1286b9fe90a215b6c5ec87cf8f4fb37c12c97223 100644 (file)
@@ -146,6 +146,11 @@ static void auth_args_apply(const char *const *args,
                            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 *const *args,
                                            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)