]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add nosyslog
authorRoy Marples <roy@marples.name>
Sun, 23 Feb 2025 20:23:45 +0000 (20:23 +0000)
committerRoy Marples <roy@marples.name>
Sun, 23 Feb 2025 20:23:45 +0000 (20:23 +0000)
Fixes #472.

src/dhcpcd.c
src/dhcpcd.conf.5.in
src/if-options.c
src/if-options.h
src/logerr.c
src/script.c

index 09c3da24a1eb3d0b639de4c569c404eb6ebf364e..4a2c01848d6f9cbe8d19d107c34ed6cd88f07f7d 100644 (file)
@@ -2173,9 +2173,6 @@ main(int argc, char **argv, char **envp)
        ctx.options &= ~DHCPCD_DAEMONISE;
 #endif
 
-       if (ctx.options & DHCPCD_DEBUG)
-               logsetopts(logopts | LOGERR_DEBUG);
-
        if (!(ctx.options & (DHCPCD_TEST | DHCPCD_DUMPLEASE))) {
 printpidfile:
                /* If we have any other args, we should run as a single dhcpcd
index a67c68f772c29b676cd2704bebeb397b7257b9d5..c8a0f62acb53b0af3ba2ff7b8008b357145137ba 100644 (file)
@@ -1,6 +1,6 @@
 .\" SPDX-License-Identifier: BSD-2-Clause
 .\"
-.\" Copyright (c) 2006-2024 Roy Marples
+.\" Copyright (c) 2006-2025 Roy Marples
 .\" All rights reserved
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 1, 2024
+.Dd February 23, 2025
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -576,6 +576,8 @@ Don't solicit or accept IPv6 Router Advertisements.
 .It Ic nolink
 Don't receive link messages about carrier status.
 You should only set this for buggy interface drivers.
+.It Ic nosyslog
+Disable writing to syslog(3).
 .It Ic noup
 Don't bring the interface up when in manager mode.
 .It Ic option Ar option
index d931c36eaabe5ae90e9c0cc2c3fc50370de3f638..dd05072eca9a7cea6d567083977359f983035898 100644 (file)
@@ -174,6 +174,7 @@ const struct option cf_options[] = {
        {"request_time",    required_argument, NULL, O_REQUEST_TIME},
        {"fallback_time",   required_argument, NULL, O_FALLBACK_TIME},
        {"ipv4ll_time",     required_argument, NULL, O_IPV4LL_TIME},
+       {"nosyslog",        no_argument,       NULL, O_NOSYSLOG},
        {NULL,              0,                 NULL, '\0'}
 };
 
@@ -740,7 +741,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                }
                break;
        case 'd':
-               ifo->options |= DHCPCD_DEBUG;
+               logsetopts(loggetopts() | LOGERR_DEBUG);
                break;
        case 'e':
                ARG_REQUIRED;
@@ -2548,6 +2549,14 @@ invalid_token:
                }
                break;
 #endif
+       case O_NOSYSLOG:
+               {
+                       unsigned int logopts = loggetopts();
+
+                       logopts &= ~LOGERR_LOG;
+                       logsetopts(logopts);
+               }
+               break;
        default:
                return 0;
        }
index cd02be1874c42b5e31acb0b7e5d2981a92a1e7c6..6fa178fcdf7bf637a6ac69f68823fc42c6e8a38e 100644 (file)
@@ -63,7 +63,7 @@
 #define DHCPCD_RTBUILD                 (1ULL << 2)
 #define DHCPCD_GATEWAY                 (1ULL << 3)
 #define DHCPCD_STATIC                  (1ULL << 4)
-#define DHCPCD_DEBUG                   (1ULL << 5)
+//#define DHCPCD_DEBUG                 (1ULL << 5)
 #define DHCPCD_ARP_PERSISTDEFENCE      (1ULL << 6)
 #define DHCPCD_LASTLEASE               (1ULL << 7)
 #define DHCPCD_INFORM                  (1ULL << 8)
 #define O_IPV4LL_TIME          O_BASE + 56
 #define O_VSIO                 O_BASE + 57
 #define O_VSIO6                        O_BASE + 58
+#define O_NOSYSLOG             O_BASE + 59
 
 extern const struct option cf_options[];
 
index 3e5cd835e936f45fe35b7b224553ff6522a6104a..7520c56a58fe6de601a41eb5e9c4141c31fef18c 100644 (file)
@@ -427,6 +427,8 @@ logsetopts(unsigned int opts)
 
        ctx->log_opts = opts;
        setlogmask(LOG_UPTO(opts & LOGERR_DEBUG ? LOG_DEBUG : LOG_INFO));
+       if (!(ctx->log_opts & LOGERR_LOG))
+               closelog();
 }
 
 #ifdef LOGERR_TAG
@@ -463,7 +465,8 @@ logopen(const char *path)
 
        if (ctx->log_opts & LOGERR_LOG_PID)
                opts |= LOG_PID;
-       openlog(getprogname(), opts, LOGERR_SYSLOG_FACILITY);
+       if (ctx->log_opts & LOGERR_LOG)
+               openlog(getprogname(), opts, LOGERR_SYSLOG_FACILITY);
        if (path == NULL)
                return 1;
 
index 3ee2eaa461d9ebcebe63e2ad5018e826ded8a508..b06e2141bf5e62ed861bb6bd805bf17c41a9e867 100644 (file)
@@ -471,7 +471,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
                if (efprintf(fp, "af_waiting=%d", af) == -1)
                        goto eexit;
        }
-       if (ifo->options & DHCPCD_DEBUG) {
+       if (loggetopts() & LOGERR_DEBUG) {
                if (efprintf(fp, "syslog_debug=true") == -1)
                        goto eexit;
        }