Module Name: src
Committed By: roy
Date: Fri Nov 20 13:24:58 UTC 2020
Modified Files:
src/external/bsd/dhcpcd/dist/hooks: 20-resolv.conf 50-ntp.conf
50-ypbind.in
src/external/bsd/dhcpcd/dist/src: dhcp.c dhcp6.c dhcpcd.8.in dhcpcd.c
if-options.c ipv6.c ipv6nd.c privsep.c script.c
Log Message:
Sync with dhcpcd-9.3.3
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf \
src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
cvs rdiff -u -r1.42 -r1.43 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.24 -r1.25 src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
cvs rdiff -u -r1.45 -r1.46 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.28 -r1.29 src/external/bsd/dhcpcd/dist/src/if-options.c
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/src/ipv6.c
cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/src/ipv6nd.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcpcd/dist/src/privsep.c
cvs rdiff -u -r1.11 -r1.12 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/hooks/20-resolv.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.4 src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.5
--- src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf:1.4 Thu Apr 2 12:41:47 2020
+++ src/external/bsd/dhcpcd/dist/hooks/20-resolv.conf Fri Nov 20 13:24:58 2020
@@ -198,8 +198,10 @@ BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
;;
esac
-if $if_up || [ "$reason" = ROUTERADVERT ]; then
- add_resolv_conf
-elif $if_down; then
- remove_resolv_conf
+if $if_configured; then
+ if $if_up || [ "$reason" = ROUTERADVERT ]; then
+ add_resolv_conf
+ elif $if_down; then
+ remove_resolv_conf
+ fi
fi
Index: src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf
diff -u src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.4 src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.5
--- src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf:1.4 Thu Apr 2 12:41:48 2020
+++ src/external/bsd/dhcpcd/dist/hooks/50-ntp.conf Fri Nov 20 13:24:58 2020
@@ -135,8 +135,10 @@ BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
;;
esac
-if $if_up; then
- add_ntp_conf
-elif $if_down; then
- remove_ntp_conf
+if $if_configured; then
+ if $if_up; then
+ add_ntp_conf
+ elif $if_down; then
+ remove_ntp_conf
+ fi
fi
Index: src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in
diff -u src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.2 src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.3
--- src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in:1.2 Sat Sep 22 13:17:46 2018
+++ src/external/bsd/dhcpcd/dist/hooks/50-ypbind.in Fri Nov 20 13:24:58 2020
@@ -68,7 +68,9 @@ restore_yp_binding()
fi
}
-if [ "$reason" = PREINIT ]; then
+if ! $if_configured; then
+ ;
+elif [ "$reason" = PREINIT ]; then
rm -f "$ypbind_dir/$interface".*
elif $if_up || $if_down; then
if [ -n "$new_nis_domain" ]; then
Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.42 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.43
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.42 Sun Nov 1 14:24:01 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c Fri Nov 20 13:24:58 2020
@@ -2346,6 +2346,24 @@ dhcp_bind(struct interface *ifp)
old_state = state->added;
+ if (!(ifo->options & DHCPCD_CONFIGURE)) {
+ struct ipv4_addr *ia;
+
+ script_runreason(ifp, state->reason);
+ dhcpcd_daemonise(ifp->ctx);
+
+ /* We we are not configuring the address, we need to keep
+ * the BPF socket open if the address does not exist. */
+ ia = ipv4_iffindaddr(ifp, &state->lease.addr, NULL);
+ if (ia != NULL) {
+ state->addr = ia;
+ state->added = STATE_ADDED;
+ dhcp_closebpf(ifp);
+ goto openudp;
+ }
+ return;
+ }
+
/* Close the BPF filter as we can now receive DHCP messages
* on a UDP socket. */
dhcp_closebpf(ifp);
@@ -2353,6 +2371,7 @@ dhcp_bind(struct interface *ifp)
/* Add the address */
ipv4_applyaddr(ifp);
+openudp:
/* If not in master mode, open an address specific socket. */
if (ctx->options & DHCPCD_MASTER ||
(state->old != NULL &&
@@ -2361,7 +2380,6 @@ dhcp_bind(struct interface *ifp)
return;
dhcp_closeinet(ifp);
-
#ifdef PRIVSEP
if (IN_PRIVSEP_SE(ctx)) {
if (ps_inet_openbootp(state->addr) == -1)
@@ -2805,7 +2823,13 @@ dhcp_drop(struct interface *ifp, const c
state->new = NULL;
state->new_len = 0;
state->reason = reason;
- ipv4_applyaddr(ifp);
+ if (ifp->options->options & DHCPCD_CONFIGURE)
+ ipv4_applyaddr(ifp);
+ else {
+ state->addr = NULL;
+ state->added = 0;
+ script_runreason(ifp, state->reason);
+ }
free(state->old);
state->old = NULL;
state->old_len = 0;
@@ -4219,6 +4243,20 @@ dhcp_handleifa(int cmd, struct ipv4_addr
#endif
ifo = ifp->options;
+
+#ifdef PRIVSEP
+ if (IN_PRIVSEP_SE(ifp->ctx) &&
+ !(ifp->ctx->options & (DHCPCD_MASTER | DHCPCD_CONFIGURE)) &&
+ IN_ARE_ADDR_EQUAL(&state->lease.addr, &ia->addr))
+ {
+ state->addr = ia;
+ state->added = STATE_ADDED;
+ dhcp_closebpf(ifp);
+ if (ps_inet_openbootp(ia) == -1)
+ logerr(__func__);
+ }
+#endif
+
if (ifo->options & DHCPCD_INFORM) {
if (state->state != DHS_INFORM)
dhcp_inform(ifp);
Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.24 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.25
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.24 Mon Oct 12 14:09:03 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c Fri Nov 20 13:24:58 2020
@@ -2877,6 +2877,8 @@ dhcp6_delegate_prefix(struct interface *
TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) {
if (!ifd->active)
continue;
+ if (!(ifd->options->options & DHCPCD_CONFIGURE))
+ continue;
k = 0;
carrier_warned = false;
TAILQ_FOREACH(ap, &state->addrs, next) {
@@ -2970,6 +2972,10 @@ dhcp6_find_delegates(struct interface *i
struct if_sla *sla;
struct interface *ifd;
+ if (ifp->options != NULL &&
+ !(ifp->options->options & DHCPCD_CONFIGURE))
+ return 0;
+
k = 0;
TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) {
ifo = ifd->options;
@@ -3195,9 +3201,11 @@ dhcp6_bind(struct interface *ifp, const
eloop_timeout_add_sec(ifp->ctx->eloop,
state->expire, dhcp6_startexpire, ifp);
- ipv6_addaddrs(&state->addrs);
- if (!timedout)
- dhcp6_deprecateaddrs(&state->addrs);
+ if (ifp->options->options & DHCPCD_CONFIGURE) {
+ ipv6_addaddrs(&state->addrs);
+ if (!timedout)
+ dhcp6_deprecateaddrs(&state->addrs);
+ }
if (state->state == DH6S_INFORMED)
logmessage(loglevel, "%s: refresh in %"PRIu32" seconds",
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.9 src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.10
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in:1.9 Sun Nov 1 14:24:01 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.8.in Fri Nov 20 13:24:58 2020
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 30, 2020
+.Dd November 3, 2020
.Dt DHCPCD 8
.Os
.Sh NAME
@@ -62,6 +62,8 @@
.Op Fl Z , Fl Fl denyinterfaces Ar pattern
.Op Fl z , Fl Fl allowinterfaces Ar pattern
.Op Fl Fl inactive
+.Op Fl Fl configure
+.Op Fl Fl noconfigure
.Op interface
.Op ...
.Nm
@@ -737,6 +739,25 @@ This allows
to be started in Master mode and then wait for subsequent
.Nm
commands to start each interface as required.
+.It Fl Fl configure
+Allows
+.Nm
+to configure the system.
+This is the default behaviour and sets
+.Ev if_configured=true .
+.It Fl Fl noconfigure
+.Nm
+will not configure the system add all.
+This is only of use if the
+.Fl Fl script
+that
+.Nm
+calls at each network event configures the system instead.
+This is different from
+.Fl T , Fl Fl test
+mode in that it's not one shot and the only change to the environment is the
+addition of
+.Ev if_configured=false .
.It Fl Fl nodev
Don't load any
.Pa /dev
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.45 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.46
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.45 Sun Nov 1 14:24:01 2020
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c Fri Nov 20 13:24:58 2020
@@ -2179,6 +2179,9 @@ printpidfile:
if (!(ctx.options & DHCPCD_MASTER))
ctx.control_fd = control_open(argv[optind], family,
ctx.options & DHCPCD_DUMPLEASE);
+ if (!(ctx.options & DHCPCD_MASTER) && ctx.control_fd == -1)
+ ctx.control_fd = control_open(argv[optind], AF_UNSPEC,
+ ctx.options & DHCPCD_DUMPLEASE);
if (ctx.control_fd == -1)
ctx.control_fd = control_open(NULL, AF_UNSPEC,
ctx.options & DHCPCD_DUMPLEASE);
@@ -2241,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 &&
@@ -2332,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: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.28 src/external/bsd/dhcpcd/dist/src/if-options.c:1.29
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.28 Mon Oct 5 16:02:15 2020
+++ src/external/bsd/dhcpcd/dist/src/if-options.c Fri Nov 20 13:24:58 2020
@@ -165,6 +165,8 @@ const struct option cf_options[] = {
{"inactive", no_argument, NULL, O_INACTIVE},
{"mudurl", required_argument, NULL, O_MUDURL},
{"link_rcvbuf", required_argument, NULL, O_LINK_RCVBUF},
+ {"configure", no_argument, NULL, O_CONFIGURE},
+ {"noconfigure", no_argument, NULL, O_NOCONFIGURE},
{NULL, 0, NULL, '\0'}
};
@@ -782,6 +784,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
break;
case 'o':
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, request, arg, 1) != 0 ||
@@ -794,6 +798,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
break;
case O_REJECT:
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, reject, arg, 1) != 0 ||
@@ -1057,6 +1063,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
break;
case 'O':
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, request, arg, -1) != 0 ||
@@ -1069,6 +1077,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
break;
case 'Q':
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl, require, arg, 1) != 0 ||
@@ -1307,6 +1317,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
break;
case O_DESTINATION:
ARG_REQUIRED;
+ if (ctx->options & DHCPCD_PRINT_PIDFILE)
+ break;
set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo,
&request, &require, &no, &reject);
if (make_option_mask(d, dl, od, odl,
@@ -2234,6 +2246,12 @@ invalid_token:
}
#endif
break;
+ case O_CONFIGURE:
+ ifo->options |= DHCPCD_CONFIGURE;
+ break;
+ case O_NOCONFIGURE:
+ ifo->options &= ~DHCPCD_CONFIGURE;
+ break;
default:
return 0;
}
@@ -2269,7 +2287,8 @@ parse_config_line(struct dhcpcd_ctx *ctx
ldop, edop);
}
- logerrx("unknown option: %s", opt);
+ if (!(ctx->options & DHCPCD_PRINT_PIDFILE))
+ logerrx("unknown option: %s", opt);
return -1;
}
@@ -2352,7 +2371,8 @@ read_config(struct dhcpcd_ctx *ctx,
if ((ifo = default_config(ctx)) == NULL)
return NULL;
if (default_options == 0) {
- default_options |= DHCPCD_DAEMONISE | DHCPCD_GATEWAY;
+ default_options |= DHCPCD_DAEMONISE |
+ DHCPCD_CONFIGURE | DHCPCD_GATEWAY;
#ifdef INET
skip = socket(PF_INET, SOCK_DGRAM, 0);
if (skip != -1) {
Index: src/external/bsd/dhcpcd/dist/src/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6.c:1.15 src/external/bsd/dhcpcd/dist/src/ipv6.c:1.16
--- src/external/bsd/dhcpcd/dist/src/ipv6.c:1.15 Mon Oct 12 14:09:03 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6.c Fri Nov 20 13:24:58 2020
@@ -1416,6 +1416,9 @@ ipv6_addlinklocal(struct interface *ifp)
struct ipv6_addr *ap, *ap2;
int dadcounter;
+ if (!(ifp->options->options & DHCPCD_CONFIGURE))
+ return 0;
+
/* Check sanity before malloc */
if (!(ifp->options->options & DHCPCD_SLAACPRIVATE)) {
switch (ifp->hwtype) {
Index: src/external/bsd/dhcpcd/dist/src/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.25 src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.26
--- src/external/bsd/dhcpcd/dist/src/ipv6nd.c:1.25 Mon Oct 12 14:09:03 2020
+++ src/external/bsd/dhcpcd/dist/src/ipv6nd.c Fri Nov 20 13:24:58 2020
@@ -1494,13 +1494,18 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
script_runreason(ifp, "TEST");
goto handle_flag;
}
+
+ if (!(ifp->options->options & DHCPCD_CONFIGURE))
+ goto run;
+
ipv6nd_applyra(ifp);
ipv6_addaddrs(&rap->addrs);
#ifdef IPV6_MANAGETEMPADDR
ipv6_addtempaddrs(ifp, &rap->acquired);
#endif
-
rt_build(ifp->ctx, AF_INET6);
+
+run:
ipv6nd_scriptrun(rap);
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
Index: src/external/bsd/dhcpcd/dist/src/privsep.c
diff -u src/external/bsd/dhcpcd/dist/src/privsep.c:1.10 src/external/bsd/dhcpcd/dist/src/privsep.c:1.11
--- src/external/bsd/dhcpcd/dist/src/privsep.c:1.10 Sun Nov 1 14:24:01 2020
+++ src/external/bsd/dhcpcd/dist/src/privsep.c Fri Nov 20 13:24:58 2020
@@ -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");
@@ -362,7 +363,7 @@ ps_dostart(struct dhcpcd_ctx *ctx,
return pid;
}
- ctx->options |= DHCPCD_UNPRIV | DHCPCD_FORKED;
+ ctx->options |= DHCPCD_FORKED;
if (ctx->fork_fd != -1) {
close(ctx->fork_fd);
ctx->fork_fd = -1;
Index: src/external/bsd/dhcpcd/dist/src/script.c
diff -u src/external/bsd/dhcpcd/dist/src/script.c:1.11 src/external/bsd/dhcpcd/dist/src/script.c:1.12
--- src/external/bsd/dhcpcd/dist/src/script.c:1.11 Mon Oct 12 14:09:03 2020
+++ src/external/bsd/dhcpcd/dist/src/script.c Fri Nov 20 13:24:58 2020
@@ -350,6 +350,9 @@ make_env(struct dhcpcd_ctx *ctx, const s
}
if (ifp->ctx->options & DHCPCD_DUMPLEASE && protocol != PROTO_LINK)
goto dumplease;
+ if (efprintf(fp, "if_configured=%s",
+ ifo->options & DHCPCD_CONFIGURE ? "true" : "false") == -1)
+ goto eexit;
if (efprintf(fp, "ifcarrier=%s",
ifp->carrier == LINK_UNKNOWN ? "unknown" :
ifp->carrier == LINK_UP ? "up" : "down") == -1)