From: Arran Cudbard-Bell Date: Sat, 22 Oct 2022 20:12:47 +0000 (-0400) Subject: If the directory already exists then we need to provide a handle to it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd6ae770d0fd3cce54b8e8bec4c06b2278ebe399;p=thirdparty%2Ffreeradius-server.git If the directory already exists then we need to provide a handle to it --- diff --git a/src/lib/util/file.c b/src/lib/util/file.c index a53f5241d49..e01203c828c 100644 --- a/src/lib/util/file.c +++ b/src/lib/util/file.c @@ -82,7 +82,15 @@ static ssize_t _fr_mkdir(int *fd_out, char *start, char *path, mode_t mode, fr_m * process created this directory in between our check * and our creation. */ - if (errno == EEXIST) return strlen(start); + if (errno == EEXIST) { + fd = open(path, O_DIRECTORY); + if (fd < 0) { + fr_strerror_printf("Failed opening existing directory: %s", fr_syserror(errno)); + goto mkdir_error; + } + *fd_out = fd; + return strlen(start); + } /* * ENOENT means we're trying to create too much path