From bf005139d0591ae07f69abcbe5b7bbfd171e5e10 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 8 Jun 2017 01:03:13 +0300 Subject: [PATCH] doveconf: Preserve import_environment when execing binary This allows import_environment setting to work with doveadm and other standalone tools. --- src/config/config-request.c | 18 ++++++++++++++++++ src/config/config-request.h | 2 ++ src/config/doveconf.c | 3 +++ 3 files changed, 23 insertions(+) diff --git a/src/config/config-request.c b/src/config/config-request.c index f0d4f50e21..4f48deb7d5 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -400,6 +400,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 ab896af367..9d4925f291 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -877,6 +877,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(); } -- 2.47.3