From ab880b8e78e530b897b195450e8fb7e8f2d2c110 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 17 Jun 2013 17:02:56 -0700 Subject: [PATCH] Re-add umask(0) code removed by commit 3a7c2777ee0de37d758fe81d67d6836a8354825e Without the umask code the pipe permissions are affected by the umask of the calling process. As only smbd currently sets its umask to zero (nmbd and winbindd should do the same) this causes the winbindd pipe to be unavailable to the nss library code unless winbindd is run from an init process that explicitly sets umask to zero. When testing from the command line this can be hard to track down :-). Signed-off-by: Jeremy Allison --- source3/lib/util_sock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index eb38055..54286b3 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1237,14 +1237,17 @@ int create_pipe_sock(const char *socket_dir, #ifdef HAVE_UNIXSOCKET struct sockaddr_un sunaddr; bool ok; - int sock; + int sock = -1; + mode_t old_umask; char *path = NULL; + old_umask = umask(0); + ok = directory_create_or_exist_strict(socket_dir, sec_initial_uid(), dir_perms); if (!ok) { - return -1; + goto out_close; } /* Create the socket file */ @@ -1273,6 +1276,7 @@ int create_pipe_sock(const char *socket_dir, SAFE_FREE(path); + umask(old_umask); return sock; out_close: @@ -1280,6 +1284,7 @@ out_close: if (sock != -1) close(sock); + umask(old_umask); return -1; #else -- 1.8.1.2