From: Timo Sirainen Date: Mon, 17 Apr 2023 23:32:02 +0000 (+0300) Subject: lib-master: Settings reading - Fix failure handling when executed via doveconf X-Git-Tag: 2.4.0~2148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fbf9ac9bc7697e21203a0561367b0cebc72b476;p=thirdparty%2Fdovecot%2Fcore.git lib-master: Settings reading - Fix failure handling when executed via doveconf 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. --- diff --git a/src/lib-master/master-service-settings.c b/src/lib-master/master-service-settings.c index d01ecbae5a..f48e54867a 100644 --- a/src/lib-master/master-service-settings.c +++ b/src/lib-master/master-service-settings.c @@ -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);