From: Roy Marples Date: Tue, 26 Apr 2016 20:09:34 +0000 (+0000) Subject: Revert prior and just move the RUNDIR check above pidfile_lock. X-Git-Tag: v6.11.0~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4b2fdf14a88ebf31da15c50156a6a7cd62dde5c;p=thirdparty%2Fdhcpcd.git Revert prior and just move the RUNDIR check above pidfile_lock. --- diff --git a/compat/pidfile.c b/compat/pidfile.c index 00b87fdc..46f34c66 100644 --- a/compat/pidfile.c +++ b/compat/pidfile.c @@ -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; diff --git a/dhcpcd.c b/dhcpcd.c index 8e6b0367..c19c6ef8 100644 --- 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) {