]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
If the directory already exists then we need to provide a handle to it
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 22 Oct 2022 20:12:47 +0000 (16:12 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 22 Oct 2022 20:12:47 +0000 (16:12 -0400)
src/lib/util/file.c

index a53f5241d4944ba3ac11a02f9edae52b200f949a..e01203c828c6bccaf954b1bb5d1a065e3242ff52 100644 (file)
@@ -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