]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Revert prior and just move the RUNDIR check above pidfile_lock.
authorRoy Marples <roy@marples.name>
Tue, 26 Apr 2016 20:09:34 +0000 (20:09 +0000)
committerRoy Marples <roy@marples.name>
Tue, 26 Apr 2016 20:09:34 +0000 (20:09 +0000)
compat/pidfile.c
dhcpcd.c

index 00b87fdcaf54a40c4be3fe4841a3c23aa2837ece..46f34c664ee1b9c4e107e780895a2531aacf0fb0 100644 (file)
@@ -201,10 +201,6 @@ 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;
index 8e6b0367e053c1e75c901ff4bd6f2e7b162170cc..c19c6ef8a501bc532de4885383fe950470ff80ce 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1790,6 +1790,12 @@ printpidfile:
        }
 
        if (!(ctx.options & DHCPCD_TEST)) {
+               /* Ensure we have the needed directories */
+               if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
+                       logger(&ctx, LOG_ERR, "mkdir `%s': %m", RUNDIR);
+               if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST)
+                       logger(&ctx, LOG_ERR, "mkdir `%s': %m", DBDIR);
+
                if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
                        if (pid == -1)
                                logger(&ctx, LOG_ERR, "%s: pidfile_lock: %m",
@@ -1800,12 +1806,6 @@ printpidfile:
                                    pid, ctx.pidfile);
                        goto exit_failure;
                }
-
-               /* Ensure we have the needed directories */
-               if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
-                       logger(&ctx, LOG_ERR, "mkdir `%s': %m", RUNDIR);
-               if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST)
-                       logger(&ctx, LOG_ERR, "mkdir `%s': %m", DBDIR);
        }
 
        if (ctx.options & DHCPCD_MASTER) {