]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
priv: fix chroot creation
authorVincent Bernat <vincent@bernat.ch>
Mon, 13 Sep 2021 06:19:49 +0000 (08:19 +0200)
committerVincent Bernat <vincent@bernat.ch>
Mon, 13 Sep 2021 06:19:49 +0000 (08:19 +0200)
src/daemon/priv.c

index 026e32c39aa7c921effec8580b9043a9c2914470..e13604a9b4159c6fa2075d24cb0e100371eee972 100644 (file)
@@ -522,10 +522,10 @@ sig_chld(int sig)
 static int _mkdir(const char *pathname, mode_t mode)
 {
        int save_errno;
-       if (mkdir(pathname, mode) == 0)
+       if (mkdir(pathname, mode) == 0 || errno == EEXIST) {
+               errno = 0;
                return 0;
-       if (errno == EEXIST)
-               return -1;
+       }
 
        /* We can get EROFS on some platforms. Let's check if the directory exists. */
        save_errno = errno;