dovecot-2.0: lib-master: If config path isn't a socket, don't tr...

dovecot at dovecot.org dovecot at dovecot.org
Fri May 14 18:41:39 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/7bb35ad5e80e
changeset: 11315:7bb35ad5e80e
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 14 17:41:34 2010 +0200
description:
lib-master: If config path isn't a socket, don't try to connect() to it.
This avoids some SELinux errors.

diffstat:

 src/lib-master/master-service-settings.c |  10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (27 lines):

diff -r 664d1b2f6b46 -r 7bb35ad5e80e src/lib-master/master-service-settings.c
--- a/src/lib-master/master-service-settings.c	Fri May 14 16:20:58 2010 +0200
+++ b/src/lib-master/master-service-settings.c	Fri May 14 17:41:34 2010 +0200
@@ -113,6 +113,7 @@
 			   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 @@
 		/* 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);


More information about the dovecot-cvs mailing list