From: Timo Sirainen Date: Sat, 6 Mar 2010 10:26:10 +0000 (+0200) Subject: lib-master: If config lookup from socket fails, fallback to execing doveconf. X-Git-Tag: 2.0.beta4~127 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4a7863c531a27498830004ca2ead2eb53812ed79;p=thirdparty%2Fdovecot%2Fcore.git lib-master: If config lookup from socket fails, fallback to execing doveconf. --HG-- branch : HEAD --- diff --git a/src/lib-master/master-service-settings.c b/src/lib-master/master-service-settings.c index 1357d08c5a..e8eab8d213 100644 --- a/src/lib-master/master-service-settings.c +++ b/src/lib-master/master-service-settings.c @@ -102,6 +102,22 @@ master_service_exec_config(struct master_service *service, bool preserve_home) i_fatal("execv(%s) failed: %m", conf_argv[0]); } +static void +config_exec_fallback(struct master_service *service, + const struct master_service_settings_input *input) +{ + const char *path; + struct stat st; + + path = input->config_path != NULL ? input->config_path : + master_service_get_config_path(service); + if (stat(path, &st) == 0 && + !S_ISSOCK(st.st_mode) && !S_ISFIFO(st.st_mode)) { + /* it's a file, not a socket/pipe */ + master_service_exec_config(service, input->preserve_home); + } +} + static int master_service_open_config(struct master_service *service, const struct master_service_settings_input *input, @@ -109,7 +125,6 @@ master_service_open_config(struct master_service *service, bool *standalone_config_from_socket_r) { const char *path; - struct stat st; int fd; *path_r = path = input->config_path != NULL ? input->config_path : @@ -142,13 +157,7 @@ master_service_open_config(struct master_service *service, if (fd < 0) { *error_r = t_strdup_printf("net_connect_unix(%s) failed: %m", path); - - if (stat(path, &st) == 0 && - !S_ISSOCK(st.st_mode) && !S_ISFIFO(st.st_mode)) { - /* it's a file, not a socket/pipe */ - master_service_exec_config(service, - input->preserve_home); - } + config_exec_fallback(service, input); return -1; } net_set_nonblock(fd, FALSE); @@ -286,6 +295,7 @@ int master_service_settings_read(struct master_service *service, if (config_send_request(input, fd, path, error_r) < 0) { (void)close(fd); + config_exec_fallback(service, input); return -1; } config_socket = TRUE; @@ -350,6 +360,7 @@ int master_service_settings_read(struct master_service *service, "Timeout reading config from %s", path); } (void)close(fd); + config_exec_fallback(service, input); return -1; } }