diff options
author | Nathan Florea <florean@gmail.com> | 2011-10-10 11:21:15 -0700 |
---|---|---|
committer | Nathan Florea <florean@gmail.com> | 2011-10-10 11:21:15 -0700 |
commit | 85238765033e2fa89b1879383421d5a8aafff17f (patch) | |
tree | 43de8a48642ae099cb84e9c4f021c9d9d7618b7a /src/anet.c | |
parent | 56209f720ae602cf5de70a35573625cff9ef0e2c (diff) | |
download | redis-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.c | 5 |
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; } |