Module Name: src
Committed By: roy
Date: Mon Oct 12 14:09:03 UTC 2020
Modified Files:
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.c if-bsd.c
ipv6.c ipv6nd.c logerr.c privsep.c script.c
Log Message:
Sync withn dhcpcd-9.3.1
To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.23 -r1.24 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.43 -r1.44 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/src/if-bsd.c \
src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/logerr.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/script.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.41
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.40 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c Mon Oct 12 14:09:03 2020
@@ -1712,7 +1712,7 @@ send_message(struct interface *ifp, uint
if (callback == NULL) {
/* No carrier? Don't bother sending the packet. */
- if (ifp->carrier <= LINK_DOWN)
+ if (!if_is_link_up(ifp))
return;
logdebugx("%s: sending %s with xid 0x%x",
ifp->name,
@@ -1731,7 +1731,7 @@ send_message(struct interface *ifp, uint
(arc4random_uniform(MSEC_PER_SEC * 2) - MSEC_PER_SEC);
/* No carrier? Don't bother sending the packet.
* However, we do need to advance the timeout. */
- if (ifp->carrier <= LINK_DOWN)
+ if (!if_is_link_up(ifp))
goto fail;
logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds",
ifp->name,
@@ -2633,7 +2633,7 @@ dhcp_reboot(struct interface *ifp)
state->state = DHS_REBOOT;
state->interval = 0;
- if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) {
+ if (ifo->options & DHCPCD_LINK && !if_is_link_up(ifp)) {
loginfox("%s: waiting for carrier", ifp->name);
return;
}
@@ -2733,7 +2733,7 @@ dhcp_drop(struct interface *ifp, const c
state->state = DHS_RELEASE;
dhcp_unlink(ifp->ctx, state->leasefile);
- if (ifp->carrier > LINK_DOWN &&
+ if (if_is_link_up(ifp) &&
state->new != NULL &&
state->lease.server.s_addr != INADDR_ANY)
{
Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.24
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.23 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Oct 12 14:09:03 2020
@@ -1237,7 +1237,7 @@ dhcp6_sendmessage(struct interface *ifp,
};
char uaddr[INET6_ADDRSTRLEN];
- if (!callback && ifp->carrier <= LINK_DOWN)
+ if (!callback && !if_is_link_up(ifp))
return 0;
if (!IN6_IS_ADDR_UNSPECIFIED(&state->unicast)) {
@@ -1298,7 +1298,7 @@ dhcp6_sendmessage(struct interface *ifp,
+ (unsigned int)((float)state->RT
* ((float)lr / DHCP6_RAND_DIV));
- if (ifp->carrier > LINK_DOWN)
+ if (if_is_link_up(ifp))
logdebugx("%s: %s %s (xid 0x%02x%02x%02x)%s%s,"
" next in %0.1f seconds",
ifp->name,
@@ -1320,7 +1320,7 @@ dhcp6_sendmessage(struct interface *ifp,
}
}
- if (ifp->carrier <= LINK_DOWN)
+ if (!if_is_link_up(ifp))
return 0;
/* Update the elapsed time */
@@ -2906,7 +2906,7 @@ dhcp6_delegate_prefix(struct interface *
if (ia->sla_len == 0) {
/* no SLA configured, so lets
* automate it */
- if (ifd->carrier != LINK_UP) {
+ if (!if_is_link_up(ifd)) {
logdebugx(
"%s: has no carrier, cannot"
" delegate addresses",
@@ -2922,7 +2922,7 @@ dhcp6_delegate_prefix(struct interface *
sla = &ia->sla[j];
if (strcmp(ifd->name, sla->ifname))
continue;
- if (ifd->carrier != LINK_UP) {
+ if (!if_is_link_up(ifd)) {
logdebugx(
"%s: has no carrier, cannot"
" delegate addresses",
@@ -4029,7 +4029,7 @@ dhcp6_freedrop(struct interface *ifp, in
if (drop && options & DHCPCD_RELEASE &&
state->state != DH6S_DELEGATED)
{
- if (ifp->carrier == LINK_UP &&
+ if (if_is_link_up(ifp) &&
state->state != DH6S_RELEASED &&
state->state != DH6S_INFORMED)
{
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.43 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.44
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.43 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Oct 12 14:09:03 2020
@@ -97,9 +97,6 @@ const int dhcpcd_signals_ignore[] = {
const size_t dhcpcd_signals_ignore_len = __arraycount(dhcpcd_signals_ignore);
#endif
-#define IF_UPANDRUNNING(a) \
- (((a)->flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING))
-
const char *dhcpcd_default_script = SCRIPT;
static void
@@ -412,7 +409,7 @@ dhcpcd_drop(struct interface *ifp, int s
}
static void
-stop_interface(struct interface *ifp)
+stop_interface(struct interface *ifp, const char *reason)
{
struct dhcpcd_ctx *ctx;
@@ -421,10 +418,7 @@ stop_interface(struct interface *ifp)
ifp->options->options |= DHCPCD_STOPPING;
dhcpcd_drop(ifp, 1);
- if (ifp->options->options & DHCPCD_DEPARTED)
- script_runreason(ifp, "DEPARTED");
- else
- script_runreason(ifp, "STOPPED");
+ script_runreason(ifp, reason == NULL ? "STOPPED" : reason);
/* Delete all timeouts for the interfaces */
eloop_q_timeout_delete(ctx->eloop, ELOOP_QUEUE_ALL, NULL, ifp);
@@ -704,110 +698,108 @@ dhcpcd_reportssid(struct interface *ifp)
void
dhcpcd_handlecarrier(struct interface *ifp, int carrier, unsigned int flags)
{
- bool nolink = ifp->options == NULL ||
- !(ifp->options->options & DHCPCD_LINK);
+ bool was_link_up = if_is_link_up(ifp);
+ ifp->carrier = carrier;
ifp->flags = flags;
- if (carrier == LINK_UNKNOWN) {
- if (ifp->wireless)
- carrier = LINK_DOWN;
- else
- carrier = IF_UPANDRUNNING(ifp) ? LINK_UP : LINK_DOWN;
- }
- if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
- if (ifp->carrier != LINK_DOWN) {
-#ifdef NOCARRIER_PRESERVE_IP
- if (ifp->flags & IFF_UP &&
- (ifp->options == NULL ||
- !(ifp->options->options & DHCPCD_ANONYMOUS)))
- ifp->carrier = LINK_DOWN_IFFUP;
- else
-#endif
- ifp->carrier = LINK_DOWN;
- if (!ifp->active || nolink)
- return;
- loginfox("%s: carrier lost", ifp->name);
- script_runreason(ifp, "NOCARRIER");
+ if (!if_is_link_up(ifp)) {
+ if (!was_link_up || !ifp->active)
+ return;
+ loginfox("%s: carrier lost", ifp->name);
+ script_runreason(ifp, "NOCARRIER");
#ifdef NOCARRIER_PRESERVE_IP
- if (ifp->flags & IFF_UP &&
- !(ifp->options->options & DHCPCD_ANONYMOUS))
- {
+ if (ifp->flags & IFF_UP &&
+ !(ifp->options->options & DHCPCD_ANONYMOUS))
+ {
#ifdef ARP
- arp_drop(ifp);
+ arp_drop(ifp);
#endif
#ifdef INET
- dhcp_abort(ifp);
+ dhcp_abort(ifp);
#endif
#ifdef DHCP6
- dhcp6_abort(ifp);
+ dhcp6_abort(ifp);
#endif
- } else
+ } else
#endif
- dhcpcd_drop(ifp, 0);
- if (ifp->options->options & DHCPCD_ANONYMOUS) {
- bool was_up = ifp->flags & IFF_UP;
-
- if (was_up)
- if_down(ifp);
- if (if_randomisemac(ifp) == -1 && errno != ENXIO)
- logerr(__func__);
- if (was_up)
- if_up(ifp);
- }
+ dhcpcd_drop(ifp, 0);
+ if (ifp->options->options & DHCPCD_ANONYMOUS) {
+ bool is_up = ifp->flags & IFF_UP;
+
+ if (is_up)
+ if_down(ifp);
+ if (if_randomisemac(ifp) == -1 && errno != ENXIO)
+ logerr(__func__);
+ if (is_up)
+ if_up(ifp);
}
- } else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
- if (ifp->carrier != LINK_UP) {
- ifp->carrier = LINK_UP;
- if (ifp->active)
- loginfox("%s: carrier acquired", ifp->name);
+ return;
+ }
+
+ /*
+ * At this point carrier is NOT DOWN and we have IFF_UP.
+ * We should treat LINK_UNKNOWN as up as the driver may not support
+ * link state changes.
+ * The consideration of any other information about carrier should
+ * be handled in the OS specific if_carrier() function.
+ */
+ if (was_link_up)
+ return;
+
+ if (ifp->active) {
+ if (carrier == LINK_UNKNOWN)
+ loginfox("%s: carrier unknown, assuming up", ifp->name);
+ else
+ loginfox("%s: carrier acquired", ifp->name);
+ }
+
#if !defined(__linux__) && !defined(__NetBSD__)
- /* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the
- * hardware address changes so we have to go
- * through the disovery process to work it out. */
- dhcpcd_handleinterface(ifp->ctx, 0, ifp->name);
-#endif
- if (ifp->wireless) {
- uint8_t ossid[IF_SSIDLEN];
- size_t olen;
-
- olen = ifp->ssid_len;
- memcpy(ossid, ifp->ssid, ifp->ssid_len);
- if_getssid(ifp);
-
- /* If we changed SSID network, drop leases */
- if ((ifp->ssid_len != olen ||
- memcmp(ifp->ssid, ossid, ifp->ssid_len)) &&
- ifp->active)
- {
- dhcpcd_reportssid(ifp);
+ /* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the
+ * hardware address changes so we have to go
+ * through the disovery process to work it out. */
+ dhcpcd_handleinterface(ifp->ctx, 0, ifp->name);
+#endif
+
+ if (ifp->wireless) {
+ uint8_t ossid[IF_SSIDLEN];
+ size_t olen;
+
+ olen = ifp->ssid_len;
+ memcpy(ossid, ifp->ssid, ifp->ssid_len);
+ if_getssid(ifp);
+
+ /* If we changed SSID network, drop leases */
+ if ((ifp->ssid_len != olen ||
+ memcmp(ifp->ssid, ossid, ifp->ssid_len)) && ifp->active)
+ {
+ dhcpcd_reportssid(ifp);
#ifdef NOCARRIER_PRESERVE_IP
- dhcpcd_drop(ifp, 0);
+ dhcpcd_drop(ifp, 0);
#endif
#ifdef IPV4LL
- ipv4ll_reset(ifp);
+ ipv4ll_reset(ifp);
#endif
- }
- }
- if (!ifp->active || nolink)
- return;
- dhcpcd_initstate(ifp, 0);
- script_runreason(ifp, "CARRIER");
+ }
+ }
+
+ if (!ifp->active)
+ return;
+
+ dhcpcd_initstate(ifp, 0);
+ script_runreason(ifp, "CARRIER");
#ifdef INET6
#ifdef NOCARRIER_PRESERVE_IP
- /* Set any IPv6 Routers we remembered to expire
- * faster than they would normally as we
- * maybe on a new network. */
- ipv6nd_startexpire(ifp);
+ /* Set any IPv6 Routers we remembered to expire faster than they
+ * would normally as we maybe on a new network. */
+ ipv6nd_startexpire(ifp);
#endif
#ifdef IPV6_MANAGETEMPADDR
- /* RFC4941 Section 3.5 */
- ipv6_regentempaddrs(ifp);
+ /* RFC4941 Section 3.5 */
+ ipv6_regentempaddrs(ifp);
#endif
#endif
- dhcpcd_startinterface(ifp);
- }
- }
+ dhcpcd_startinterface(ifp);
}
static void
@@ -866,9 +858,7 @@ dhcpcd_startinterface(void *arg)
struct interface *ifp = arg;
struct if_options *ifo = ifp->options;
- if (ifo->options & DHCPCD_LINK && (ifp->carrier == LINK_DOWN ||
- (ifp->carrier == LINK_UNKNOWN && !IF_UPANDRUNNING(ifp))))
- {
+ if (ifo->options & DHCPCD_LINK && !if_is_link_up(ifp)) {
loginfox("%s: waiting for carrier", ifp->name);
return;
}
@@ -959,7 +949,7 @@ dhcpcd_prestartinterface(void *arg)
struct dhcpcd_ctx *ctx = ifp->ctx;
bool anondown;
- if (ifp->carrier == LINK_DOWN &&
+ if (ifp->carrier <= LINK_DOWN &&
ifp->options->options & DHCPCD_ANONYMOUS &&
ifp->flags & IFF_UP)
{
@@ -990,7 +980,7 @@ run_preinit(struct interface *ifp)
return;
script_runreason(ifp, "PREINIT");
- if (ifp->wireless && ifp->carrier == LINK_UP)
+ if (ifp->wireless && if_is_link_up(ifp))
dhcpcd_reportssid(ifp);
if (ifp->options->options & DHCPCD_LINK && ifp->carrier != LINK_UNKNOWN)
script_runreason(ifp,
@@ -1032,8 +1022,7 @@ dhcpcd_handleinterface(void *arg, int ac
}
if (ifp->active) {
logdebugx("%s: interface departed", ifp->name);
- ifp->options->options |= DHCPCD_DEPARTED;
- stop_interface(ifp);
+ stop_interface(ifp, "DEPARTED");
}
TAILQ_REMOVE(ctx->ifaces, ifp, next);
if_free(ifp);
@@ -1346,7 +1335,7 @@ stop_all_interfaces(struct dhcpcd_ctx *c
if (ifp->options->options & DHCPCD_RELEASE)
ifp->options->options &= ~DHCPCD_PERSISTENT;
ifp->options->options |= DHCPCD_EXITING;
- stop_interface(ifp);
+ stop_interface(ifp, NULL);
}
}
@@ -1357,8 +1346,7 @@ dhcpcd_ifrenew(struct interface *ifp)
if (!ifp->active)
return;
- if (ifp->options->options & DHCPCD_LINK &&
- ifp->carrier == LINK_DOWN)
+ if (ifp->options->options & DHCPCD_LINK && !if_is_link_up(ifp))
return;
#ifdef INET
@@ -1599,7 +1587,7 @@ dumperr:
ifp->options->options |= opts;
if (opts & DHCPCD_RELEASE)
ifp->options->options &= ~DHCPCD_PERSISTENT;
- stop_interface(ifp);
+ stop_interface(ifp, NULL);
}
return 0;
}
@@ -1779,7 +1767,7 @@ dhcpcd_stderr_cb(void *arg)
}
int
-main(int argc, char **argv)
+main(int argc, char **argv, char **envp)
{
struct dhcpcd_ctx ctx;
struct ifaddrs *ifaddrs = NULL;
@@ -1799,6 +1787,12 @@ main(int argc, char **argv)
size_t si;
#endif
+#ifdef SETPROCTITLE_H
+ setproctitle_init(argc, argv, envp);
+#else
+ UNUSED(envp);
+#endif
+
/* Test for --help and --version */
if (argc > 1) {
if (strcmp(argv[1], "--help") == 0) {
@@ -2258,7 +2252,7 @@ printpidfile:
ctx.fork_fd = fork_fd[1];
close(fork_fd[0]);
#ifdef PRIVSEP_RIGHTS
- if (ps_rights_limit_fd(fork_fd[1]) == -1) {
+ if (ps_rights_limit_fd(ctx.fork_fd) == -1) {
logerr("ps_rights_limit_fdpair");
goto exit_failure;
}
@@ -2301,14 +2295,12 @@ printpidfile:
break;
default:
setproctitle("[launcher]");
- ctx.options |= DHCPCD_FORKED;
+ ctx.options |= DHCPCD_FORKED | DHCPCD_LAUNCHER;
ctx.fork_fd = fork_fd[0];
close(fork_fd[1]);
#ifdef PRIVSEP_RIGHTS
- if (ps_rights_limit_fd(fork_fd[0]) == -1 ||
- ps_rights_limit_fd(stderr_fd[0]) == 1)
- {
- logerr("ps_rights_limit_fdpair");
+ if (ps_rights_limit_fd(ctx.fork_fd) == -1) {
+ logerr("ps_rights_limit_fd");
goto exit_failure;
}
#endif
@@ -2318,14 +2310,13 @@ printpidfile:
ctx.stderr_fd = stderr_fd[0];
close(stderr_fd[1]);
#ifdef PRIVSEP_RIGHTS
- if (ps_rights_limit_fd(stderr_fd[0]) == 1) {
- logerr("ps_rights_limit_fdpair");
+ if (ps_rights_limit_fd(ctx.stderr_fd) == 1) {
+ logerr("ps_rights_limit_fd");
goto exit_failure;
}
#endif
- if (ctx.stderr_valid)
- eloop_event_add(ctx.eloop, ctx.stderr_fd,
- dhcpcd_stderr_cb, &ctx);
+ eloop_event_add(ctx.eloop, ctx.stderr_fd,
+ dhcpcd_stderr_cb, &ctx);
}
#ifdef PRIVSEP
if (IN_PRIVSEP(&ctx) && ps_mastersandbox(&ctx, NULL) == -1)
@@ -2463,8 +2454,7 @@ printpidfile:
TAILQ_FOREACH(ifp, ctx.ifaces, next) {
if (ifp->active) {
run_preinit(ifp);
- if (!(ifp->options->options & DHCPCD_LINK) ||
- ifp->carrier != LINK_DOWN)
+ if (if_is_link_up(ifp))
opt = 1;
}
}
@@ -2582,7 +2572,7 @@ exit1:
free(ctx.logfile);
free(ctx.ctl_buf);
#ifdef SETPROCTITLE_H
- setproctitle_free();
+ setproctitle_fini();
#endif
#ifdef USE_SIGNALS
if (ctx.options & DHCPCD_STARTED) {
Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.24 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.25
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.24 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/if-bsd.c Mon Oct 12 14:09:03 2020
@@ -385,7 +385,7 @@ static int if_indirect_ioctl(struct dhcp
}
int
-if_carrier(__unused struct interface *ifp, const void *ifadata)
+if_carrier(struct interface *ifp, const void *ifadata)
{
const struct if_data *ifi = ifadata;
@@ -398,8 +398,15 @@ if_carrier(__unused struct interface *if
if (ifi->ifi_link_state >= LINK_STATE_UP)
return LINK_UP;
- if (ifi->ifi_link_state == LINK_STATE_UNKNOWN)
+ if (ifi->ifi_link_state == LINK_STATE_UNKNOWN) {
+ /*
+ * Work around net80211 issues in some BSDs.
+ * Wireless MUST support link state change.
+ */
+ if (ifp->wireless)
+ return LINK_DOWN;
return LINK_UNKNOWN;
+ }
return LINK_DOWN;
}
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.24 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.25
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.24 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Mon Oct 12 14:09:03 2020
@@ -437,7 +437,7 @@ ipv6nd_sendadvertisement(void *arg)
const struct rs_state *state = RS_CSTATE(ifp);
int s;
- if (state == NULL || ifp->carrier <= LINK_DOWN)
+ if (state == NULL || !if_is_link_up(ifp))
goto freeit;
#ifdef SIN6_LEN
@@ -505,7 +505,7 @@ ipv6nd_advertise(struct ipv6_addr *ia)
iaf = NULL;
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
state = IPV6_STATE(ifp);
- if (state == NULL || ifp->carrier <= LINK_DOWN)
+ if (state == NULL || !if_is_link_up(ifp))
continue;
TAILQ_FOREACH(iap, &state->addrs, next) {
Index: src/external/bsd/dhcpcd/dist/src/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6.c:1.14 src/external/bsd/dhcpcd/dist/src/ipv6.c:1.15
--- src/external/bsd/dhcpcd/dist/src/ipv6.c:1.14 Sun Sep 6 14:55:34 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6.c Mon Oct 12 14:09:03 2020
@@ -105,7 +105,7 @@
defined(IFF_NOLINKLOCAL)
/* Only add the LL address if we have a carrier, so DaD works. */
#define CAN_ADD_LLADDR(ifp) \
- (!((ifp)->options->options & DHCPCD_LINK) || (ifp)->carrier != LINK_DOWN)
+ (!((ifp)->options->options & DHCPCD_LINK) || if_is_link_up((ifp)))
#ifdef __sun
/* Although we can add our own LL address, we cannot drop it
* without unplumbing the if which is a lot of code.
Index: src/external/bsd/dhcpcd/dist/src/logerr.c
diff -u src/external/bsd/dhcpcd/dist/src/logerr.c:1.9 src/external/bsd/dhcpcd/dist/src/logerr.c:1.10
--- src/external/bsd/dhcpcd/dist/src/logerr.c:1.9 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/logerr.c Mon Oct 12 14:09:03 2020
@@ -366,20 +366,24 @@ int
logopen(const char *path)
{
struct logctx *ctx = &_logctx;
+ int opts = 0;
/* Cache timezone */
tzset();
(void)setvbuf(stderr, ctx->log_buf, _IOLBF, sizeof(ctx->log_buf));
- if (path == NULL) {
- int opts = 0;
+ if (!(ctx->log_opts & LOGERR_LOG))
+ return 1;
- if (ctx->log_opts & LOGERR_LOG_PID)
- opts |= LOG_PID;
- openlog(NULL, opts, LOGERR_SYSLOG_FACILITY);
+#ifdef LOG_NDELAY
+ opts |= LOG_NDELAY;
+#endif
+ if (ctx->log_opts & LOGERR_LOG_PID)
+ opts |= LOG_PID;
+ openlog(NULL, opts, LOGERR_SYSLOG_FACILITY);
+ if (path == NULL)
return 1;
- }
#ifndef SMALL
if ((ctx->log_file = fopen(path, "ae")) == NULL)
Index: src/external/bsd/dhcpcd/dist/src/privsep.c
diff -u src/external/bsd/dhcpcd/dist/src/privsep.c:1.8 src/external/bsd/dhcpcd/dist/src/privsep.c:1.9
--- src/external/bsd/dhcpcd/dist/src/privsep.c:1.8 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/privsep.c Mon Oct 12 14:09:03 2020
@@ -116,7 +116,7 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
{
struct passwd *pw = ctx->ps_user;
- if (!(ctx->options & DHCPCD_FORKED))
+ if (ctx->options & DHCPCD_LAUNCHER)
logdebugx("chrooting as %s to %s", pw->pw_name, pw->pw_dir);
if (chroot(pw->pw_dir) == -1 &&
(errno != EPERM || ctx->options & DHCPCD_FORKED))
@@ -166,7 +166,10 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
/* 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) {
+ if (ctx->logfile == NULL &&
+ (ctx->options & DHCPCD_STARTED ||
+ !ctx->stderr_valid || isatty(STDERR_FILENO) == 1))
+ {
if (setrlimit(RLIMIT_FSIZE, &rzero) == -1)
logerr("setrlimit RLIMIT_FSIZE");
}
@@ -467,13 +470,11 @@ ps_start(struct dhcpcd_ctx *ctx)
/* No point in spawning the generic network listener if we're
* not going to use it. */
- if (!(ctx->options & (DHCPCD_MASTER | DHCPCD_IPV6)))
+ if (!ps_inet_canstart(ctx))
goto started_net;
switch (pid = ps_inet_start(ctx)) {
case -1:
- if (errno == ENXIO)
- return 0;
return -1;
case 0:
return 0;
@@ -566,7 +567,7 @@ ps_mastersandbox(struct dhcpcd_ctx *ctx,
}
logerr("%s: %s", __func__, sandbox);
return -1;
- } else if (!forked)
+ } else if (ctx->options & DHCPCD_LAUNCHER)
logdebugx("sandbox: %s", sandbox);
return 0;
}
Index: src/external/bsd/dhcpcd/dist/src/script.c
diff -u src/external/bsd/dhcpcd/dist/src/script.c:1.10 src/external/bsd/dhcpcd/dist/src/script.c:1.11
--- src/external/bsd/dhcpcd/dist/src/script.c:1.10 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/script.c Mon Oct 12 14:09:03 2020
@@ -589,7 +589,6 @@ send_interface(struct fd_list *fd, const
reason = "CARRIER";
break;
case LINK_DOWN:
- case LINK_DOWN_IFFUP:
reason = "NOCARRIER";
break;
default: