Browse Source

set socket file mode to owner+group R+W

master
kanoi 10 years ago
parent
commit
8ac517e70d
  1. 2
      src/ckdb.c
  2. 5
      src/libckpool.c

2
src/ckdb.c

@ -1265,6 +1265,7 @@ void logmsg(int loglevel, const char *fmt, ...)
fprintf(LOGFP, "%s %s", stamp, buf); fprintf(LOGFP, "%s %s", stamp, buf);
if (loglevel <= LOG_ERR && errno != 0) if (loglevel <= LOG_ERR && errno != 0)
fprintf(LOGFP, " with errno %d: %s", errno, strerror(errno)); fprintf(LOGFP, " with errno %d: %s", errno, strerror(errno));
errno = 0;
fprintf(LOGFP, "\n"); fprintf(LOGFP, "\n");
flock(logfd, LOCK_UN); flock(logfd, LOCK_UN);
} }
@ -1272,6 +1273,7 @@ void logmsg(int loglevel, const char *fmt, ...)
if (loglevel <= LOG_ERR && errno != 0) { if (loglevel <= LOG_ERR && errno != 0) {
fprintf(stderr, "%s %s with errno %d: %s%s\n", fprintf(stderr, "%s %s with errno %d: %s%s\n",
stamp, buf, errno, strerror(errno), extra); stamp, buf, errno, strerror(errno), extra);
errno = 0;
} else } else
fprintf(stderr, "%s %s%s\n", stamp, buf, extra); fprintf(stderr, "%s %s%s\n", stamp, buf, extra);
fflush(stderr); fflush(stderr);

5
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) 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; struct sockaddr_un serveraddr;
int sockd = -1, len, ret; int sockd = -1, len, ret;
struct stat buf; struct stat buf;
@ -546,6 +547,10 @@ int _open_unix_server(const char *server_path, const char *file, const char *fun
goto out; 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); ret = listen(sockd, 10);
if (unlikely(ret < 0)) { if (unlikely(ret < 0)) {
LOGERR("Failed to listen to socket in open_unix_server"); LOGERR("Failed to listen to socket in open_unix_server");

Loading…
Cancel
Save