From ed6b37eeec4c20354a871ad5f4dc0a97f769d37e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 8 Jun 2017 00:35:08 +0300 Subject: [PATCH] lib-master: Use master_service_import_environment() for preserving environments --- src/lib-master/master-service-settings.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/lib-master/master-service-settings.c b/src/lib-master/master-service-settings.c index 0902d4acba..5161645016 100644 --- a/src/lib-master/master-service-settings.c +++ b/src/lib-master/master-service-settings.c @@ -123,7 +123,7 @@ master_service_exec_config(struct master_service *service, const struct master_service_settings_input *input) { const char **conf_argv, *binary_path = service->argv[0]; - const char *home = NULL, *user = NULL, *timestamp = NULL, *error = NULL; + const char *error = NULL; unsigned int i, argv_max_count; if (!t_binary_abspath(&binary_path, &error)) { @@ -132,18 +132,12 @@ master_service_exec_config(struct master_service *service, if (!service->keep_environment && !input->preserve_environment) { if (input->preserve_home) - home = getenv("HOME"); + master_service_import_environment("HOME"); if (input->preserve_user) - user = getenv("USER"); + master_service_import_environment("USER"); if ((service->flags & MASTER_SERVICE_FLAG_STANDALONE) != 0) - timestamp = getenv("LOG_STDERR_TIMESTAMP"); + master_service_import_environment("LOG_STDERR_TIMESTAMP"); master_service_env_clean(); - if (home != NULL) - env_put(t_strconcat("HOME=", home, NULL)); - if (user != NULL) - env_put(t_strconcat("USER=", user, NULL)); - if (timestamp != NULL) - env_put(t_strconcat("LOG_STDERR_TIMESTAMP=", timestamp, NULL)); } if (input->use_sysexits) env_put("USE_SYSEXITS=1"); -- 2.47.3