From 9443494239616a5a9f1e7d5711324c435d04e035 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 3 Apr 2015 03:58:53 +0200
Subject: server: When creating new directories temporarily give
 read-permissions until they are opened.

---
 server/fd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/server/fd.c b/server/fd.c
index 3afb89a..9a4aac4 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1774,7 +1774,12 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
     /* create the directory if needed */
     if ((options & FILE_DIRECTORY_FILE) && (flags & O_CREAT))
     {
-        if (mkdir( name, *mode ) == -1)
+        if (mkdir( name, *mode | S_IRUSR ) != -1)
+        {
+            /* remove S_IRUSR later, after we have opened the directory */
+            do_chmod = !(*mode & S_IRUSR);
+        }
+        else
         {
             if (errno != EEXIST || (flags & O_EXCL))
             {
-- 
2.3.3

