From 8ac517e70d0865a4814860607c9d6cbd7f6c8b82 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 9 Aug 2014 14:23:05 +1000 Subject: [PATCH] set socket file mode to owner+group R+W --- src/ckdb.c | 2 ++ src/libckpool.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/ckdb.c b/src/ckdb.c index 7c346af7..4b8d31fa 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -1265,6 +1265,7 @@ void logmsg(int loglevel, const char *fmt, ...) fprintf(LOGFP, "%s %s", stamp, buf); if (loglevel <= LOG_ERR && errno != 0) fprintf(LOGFP, " with errno %d: %s", errno, strerror(errno)); + errno = 0; fprintf(LOGFP, "\n"); flock(logfd, LOCK_UN); } @@ -1272,6 +1273,7 @@ void logmsg(int loglevel, const char *fmt, ...) if (loglevel <= LOG_ERR && errno != 0) { fprintf(stderr, "%s %s with errno %d: %s%s\n", stamp, buf, errno, strerror(errno), extra); + errno = 0; } else fprintf(stderr, "%s %s%s\n", stamp, buf, extra); fflush(stderr); diff --git a/src/libckpool.c b/src/libckpool.c index adc46f21..ea02ca48 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -499,6 +499,7 @@ void close_unix_socket(const int sockd, const char *server_path) int _open_unix_server(const char *server_path, const char *file, const char *func, const int line) { + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; // Owner+Group R+W struct sockaddr_un serveraddr; int sockd = -1, len, ret; struct stat buf; @@ -546,6 +547,10 @@ int _open_unix_server(const char *server_path, const char *file, const char *fun goto out; } + ret = chmod(server_path, mode); + if (unlikely(ret < 0)) + LOGERR("Failed to set mode in open_unix_server - continuing"); + ret = listen(sockd, 10); if (unlikely(ret < 0)) { LOGERR("Failed to listen to socket in open_unix_server");