]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Settings reading - Fix failure handling when executed via doveconf
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 17 Apr 2023 23:32:02 +0000 (02:32 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:21:55 +0000 (14:21 +0200)
The DOVECOT_CONFIG_FD_ENV environment check didn't work, because it was
already unset.

Also this simplifies the code a bit. There's no need to re-parse the config
if it wasn't just mmaped, since nothing would have changed.

src/lib-master/master-service-settings.c

index d01ecbae5a82f84df9fd3ab85d3b9aee1f603f12..f48e54867a614d6591e87d08a80a47b76c76cbb7 100644 (file)
@@ -899,31 +899,26 @@ int master_service_settings_read(struct master_service *service,
                        output_r->config_fd = fd;
                else
                        i_close_fd(&fd);
-               env_remove(DOVECOT_CONFIG_FD_ENV);
-       }
-
-       /* Create event for matching config filters */
-       struct event *event = event_create(NULL);
-       event_add_str(event, "protocol", input->protocol != NULL ?
-                     input->protocol : service->name);
 
-       /* config_mmap is NULL only if MASTER_SERVICE_FLAG_NO_CONFIG_SETTINGS
-          is used */
-       if (service->settings_root->mmap != NULL) {
                ret = settings_mmap_parse(service->settings_root->mmap,
                                          output_r, &error);
                if (ret < 0) {
                        if (getenv(DOVECOT_CONFIG_FD_ENV) != NULL) {
                                i_fatal("Failed to parse config from fd %d: %s",
-                                       fd, *error_r);
+                                       fd, error);
                        }
                        *error_r = t_strdup_printf(
                                "Failed to parse configuration: %s", error);
-                       event_unref(&event);
                        return -1;
                }
+               env_remove(DOVECOT_CONFIG_FD_ENV);
        }
 
+       /* Create event for matching config filters */
+       struct event *event = event_create(NULL);
+       event_add_str(event, "protocol", input->protocol != NULL ?
+                     input->protocol : service->name);
+
        settings_free(service->set);
        ret = settings_get(event, &master_service_setting_parser_info, 0,
                           &service->set, error_r);