From fcc43cfbe34f3e8039c5e1364fc327f3d7b88b12 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 17 Jun 2013 16:16:31 -0700 Subject: Fix xx_path() - return check from mkdir() is incorrect. 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 Reviewed-by: Ira Cooper --- source3/lib/util.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index d21c730f3b..93aab3c2ad 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -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); -- cgit