]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add a hack to ensure RUNDIR exists.
authorRoy Marples <roy@marples.name>
Tue, 26 Apr 2016 20:07:29 +0000 (20:07 +0000)
committerRoy Marples <roy@marples.name>
Tue, 26 Apr 2016 20:07:29 +0000 (20:07 +0000)
compat/pidfile.c

index 5adb3972f7bbccf5d4aef6b492fbbd04a3d3119a..00b87fdcaf54a40c4be3fe4841a3c23aa2837ece 100644 (file)
@@ -50,9 +50,6 @@ __RCSID("$NetBSD: pidfile.c,v 1.14 2016/04/12 20:40:43 roy Exp $");
 #include "../config.h"
 #include "../defs.h"
 
-#undef _PATH_VARRUN
-#define _PATH_VARRUN   RUNDIR
-
 static pid_t pidfile_pid;
 static char pidfile_path[PATH_MAX];
 static int pidfile_fd = -1;
@@ -204,6 +201,10 @@ pidfile_lock(const char *path)
        if (pidfile_fd == -1) {
                int fd, opts;
 
+               /* Ensure we have the needed directories */
+               if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
+                       return -1;
+
                opts = O_WRONLY | O_CREAT | O_NONBLOCK;
 #ifdef O_CLOEXEC
                opts |= O_CLOEXEC;