s3-nmbd: Check if we created the directories correctly.
authorAndreas Schneider <asn@samba.org>
Thu, 13 Dec 2012 17:16:34 +0000 (18:16 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 21 Dec 2012 12:56:00 +0000 (13:56 +0100)
Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
source3/nmbd/nmbd.c

index d4df2020d5c1c5ec459432dca1bc8ca79c9b02e4..49f0cdf45784dd2f4dd6552476f4f9c2c4abfa21 100644 (file)
@@ -788,6 +788,7 @@ static bool open_sockets(bool isdaemon, int port)
        };
        TALLOC_CTX *frame;
        NTSTATUS status;
+       bool ok;
 
        /*
         * Do this before any other talloc operation
@@ -945,12 +946,18 @@ static bool open_sockets(bool isdaemon, int port)
        }
 #endif
 
-       if (!directory_exist(lp_lockdir())) {
-               mkdir(lp_lockdir(), 0755);
+       ok = directory_create_or_exist(lp_lockdir(), geteuid(), 0755);
+       if (!ok) {
+               DEBUG(0, ("Failed to create directory %s for lock files - %s\n",
+                         lp_lockdir(), strerror(errno)));
+               exit(1);
        }
 
-       if (!directory_exist(lp_piddir())) {
-               mkdir(lp_piddir(), 0755);
+       ok = directory_create_or_exist(lp_piddir(), geteuid(), 0755);
+       if (!ok) {
+               DEBUG(0, ("Failed to create directory %s for pid files - %s\n",
+                         lp_piddir(), strerror(errno)));
+               exit(1);
        }
 
        pidfile_create(lp_piddir(), "nmbd");