commit 8dff41f76998907442cd05582fa57422c285eca2
parent bdd7bf5f02140267e379298788674967c8acb345
Author: sin <sin@2f30.org>
Date: Mon, 6 Jun 2016 14:33:21 +0100
Restore process umask after creating the unix domain socket
Use 0111 to be more explicit.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ncmixer.c b/ncmixer.c
@@ -316,7 +316,7 @@ server_listen(char *name)
{
struct sockaddr_un sun;
socklen_t len;
- int fd;
+ int fd, oldumask;
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1)
@@ -326,9 +326,10 @@ server_listen(char *name)
sun.sun_family = AF_UNIX;
strlcpy(sun.sun_path, name, sizeof(sun.sun_path));
len = sizeof(sun);
- umask(0);
+ oldumask = umask(0111);
if (bind(fd, (SA *)&sun, len) == -1)
printerr(1, "bind");
+ umask(oldumask);
if (listen(fd, 5) == -1)
printerr(1, "listen");
return fd;