]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master,master: Use separate environment variable for config file socket
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 12 Sep 2023 11:59:30 +0000 (14:59 +0300)
committermarkus.valentin <markus.valentin@open-xchange.com>
Thu, 21 Sep 2023 13:58:41 +0000 (13:58 +0000)
This allows retaining the CONFIG_FILE environment variable pointing
to file always.

src/lib-master/master-interface.h
src/lib-master/master-service.c
src/master/service-process.c

index f783a7ce3d6d36b6204d730cf4e27ac43d5900ca..369e0930c97c154adf1919996b5dd1c5c6384800 100644 (file)
@@ -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"
index cecb753780e7796d5b3672250abd211fe1b2a005..079fc7a5e2eef1452b564b0f24c78c9d35047e75 100644 (file)
@@ -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));
index 03cfb4823e12c936aae743d397b0a7da67de3f3b..0d708ba8d6c61b5c5fafffafc2e57c0db60a95a1 100644 (file)
@@ -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;
        }