changeset 22491:5854337cc4ad

doveconf: Preserve import_environment when execing binary This allows import_environment setting to work with doveadm and other standalone tools.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 08 Jun 2017 01:03:13 +0300
parents 48772f0423cd
children ac432c123103
files src/config/config-request.c src/config/config-request.h src/config/doveconf.c
diffstat 3 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/config/config-request.c	Thu Jun 08 00:40:12 2017 +0300
+++ b/src/config/config-request.c	Thu Jun 08 01:03:13 2017 +0300
@@ -400,6 +400,24 @@
 	*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)
--- a/src/config/config-request.h	Thu Jun 08 00:40:12 2017 +0300
+++ b/src/config/config-request.h	Thu Jun 08 01:03:13 2017 +0300
@@ -48,6 +48,8 @@
 			   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
--- a/src/config/doveconf.c	Thu Jun 08 00:40:12 2017 +0300
+++ b/src/config/doveconf.c	Thu Jun 08 01:03:13 2017 +0300
@@ -877,6 +877,9 @@
 			   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();
 		}