From: Timo Sirainen Date: Fri, 14 May 2010 15:41:34 +0000 (+0200) Subject: lib-master: If config path isn't a socket, don't try to connect() to it. X-Git-Tag: 2.0.beta6~215 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5ea5c79ca3f6012095bd5e9b2251e6dd5f614a8d;p=thirdparty%2Fdovecot%2Fcore.git lib-master: If config path isn't a socket, don't try to connect() to it. This avoids some SELinux errors. --HG-- branch : HEAD --- diff --git a/src/lib-master/master-service-settings.c b/src/lib-master/master-service-settings.c index 842d732018..6736a1814c 100644 --- a/src/lib-master/master-service-settings.c +++ b/src/lib-master/master-service-settings.c @@ -113,6 +113,7 @@ master_service_open_config(struct master_service *service, const struct master_service_settings_input *input, const char **path_r, const char **error_r) { + struct stat st; const char *path; int fd; @@ -140,7 +141,14 @@ master_service_open_config(struct master_service *service, /* fallback to executing doveconf */ } - fd = net_connect_unix_with_retries(path, 1000); + if (stat(path, &st) == 0 && + !S_ISSOCK(st.st_mode) && !S_ISFIFO(st.st_mode)) { + /* it's not an UNIX socket, don't even try to connect */ + fd = -1; + errno = ENOTSOCK; + } else { + fd = net_connect_unix_with_retries(path, 1000); + } if (fd < 0) { *error_r = t_strdup_printf("net_connect_unix(%s) failed: %m", path);