summaryrefslogtreecommitdiff
path: root/src/anet.c
diff options
context:
space:
mode:
authorNathan Florea <florean@gmail.com>2011-10-10 11:21:15 -0700
committerNathan Florea <florean@gmail.com>2011-10-10 11:21:15 -0700
commit85238765033e2fa89b1879383421d5a8aafff17f (patch)
tree43de8a48642ae099cb84e9c4f021c9d9d7618b7a /src/anet.c
parent56209f720ae602cf5de70a35573625cff9ef0e2c (diff)
downloadredis-85238765033e2fa89b1879383421d5a8aafff17f.tar.gz
Added a config directive for a Unix socket mask
Added a configuration directive to allow a user to specify the permissions to be granted to the Unix socket file. I followed the format Pieter and Salvatore discusses in issue #85 ( https://github.com/antirez/redis/issues/85).
Diffstat (limited to 'src/anet.c')
-rw-r--r--src/anet.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/anet.c b/src/anet.c
index 692cef194..9aff4dfa1 100644
--- a/src/anet.c
+++ b/src/anet.c
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -291,7 +292,7 @@ int anetTcpServer(char *err, int port, char *bindaddr)
return s;
}
-int anetUnixServer(char *err, char *path)
+int anetUnixServer(char *err, char *path, mode_t perm)
{
int s;
struct sockaddr_un sa;
@@ -304,6 +305,8 @@ int anetUnixServer(char *err, char *path)
strncpy(sa.sun_path,path,sizeof(sa.sun_path)-1);
if (anetListen(err,s,(struct sockaddr*)&sa,sizeof(sa)) == ANET_ERR)
return ANET_ERR;
+ if (perm)
+ chmod(sa.sun_path, perm);
return s;
}