From 796aef8d174304cada696be47670322e7702f2be Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Thu, 9 Jan 2014 09:19:59 +0000 Subject: [PATCH] Always create /var/run/casper with correct permissions and don't depend on the calling process' umask. Submitted by: Mikhail --- sbin/casperd/casperd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbin/casperd/casperd.c b/sbin/casperd/casperd.c index d0e63762769e..f283709e2f17 100644 --- a/sbin/casperd/casperd.c +++ b/sbin/casperd/casperd.c @@ -541,6 +541,7 @@ main_loop(const char *sockpath, struct pidfh *pfh) struct casper_service *casserv; struct service_connection *sconn, *sconntmp; int lsock, sock, maxfd, ret; + mode_t oldumask; lsock = socket(AF_UNIX, SOCK_STREAM, 0); if (lsock == -1) @@ -554,8 +555,10 @@ main_loop(const char *sockpath, struct pidfh *pfh) sizeof(sun.sun_path)); sun.sun_len = SUN_LEN(&sun); + oldumask = umask(S_IXUSR | S_IXGRP | S_IXOTH); if (bind(lsock, (struct sockaddr *)&sun, sizeof(sun)) == -1) pjdlog_exit(1, "Unable to bind to %s", sockpath); + (void)umask(oldumask); if (listen(lsock, 8) == -1) pjdlog_exit(1, "Unable to listen on %s", sockpath);