From: Timo Sirainen Date: Wed, 7 Jun 2017 22:03:13 +0000 (+0300) Subject: doveconf: Preserve import_environment when execing binary X-Git-Tag: 2.3.0.rc1~1453 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ecee121e141083faf1db165f0ee3bc0cd232d7e;p=thirdparty%2Fdovecot%2Fcore.git doveconf: Preserve import_environment when execing binary This allows import_environment setting to work with doveadm and other standalone tools. --- diff --git a/src/config/config-request.c b/src/config/config-request.c index 6569b3a557..9b713b4421 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -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) diff --git a/src/config/config-request.h b/src/config/config-request.h index 02b49cb3c9..39147af9fd 100644 --- a/src/config/config-request.h +++ b/src/config/config-request.h @@ -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 diff --git a/src/config/doveconf.c b/src/config/doveconf.c index d723ed6f91..330849255f 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -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(); }