]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveconf: Preserve import_environment when execing binary
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 7 Jun 2017 22:03:13 +0000 (01:03 +0300)
committerGitLab <gitlab@git.dovecot.net>
Sat, 10 Jun 2017 08:35:40 +0000 (11:35 +0300)
This allows import_environment setting to work with doveadm and other
standalone tools.

src/config/config-request.c
src/config/config-request.h
src/config/doveconf.c

index 6569b3a557375792c771c589abf096e378844846..9b713b44214250b390487c00f15067088123fe36 100644 (file)
@@ -414,6 +414,24 @@ void config_export_get_output(struct config_export_context *ctx,
        *output_r = ctx->output;
 }
 
+const char *
+config_export_get_import_environment(struct config_export_context *ctx)
+{
+       enum setting_type stype;
+       unsigned int i;
+
+       for (i = 0; ctx->parsers[i].root != NULL; i++) {
+               if (ctx->parsers[i].root == &master_service_setting_parser_info) {
+                       const char *const *value =
+                               settings_parse_get_value(ctx->parsers[i].parser,
+                                       "import_environment", &stype);
+                       i_assert(value != NULL);
+                       return *value;
+               }
+       }
+       i_unreached();
+}
+
 static void config_export_free(struct config_export_context *ctx)
 {
        if (ctx->dup_parsers != NULL)
index 02b49cb3c94469d91e977fcba8827b83d77cc95c..39147af9fd0c452ea166f1fb21e7142aeb31ce6f 100644 (file)
@@ -48,6 +48,8 @@ void config_export_parsers(struct config_export_context *ctx,
                           const struct config_module_parser *parsers);
 void config_export_get_output(struct config_export_context *ctx,
                              struct master_service_settings_output *output_r);
+const char *
+config_export_get_import_environment(struct config_export_context *ctx);
 int config_export_finish(struct config_export_context **ctx);
 
 #endif
index d723ed6f9178833f6e84b13725fb357c343361ce..330849255f46fa3e5359ad7ebadb9703977082d4 100644 (file)
@@ -882,6 +882,9 @@ int main(int argc, char *argv[])
                           Do this only if the environment exists, because
                           lib-master doesn't set it if it doesn't want the
                           environment to be cleaned (e.g. -k parameter). */
+                       const char *import_environment =
+                               config_export_get_import_environment(ctx);
+                       master_service_import_environment(import_environment);
                        master_service_env_clean();
                }