lib: Use directory_create_or_exist in xx_path
authorVolker Lendecke <vl@samba.org>
Sun, 13 Dec 2015 14:27:15 +0000 (15:27 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 14 Dec 2015 19:23:13 +0000 (20:23 +0100)
directory_create_or_exist is a little different: It does the lstat first and
sets the umask properly, but I think this is more correct than the xx_path()
version before.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/util.c

index 1d043189a4fdf247d355b9669c3caef2b8a95522..320fdc2e0e49b2916564fae315edaea760b41ea0 100644 (file)
@@ -1515,15 +1515,8 @@ static char *xx_path(const char *name, const char *rootpath)
        }
        trim_string(fname,"","/");
 
-       if (!directory_exist(fname)) {
-               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;
-                       }
-               }
+       if (!directory_create_or_exist(fname, 0755)) {
+               return NULL;
        }
 
        return talloc_asprintf_append(fname, "/%s", name);