Skip to content

Commit 572c3e1

Browse files
committed
Add nosyslog
Fixes #472.
1 parent 3425b8f commit 572c3e1

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

src/dhcpcd.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,9 +2173,6 @@ main(int argc, char **argv, char **envp)
21732173
ctx.options &= ~DHCPCD_DAEMONISE;
21742174
#endif
21752175

2176-
if (ctx.options & DHCPCD_DEBUG)
2177-
logsetopts(logopts | LOGERR_DEBUG);
2178-
21792176
if (!(ctx.options & (DHCPCD_TEST | DHCPCD_DUMPLEASE))) {
21802177
printpidfile:
21812178
/* If we have any other args, we should run as a single dhcpcd

src/dhcpcd.conf.5.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" SPDX-License-Identifier: BSD-2-Clause
22
.\"
3-
.\" Copyright (c) 2006-2024 Roy Marples
3+
.\" Copyright (c) 2006-2025 Roy Marples
44
.\" All rights reserved
55
.\"
66
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
2424
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2525
.\" SUCH DAMAGE.
2626
.\"
27-
.Dd November 1, 2024
27+
.Dd February 23, 2025
2828
.Dt DHCPCD.CONF 5
2929
.Os
3030
.Sh NAME
@@ -576,6 +576,8 @@ Don't solicit or accept IPv6 Router Advertisements.
576576
.It Ic nolink
577577
Don't receive link messages about carrier status.
578578
You should only set this for buggy interface drivers.
579+
.It Ic nosyslog
580+
Disable writing to syslog(3).
579581
.It Ic noup
580582
Don't bring the interface up when in manager mode.
581583
.It Ic option Ar option

src/if-options.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ const struct option cf_options[] = {
174174
{"request_time", required_argument, NULL, O_REQUEST_TIME},
175175
{"fallback_time", required_argument, NULL, O_FALLBACK_TIME},
176176
{"ipv4ll_time", required_argument, NULL, O_IPV4LL_TIME},
177+
{"nosyslog", no_argument, NULL, O_NOSYSLOG},
177178
{NULL, 0, NULL, '\0'}
178179
};
179180

@@ -740,7 +741,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
740741
}
741742
break;
742743
case 'd':
743-
ifo->options |= DHCPCD_DEBUG;
744+
logsetopts(loggetopts() | LOGERR_DEBUG);
744745
break;
745746
case 'e':
746747
ARG_REQUIRED;
@@ -2548,6 +2549,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
25482549
}
25492550
break;
25502551
#endif
2552+
case O_NOSYSLOG:
2553+
{
2554+
unsigned int logopts = loggetopts();
2555+
2556+
logopts &= ~LOGERR_LOG;
2557+
logsetopts(logopts);
2558+
}
2559+
break;
25512560
default:
25522561
return 0;
25532562
}

src/if-options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#define DHCPCD_RTBUILD (1ULL << 2)
6464
#define DHCPCD_GATEWAY (1ULL << 3)
6565
#define DHCPCD_STATIC (1ULL << 4)
66-
#define DHCPCD_DEBUG (1ULL << 5)
66+
//#define DHCPCD_DEBUG (1ULL << 5)
6767
#define DHCPCD_ARP_PERSISTDEFENCE (1ULL << 6)
6868
#define DHCPCD_LASTLEASE (1ULL << 7)
6969
#define DHCPCD_INFORM (1ULL << 8)
@@ -189,6 +189,7 @@
189189
#define O_IPV4LL_TIME O_BASE + 56
190190
#define O_VSIO O_BASE + 57
191191
#define O_VSIO6 O_BASE + 58
192+
#define O_NOSYSLOG O_BASE + 59
192193

193194
extern const struct option cf_options[];
194195

src/logerr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ logsetopts(unsigned int opts)
427427

428428
ctx->log_opts = opts;
429429
setlogmask(LOG_UPTO(opts & LOGERR_DEBUG ? LOG_DEBUG : LOG_INFO));
430+
if (!(ctx->log_opts & LOGERR_LOG))
431+
closelog();
430432
}
431433

432434
#ifdef LOGERR_TAG
@@ -463,7 +465,8 @@ logopen(const char *path)
463465

464466
if (ctx->log_opts & LOGERR_LOG_PID)
465467
opts |= LOG_PID;
466-
openlog(getprogname(), opts, LOGERR_SYSLOG_FACILITY);
468+
if (ctx->log_opts & LOGERR_LOG)
469+
openlog(getprogname(), opts, LOGERR_SYSLOG_FACILITY);
467470
if (path == NULL)
468471
return 1;
469472

src/script.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ make_env(struct dhcpcd_ctx *ctx, const struct interface *ifp,
471471
if (efprintf(fp, "af_waiting=%d", af) == -1)
472472
goto eexit;
473473
}
474-
if (ifo->options & DHCPCD_DEBUG) {
474+
if (loggetopts() & LOGERR_DEBUG) {
475475
if (efprintf(fp, "syslog_debug=true") == -1)
476476
goto eexit;
477477
}

0 commit comments

Comments
 (0)