From: Aki Tuomi Date: Tue, 12 Sep 2023 11:59:30 +0000 (+0300) Subject: lib-master,master: Use separate environment variable for config file socket X-Git-Tag: 2.4.0~2592 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59a924b010a450a3ccce122ef7a08d30a24a9321;p=thirdparty%2Fdovecot%2Fcore.git lib-master,master: Use separate environment variable for config file socket This allows retaining the CONFIG_FILE environment variable pointing to file always. --- diff --git a/src/lib-master/master-interface.h b/src/lib-master/master-interface.h index f783a7ce3d..369e0930c9 100644 --- a/src/lib-master/master-interface.h +++ b/src/lib-master/master-interface.h @@ -63,9 +63,13 @@ enum master_login_state { in seconds. */ #define MASTER_SERVICE_IDLE_KILL_ENV "IDLE_KILL" -/* getenv(MASTER_CONFIG_FILE_ENV) provides path to configuration file/socket */ +/* getenv(MASTER_CONFIG_FILE_ENV) provides path to configuration file. */ #define MASTER_CONFIG_FILE_ENV "CONFIG_FILE" +/* getenv(MASTER_CONFIG_FILE_SOCKET_ENV) provides path to Configuration + socket, if available. */ +#define MASTER_CONFIG_FILE_SOCKET_ENV "CONFIG_FILE_SOCKET" + /* getenv(MASTER_VERBOSE_PROCTITLE_ENV) is non-NULL if verbose_proctitle=yes. This is used by lib-master during initialization. */ #define MASTER_VERBOSE_PROCTITLE_ENV "VERBOSE_PROCTITLE" diff --git a/src/lib-master/master-service.c b/src/lib-master/master-service.c index cecb753780..079fc7a5e2 100644 --- a/src/lib-master/master-service.c +++ b/src/lib-master/master-service.c @@ -525,7 +525,9 @@ master_service_init(const char *name, enum master_service_flags flags, service->service_count_left = UINT_MAX; service->datastack_frame_id = datastack_frame_id; - service->config_path = i_strdup(getenv(MASTER_CONFIG_FILE_ENV)); + service->config_path = i_strdup(getenv(MASTER_CONFIG_FILE_SOCKET_ENV)); + if (service->config_path == NULL) + service->config_path = i_strdup(getenv(MASTER_CONFIG_FILE_ENV)); if (service->config_path == NULL) service->config_path = i_strdup(DEFAULT_CONFIG_FILE_PATH); else @@ -632,7 +634,7 @@ master_service_init(const char *name, enum master_service_flags flags, env_remove(MASTER_SERVICE_ENV); env_remove(MASTER_SERVICE_SOCKET_COUNT_ENV); env_remove(MASTER_UID_ENV); - env_remove(MASTER_CONFIG_FILE_ENV); + env_remove(MASTER_CONFIG_FILE_SOCKET_ENV); T_BEGIN { for (unsigned int i = 0; i < service->socket_count; i++) env_remove(t_strdup_printf("SOCKET%u_SETTINGS", i)); diff --git a/src/master/service-process.c b/src/master/service-process.c index 03cfb4823e..0d708ba8d6 100644 --- a/src/master/service-process.c +++ b/src/master/service-process.c @@ -286,7 +286,8 @@ static void service_process_setup_config_environment(struct service *service) env_put(MASTER_CONFIG_FILE_ENV, service->config_file_path); break; default: - env_put(MASTER_CONFIG_FILE_ENV, + env_put(MASTER_CONFIG_FILE_ENV, services->config->config_file_path); + env_put(MASTER_CONFIG_FILE_SOCKET_ENV, services_get_config_socket_path(service->list)); break; }