]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: If config path isn't a socket, don't try to connect() to it.
authorTimo Sirainen <tss@iki.fi>
Fri, 14 May 2010 15:41:34 +0000 (17:41 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 14 May 2010 15:41:34 +0000 (17:41 +0200)
This avoids some SELinux errors.

--HG--
branch : HEAD

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

index 842d7320186cff4ff294827bff95abd3f9d5b74e..6736a1814cb089ff1666c8c3b7d892c2c46f249d 100644 (file)
@@ -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);