Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/roy]: src/external/bsd/dhcpcd/dist Update to dhcpcd-9.0.1 with the follo...
details: https://anonhg.NetBSD.org/src/rev/91e36d242e44
branches: roy
changeset: 930764:91e36d242e44
user: roy <roy%NetBSD.org@localhost>
date: Mon Apr 13 15:42:20 2020 +0000
description:
Update to dhcpcd-9.0.1 with the following changes:
* privsep: Improve error when we don't have permission to write lease
PR bin/55135
* privsep: Fix hooks restarting other daemons
diffstat:
external/bsd/dhcpcd/dist/README.md | 4 +-
external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in | 4 +-
external/bsd/dhcpcd/dist/src/defs.h | 2 +-
external/bsd/dhcpcd/dist/src/dhcp.c | 2 +-
external/bsd/dhcpcd/dist/src/dhcp6.c | 9 +-
external/bsd/dhcpcd/dist/src/dhcpcd.c | 96 +++--
external/bsd/dhcpcd/dist/src/if-bsd.c | 8 +-
external/bsd/dhcpcd/dist/src/if-options.c | 6 +
external/bsd/dhcpcd/dist/src/ipv6.c | 302 ++++++------------
external/bsd/dhcpcd/dist/src/ipv6.h | 17 +-
external/bsd/dhcpcd/dist/src/ipv6nd.c | 9 +-
external/bsd/dhcpcd/dist/src/ipv6nd.h | 1 +
external/bsd/dhcpcd/dist/src/route.h | 15 +
external/bsd/dhcpcd/dist/src/script.c | 6 +-
external/bsd/dhcpcd/dist/src/script.h | 2 +-
15 files changed, 209 insertions(+), 274 deletions(-)
diffs (truncated from 1017 to 300 lines):
diff -r 3edbf943c0bb -r 91e36d242e44 external/bsd/dhcpcd/dist/README.md
--- a/external/bsd/dhcpcd/dist/README.md Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/README.md Mon Apr 13 15:42:20 2020 +0000
@@ -90,9 +90,7 @@
`/var/db` and now stores dhcpcd.duid and dhcpcd.secret in there instead of
in /etc.
dhcpcd-9 requires this directory and contents to be writeable by the
-unprivileged user (default _dhcpcd).
-The Makefile `_confinstall` target will attempt to move the files correctly from
-the old locations to the new locations.
+unprivileged user (default _dhcpcd, _dhcp or dhcpcd).
Of course this won't work if dhcpcd is packaged up, so packagers will need to
install similar logic into their dhcpcd package.
diff -r 3edbf943c0bb -r 91e36d242e44 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in
--- a/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.8.in Mon Apr 13 15:42:20 2020 +0000
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 21, 2020
+.Dd April 3, 2020
.Dt DHCPCD-RUN-HOOKS 8
.Os
.Sh NAME
@@ -136,8 +136,6 @@
This normally happens when dhcpcd does not support the raw interface, which
means it cannot work as a DHCP or ZeroConf client.
Static configuration and DHCP INFORM is still allowed.
-.It Dv DUMP
-dhcpcd has been asked to dump the last lease for the interface.
.It Dv TEST
dhcpcd received an OFFER from a DHCP server but will not configure the
interface.
diff -r 3edbf943c0bb -r 91e36d242e44 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h Mon Apr 13 15:42:20 2020 +0000
@@ -29,7 +29,7 @@
#define CONFIG_H
#define PACKAGE "dhcpcd"
-#define VERSION "9.0.0"
+#define VERSION "9.0.1"
#ifndef PRIVSEP_USER
# define PRIVSEP_USER "_" PACKAGE
diff -r 3edbf943c0bb -r 91e36d242e44 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c Mon Apr 13 15:42:20 2020 +0000
@@ -2301,7 +2301,7 @@
if (!state->lease.frominfo &&
!(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)))
if (write_lease(ifp, state->new, state->new_len) == -1)
- logerr(__func__);
+ logerr("write_lease: %s", state->leasefile);
/* Close the BPF filter as we can now receive DHCP messages
* on a UDP socket. */
diff -r 3edbf943c0bb -r 91e36d242e44 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c Mon Apr 13 15:42:20 2020 +0000
@@ -2503,10 +2503,8 @@
logdebugx("%s: writing lease `%s'", ifp->name, state->leasefile);
fd = open(state->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd == -1) {
- logerr(__func__);
+ if (fd == -1)
return -1;
- }
bytes = write(fd, state->new, state->new_len);
close(fd);
return bytes;
@@ -2710,7 +2708,7 @@
vl |= sla->suffix;
be64enc(daddr.s6_addr + 8, vl);
} else {
- dadcounter = ipv6_makeaddr(&daddr, ifp, &addr, pfxlen);
+ dadcounter = ipv6_makeaddr(&daddr, ifp, &addr, pfxlen, 0);
if (dadcounter == -1) {
logerrx("%s: error adding slaac to prefix_len %d",
ifp->name, pfxlen);
@@ -3162,7 +3160,8 @@
ifp->name, state->expire);
rt_build(ifp->ctx, AF_INET6);
if (!confirmed && !timedout)
- dhcp6_writelease(ifp);
+ if (dhcp6_writelease(ifp) == -1)
+ logerr("dhcp6_writelease: %s",state->leasefile);
#ifndef SMALL
dhcp6_delegate_prefix(ifp);
#endif
diff -r 3edbf943c0bb -r 91e36d242e44 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c Mon Apr 13 15:42:20 2020 +0000
@@ -781,8 +781,10 @@
* maybe on a new network. */
ipv6nd_startexpire(ifp);
#endif
+#ifdef IPV6_MANAGETEMPADDR
/* RFC4941 Section 3.5 */
- ipv6_gentempifid(ifp);
+ ipv6_regentempaddrs(ifp);
+#endif
#endif
dhcpcd_startinterface(ifp);
}
@@ -1552,26 +1554,39 @@
ctx->options |= DHCPCD_DUMPLEASE;
size_t nifaces = 0;
- for (oi = optind; oi < argc; oi++) {
- if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
- continue;
+ TAILQ_FOREACH(ifp, ctx->ifaces, next) {
if (!ifp->active)
continue;
- opt = send_interface(NULL, ifp, af);
- if (opt != -1)
+ for (oi = optind; oi < argc; oi++) {
+ if (strcmp(ifp->name, argv[oi]) == 0)
+ break;
+ }
+ if (optind == argc || oi < argc) {
+ opt = send_interface(NULL, ifp, af);
+ if (opt == -1)
+ goto dumperr;
nifaces += (size_t)opt;
+ }
}
if (write(fd->fd, &nifaces, sizeof(nifaces)) != sizeof(nifaces))
- return -1;
- for (oi = optind; oi < argc; oi++) {
- if ((ifp = if_find(ctx->ifaces, argv[oi])) == NULL)
- continue;
+ goto dumperr;
+ TAILQ_FOREACH(ifp, ctx->ifaces, next) {
if (!ifp->active)
continue;
- send_interface(fd, ifp, af);
+ for (oi = optind; oi < argc; oi++) {
+ if (strcmp(ifp->name, argv[oi]) == 0)
+ break;
+ }
+ if (optind == argc || oi < argc) {
+ if (send_interface(fd, ifp, af) == -1)
+ goto dumperr;
+ }
}
ctx->options &= ~DHCPCD_DUMPLEASE;
return 0;
+dumperr:
+ ctx->options &= ~DHCPCD_DUMPLEASE;
+ return -1;
}
/* Only privileged users can control dhcpcd via the socket. */
@@ -1618,14 +1633,20 @@
return 0;
}
+static const char *dumpskip[] = {
+ "PATH=",
+ "pid=",
+ "chroot=",
+};
+
static int
dhcpcd_readdump(struct dhcpcd_ctx *ctx)
{
int error = 0;
- size_t nifaces, buflen = 0, dlen;
+ size_t nifaces, buflen = 0, dlen, i;
ssize_t len;
char *buf = NULL, *dp, *de;
- bool print;
+ const char *skip;
again1:
len = read(ctx->control_fd, &nifaces, sizeof(nifaces));
@@ -1660,6 +1681,11 @@
buf = nbuf;
buflen = dlen;
}
+ if (dlen == 0) {
+ errno = EINVAL;
+ error = -1;
+ goto out;
+ }
again3:
if (read(ctx->control_fd, buf, dlen) != (ssize_t)dlen) {
if (errno == EAGAIN)
@@ -1669,28 +1695,23 @@
}
dp = buf;
de = dp + dlen;
+ if (*(dp - 1) != '\0') {
+ errno = EINVAL;
+ error = -1;
+ goto out;
+ }
while (dp < de) {
- if (dp + 6 >= de) /* _new and = something */
- break;
- if (dp[0] == 'n' && dp[3] == '_') {
- if (dp[1] == 'e' && dp[2] == 'w') {
- print = true;
+ for (i = 0; i < __arraycount(dumpskip); i++) {
+ skip = dumpskip[i];
+ if (strncmp(dp, skip, strlen(skip)) == 0)
+ break;
+ }
+ if (i == __arraycount(dumpskip)) {
+ if (strncmp(dp, "new_", 4) == 0)
dp += 4;
- } else if (dp[1] == 'd' &&
- isdigit((unsigned char)dp[2]))
- print = true;
- else
- print = false;
- } else
- print = false;
- while (dp < de && *dp != '\0') {
- if (print)
- putchar(*dp);
- dp++;
+ printf("%s\n", dp);
}
- if (print)
- putchar('\n');
- dp++;
+ dp += strlen(dp) + 1;
}
fflush(stdout);
if (nifaces != 1)
@@ -2107,16 +2128,11 @@
}
#endif
- logdebugx(PACKAGE "-" VERSION " starting");
+ loginfox(PACKAGE "-" VERSION " starting");
freopen(_PATH_DEVNULL, "r", stdin);
#ifdef PRIVSEP
- if (ps_init(&ctx) == -1) {
- if (errno != 0) {
- logerr("ps_init");
- goto exit_failure;
- }
- } else
+ if (ps_init(&ctx) == 0)
script_runchroot(&ctx, ifo->script);
#endif
@@ -2169,7 +2185,7 @@
}
#endif
-#ifdef BSD
+#if defined(BSD) && defined(INET6)
/* Disable the kernel RTADV sysctl as early as possible. */
if (ctx.options & DHCPCD_IPV6 && ctx.options & DHCPCD_IPV6RS)
if_disable_rtadv();
diff -r 3edbf943c0bb -r 91e36d242e44 external/bsd/dhcpcd/dist/src/if-bsd.c
--- a/external/bsd/dhcpcd/dist/src/if-bsd.c Thu Apr 02 12:38:54 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-bsd.c Mon Apr 13 15:42:20 2020 +0000
@@ -1037,7 +1037,7 @@
if (ia->addr_flags & IN6_IFF_TENTATIVE)
ifa.ifra_flags |= IN6_IFF_TENTATIVE;
#endif
-#ifdef IPV6_MANGETEMPADDR
+#ifdef IPV6_MANAGETEMPADDR
if (ia->flags & IPV6_AF_TEMPORARY)
ifa.ifra_flags |= IN6_IFF_TEMPORARY;
#endif
@@ -1524,6 +1524,8 @@
#ifdef INET6
if (sa->sa_family == AF_INET6)
ifa_setscope(satosin6(sa), ifp->index);
+#else
+ UNUSED(ifp);
#endif
cp = ctx->rt_missfilter + ctx->rt_missfilterlen;
@@ -1728,14 +1730,14 @@
ip6_temp_preferred_lifetime(__unused const char *ifname)
{
- return ND6_PRIV_PREFERRED_LIFETIME;
+ return TEMP_PREFERRED_LIFETIME;
}
int
ip6_temp_valid_lifetime(__unused const char *ifname)
{
- return ND6_PRIV_VALID_LIFETIME;
+ return TEMP_VALID_LIFETIME;
}
Home |
Main Index |
Thread Index |
Old Index