Fix xx_path() - return check from mkdir() is incorrect.
authorJeremy Allison <jra@samba.org>
Mon, 17 Jun 2013 23:16:31 +0000 (16:16 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 18 Jun 2013 00:41:10 +0000 (02:41 +0200)
This is very old code, but mkdir() fails with -1, not 0.
Only print the error message is mkdir failed with anything
other than EEXIST.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
source3/lib/util.c

index d21c730f3ba408b3eedb341489befd3be58033bf..93aab3c2ad8a85b288ff87994f09608b543b3ee3 100644 (file)
@@ -1517,9 +1517,14 @@ static char *xx_path(const char *name, const char *rootpath)
        trim_string(fname,"","/");
 
        if (!directory_exist(fname)) {
-               if (!mkdir(fname,0755))
-                       DEBUG(1, ("Unable to create directory %s for file %s. "
-                             "Error was %s\n", fname, name, strerror(errno)));
+               if (mkdir(fname,0755) == -1) {
+                       /* Did someone else win the race ? */
+                       if (errno != EEXIST) {
+                               DEBUG(1, ("Unable to create directory %s for file %s. "
+                                       "Error was %s\n", fname, name, strerror(errno)));
+                               return NULL;
+                       }
+               }
        }
 
        return talloc_asprintf_append(fname, "/%s", name);