]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
dhcpcd: Don't create launcher process if keeping in foreground
authorRoy Marples <roy@marples.name>
Wed, 11 Nov 2020 17:44:55 +0000 (17:44 +0000)
committerRoy Marples <roy@marples.name>
Wed, 11 Nov 2020 17:44:55 +0000 (17:44 +0000)
There is little point.

src/dhcpcd.c
src/privsep.c

index 7377fcc667e22b63c40018cf0bf8d1c8dc859d32..5892a28b4eb7bc98b4059a33d45dac412f3426fb 100644 (file)
@@ -2244,6 +2244,9 @@ printpidfile:
        if (ctx.stdin_valid && freopen(_PATH_DEVNULL, "w", stdin) == NULL)
                logwarn("freopen stdin");
 
+       if (!(ctx.options & DHCPCD_DAEMONISE))
+               goto start_master;
+
 #if defined(USE_SIGNALS) && !defined(THERE_IS_NO_FORK)
        if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fork_fd) == -1 ||
            (ctx.stderr_valid &&
@@ -2335,8 +2338,9 @@ printpidfile:
 
        /* We have now forked, setsid, forked once more.
         * From this point on, we are the controlling daemon. */
-       ctx.options |= DHCPCD_STARTED;
        logdebugx("spawned master process on PID %d", getpid());
+start_master:
+       ctx.options |= DHCPCD_STARTED;
        if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
                logerr("%s: pidfile_lock %d", __func__, pid);
 #ifdef PRIVSEP
index f43e7ef20260f952ef64f0481910181911dba06b..55bb3c4295ceacfa602afbfb5db731de11f23807 100644 (file)
@@ -163,12 +163,13 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
 #endif
        }
 
+#define DHC_NOCHKIO    (DHCPCD_STARTED | DHCPCD_DAEMONISE)
        /* Prohibit writing to files.
         * Obviously this won't work if we are using a logfile
         * or redirecting stderr to a file. */
-       if (ctx->logfile == NULL &&
-           (ctx->options & DHCPCD_STARTED ||
-            !ctx->stderr_valid || isatty(STDERR_FILENO) == 1))
+       if ((ctx->options & DHC_NOCHKIO) == DHC_NOCHKIO ||
+           (ctx->logfile == NULL &&
+           (!ctx->stderr_valid || isatty(STDERR_FILENO) == 1)))
        {
                if (setrlimit(RLIMIT_FSIZE, &rzero) == -1)
                        logerr("setrlimit RLIMIT_FSIZE");