From: Timo Sirainen Date: Tue, 27 May 2025 08:10:56 +0000 (+0300) Subject: lib-master: Always process import_environment for standalone programs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3c8dd532eff97b116b71d9f621f8d7a8719ac00f;p=thirdparty%2Fdovecot%2Fcore.git lib-master: Always process import_environment for standalone programs It wasn't processed if config was read via config socket or from config cache. --- diff --git a/src/lib-master/master-service-settings.c b/src/lib-master/master-service-settings.c index 7936b9dc5e..144a6804ef 100644 --- a/src/lib-master/master-service-settings.c +++ b/src/lib-master/master-service-settings.c @@ -4,6 +4,7 @@ #include "array.h" #include "event-filter.h" #include "path-util.h" +#include "hostpid.h" #include "fdpass.h" #include "write-full.h" #include "str.h" @@ -480,6 +481,7 @@ master_service_settings_read_int(struct master_service *service, { const char *path = NULL, *value, *error; bool cached_config = FALSE; + bool import_environment_missing = FALSE; int ret, fd = -1; i_zero(output_r); @@ -513,6 +515,13 @@ master_service_settings_read_int(struct master_service *service, "Failed to read configuration: %s", error); return -1; } + if (getenv(MASTER_IS_PARENT_ENV) == NULL) { + /* Standalone program read the config via socket or + config cache (not via executing doveconf). + import_environment setting still needs to be + processed. */ + import_environment_missing = TRUE; + } } else if (!settings_has_mmap(service->settings_root)) { /* Use default settings. Set dovecot_storage_version to the latest version, so it won't cause a failure. Use userdb @@ -597,6 +606,14 @@ master_service_settings_read_int(struct master_service *service, if (service->set->shutdown_clients) master_service_set_die_with_master(master_service, TRUE); + + if (import_environment_missing) { + const char *import_environment = + master_service_get_import_environment_keyvals(service); + master_service_import_environment(import_environment); + /* DOVECOT_HOST* environments may have changed */ + hostpid_init(); + } return 0; }