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 Import dhcpcd-10.0.2 with the followi...



details:   https://anonhg.NetBSD.org/src/rev/29b3ae9aebef
branches:  roy
changeset: 378084:29b3ae9aebef
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Jul 19 13:51:07 2023 +0000

description:
Import dhcpcd-10.0.2 with the following changes:
 * BSD: When we get RTM_NEWADDR the interface must have IFF_UP
 * BSD: Fix non INET6 builds
 * DHCP: Don't enforce the message came port 67
 * privsep: Allow zero length messages through
 * dhcpcd: deal with HANGUP and EPIPE better
 * dhcpcd: Fix waitip address family
 * privsep: Check if we have a root process before sending it stuff
 * privsep: Only unlink control sockets if we created them
 * common: Improve valid_domain and check correct return
 * common: Allow hwaddr_ntoa to print an empty string
 * privsep: Send only what we have put in the buffer to script env

diffstat:

 external/bsd/dhcpcd/dist/README.md             |   4 +-
 external/bsd/dhcpcd/dist/src/bpf.c             |  11 ++++--
 external/bsd/dhcpcd/dist/src/common.c          |   8 +++-
 external/bsd/dhcpcd/dist/src/control.c         |  41 +++++++++++++++++--------
 external/bsd/dhcpcd/dist/src/defs.h            |   2 +-
 external/bsd/dhcpcd/dist/src/dhcp-common.c     |  23 ++++++--------
 external/bsd/dhcpcd/dist/src/dhcp.c            |   4 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c           |  11 +++---
 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c |   6 +++
 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h |   4 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.c          |   9 +++-
 external/bsd/dhcpcd/dist/src/eloop.c           |   4 ++
 external/bsd/dhcpcd/dist/src/if-bsd.c          |  31 ++++++++++--------
 external/bsd/dhcpcd/dist/src/if-options.c      |  11 +++++-
 external/bsd/dhcpcd/dist/src/script.c          |   2 +-
 15 files changed, 104 insertions(+), 67 deletions(-)

diffs (truncated from 521 to 300 lines):

diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/README.md
--- a/external/bsd/dhcpcd/dist/README.md        Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/README.md        Wed Jul 19 13:51:07 2023 +0000
@@ -92,5 +92,5 @@ dhcpcd-9 defaults the run directory to `
 ## ChangeLog
 We no longer supply a ChangeLog.
 However, you're more than welcome to read the
-[commit log](https://roy.marples.name/git/dhcpcd/log) and
-[archived release announcements](https://roy.marples.name/archives/dhcpcd-discuss/).
+[commit log](https://github.com/NetworkConfiguration/dhcpcd/commits) and
+[release announcements](https://github.com/NetworkConfiguration/dhcpcd/releases).
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/bpf.c
--- a/external/bsd/dhcpcd/dist/src/bpf.c        Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/bpf.c        Wed Jul 19 13:51:07 2023 +0000
@@ -610,16 +610,19 @@ static const struct bpf_insn bpf_bootp_b
 #define BPF_BOOTP_BASE_LEN     __arraycount(bpf_bootp_base)
 
 static const struct bpf_insn bpf_bootp_read[] = {
-       /* Make sure it's from and to the right port. */
-       BPF_STMT(BPF_LD + BPF_W + BPF_IND, 0),
-       BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, (BOOTPS << 16) + BOOTPC, 1, 0),
+       /* Make sure it's to the right port.
+        * RFC2131 makes no mention of enforcing a source port. */
+       BPF_STMT(BPF_LD + BPF_H + BPF_IND, offsetof(struct udphdr, uh_dport)),
+       BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, BOOTPC, 1, 0),
        BPF_STMT(BPF_RET + BPF_K, 0),
 };
 #define BPF_BOOTP_READ_LEN     __arraycount(bpf_bootp_read)
 
 #ifdef BIOCSETWF
 static const struct bpf_insn bpf_bootp_write[] = {
-       /* Make sure it's from and to the right port. */
+       /* Make sure it's from and to the right port.
+        * RFC2131 makes no mention of encforcing a source port,
+        * but dhcpcd does enforce it for sending. */
        BPF_STMT(BPF_LD + BPF_W + BPF_IND, 0),
        BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, (BOOTPC << 16) + BOOTPS, 1, 0),
        BPF_STMT(BPF_RET + BPF_K, 0),
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/common.c
--- a/external/bsd/dhcpcd/dist/src/common.c     Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/common.c     Wed Jul 19 13:51:07 2023 +0000
@@ -46,10 +46,15 @@ hwaddr_ntoa(const void *hwaddr, size_t h
        const unsigned char *hp, *ep;
        char *p;
 
-       if (buf == NULL || hwlen == 0)
+       /* Allow a hwlen of 0 to be an empty string. */
+       if (buf == NULL || buflen == 0) {
+               errno = ENOBUFS;
                return NULL;
+       }
 
        if (hwlen * 3 > buflen) {
+               /* We should still terminate the string just in case. */
+               buf[0] = '\0';
                errno = ENOBUFS;
                return NULL;
        }
@@ -57,7 +62,6 @@ hwaddr_ntoa(const void *hwaddr, size_t h
        hp = hwaddr;
        ep = hp + hwlen;
        p = buf;
-
        while (hp < ep) {
                if (hp != hwaddr)
                        *p ++= ':';
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/control.c
--- a/external/bsd/dhcpcd/dist/src/control.c    Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/control.c    Wed Jul 19 13:51:07 2023 +0000
@@ -94,22 +94,28 @@ control_free(struct fd_list *fd)
 }
 
 static void
+control_hangup(struct fd_list *fd)
+{
+
+#ifdef PRIVSEP
+       if (IN_PRIVSEP(fd->ctx)) {
+               if (ps_ctl_sendeof(fd) == -1)
+                       logerr(__func__);
+       }
+#endif
+       control_free(fd);
+}
+
+static void
 control_handle_read(struct fd_list *fd)
 {
        char buffer[1024];
        ssize_t bytes;
 
        bytes = read(fd->fd, buffer, sizeof(buffer) - 1);
-       if (bytes == -1)
+       if (bytes == -1) {
                logerr(__func__);
-       if (bytes == -1 || bytes == 0) {
-#ifdef PRIVSEP
-               if (IN_PRIVSEP(fd->ctx)) {
-                       if (ps_ctl_sendeof(fd) == -1)
-                               logerr(__func__);
-               }
-#endif
-               control_free(fd);
+               control_hangup(fd);
                return;
        }
 
@@ -158,8 +164,11 @@ control_handle_write(struct fd_list *fd)
        }
 
        if (writev(fd->fd, iov, iov_len) == -1) {
-               logerr("%s: write", __func__);
-               control_free(fd);
+               if (errno != EPIPE && errno != ENOTCONN) {
+                       // We don't get ELE_HANGUP for some reason
+                       logerr("%s: write", __func__);
+               }
+               control_hangup(fd);
                return;
        }
 
@@ -194,13 +203,15 @@ control_handle_data(void *arg, unsigned 
 {
        struct fd_list *fd = arg;
 
-       if (!(events & (ELE_READ | ELE_WRITE)))
+       if (!(events & (ELE_READ | ELE_WRITE | ELE_HANGUP)))
                logerrx("%s: unexpected event 0x%04x", __func__, events);
 
        if (events & ELE_WRITE && !(events & ELE_HANGUP))
                control_handle_write(fd);
        if (events & ELE_READ)
                control_handle_read(fd);
+       if (events & ELE_HANGUP)
+               control_hangup(fd);
 }
 
 void
@@ -487,9 +498,11 @@ control_stop(struct dhcpcd_ctx *ctx)
 
 #ifdef PRIVSEP
        if (IN_PRIVSEP_SE(ctx)) {
-               if (ps_root_unlink(ctx, ctx->control_sock) == -1)
+               if (ctx->control_sock[0] != '\0' &&
+                   ps_root_unlink(ctx, ctx->control_sock) == -1)
                        retval = -1;
-               if (ps_root_unlink(ctx, ctx->control_sock_unpriv) == -1)
+               if (ctx->control_sock_unpriv[0] != '\0' &&
+                   ps_root_unlink(ctx, ctx->control_sock_unpriv) == -1)
                        retval = -1;
                return retval;
        } else if (ctx->options & DHCPCD_FORKED)
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Wed Jul 19 13:51:07 2023 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "10.0.1"
+#define VERSION                        "10.0.2"
 
 #ifndef PRIVSEP_USER
 # define PRIVSEP_USER          "_" PACKAGE
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/src/dhcp-common.c        Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp-common.c        Wed Jul 19 13:51:07 2023 +0000
@@ -413,26 +413,23 @@ decode_rfc1035(char *out, size_t len, co
 }
 
 /* Check for a valid name as per RFC952 and RFC1123 section 2.1 */
-static int
+static ssize_t
 valid_domainname(char *lbl, int type)
 {
-       char *slbl, *lst;
+       char *slbl = lbl, *lst = NULL;
        unsigned char c;
-       int start, len, errset;
+       int len = 0;
+       bool start = true, errset = false;
 
        if (lbl == NULL || *lbl == '\0') {
                errno = EINVAL;
                return 0;
        }
 
-       slbl = lbl;
-       lst = NULL;
-       start = 1;
-       len = errset = 0;
        for (;;) {
                c = (unsigned char)*lbl++;
                if (c == '\0')
-                       return 1;
+                       return lbl - slbl - 1;
                if (c == ' ') {
                        if (lbl - 1 == slbl) /* No space at start */
                                break;
@@ -440,7 +437,7 @@ valid_domainname(char *lbl, int type)
                                break;
                        /* Skip to the next label */
                        if (!start) {
-                               start = 1;
+                               start = true;
                                lst = lbl - 1;
                        }
                        if (len)
@@ -459,13 +456,13 @@ valid_domainname(char *lbl, int type)
                {
                        if (++len > NS_MAXLABEL) {
                                errno = ERANGE;
-                               errset = 1;
+                               errset = true;
                                break;
                        }
                } else
                        break;
                if (start)
-                       start = 0;
+                       start = false;
        }
 
        if (!errset)
@@ -473,7 +470,7 @@ valid_domainname(char *lbl, int type)
        if (lst) {
                /* At least one valid domain, return it */
                *lst = '\0';
-               return 1;
+               return lst - slbl;
        }
        return 0;
 }
@@ -665,7 +662,7 @@ print_option(FILE *fp, const char *prefi
                        goto err;
                if (sl == 0)
                        goto done;
-               if (valid_domainname(domain, opt->type) == -1)
+               if (!valid_domainname(domain, opt->type))
                        goto err;
                return efprintf(fp, "%s", domain);
        }
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Wed Jul 19 13:51:07 2023 +0000
@@ -3436,8 +3436,8 @@ is_packet_udp_bootp(void *packet, size_t
        if (ip_hlen + ntohs(udp.uh_ulen) > plen)
                return false;
 
-       /* Check it's to and from the right ports. */
-       if (udp.uh_dport != htons(BOOTPC) || udp.uh_sport != htons(BOOTPS))
+       /* Check it's to the right port. */
+       if (udp.uh_dport != htons(BOOTPC))
                return false;
 
        return true;
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Wed Jul 19 13:51:07 2023 +0000
@@ -1667,10 +1667,7 @@ dhcp6_startinform(void *arg)
 
        ifp = arg;
        state = D6_STATE(ifp);
-       if (state->new_start || (state->new == NULL && !state->failed))
-               llevel = LOG_INFO;
-       else
-               llevel = LOG_DEBUG;
+       llevel = state->failed ? LOG_DEBUG : LOG_INFO;
        logmessage(llevel, "%s: requesting DHCPv6 information", ifp->name);
        state->state = DH6S_INFORM;
        state->RTC = 0;
@@ -3069,7 +3066,7 @@ dhcp6_bind(struct interface *ifp, const 
        int loglevel;
        struct timespec now;
 
-       if (state->state == DH6S_RENEW && !state->new_start) {
+       if (state->state == DH6S_RENEW) {
                loglevel = LOG_DEBUG;
                TAILQ_FOREACH(ia, &state->addrs, next) {
                        if (ia->flags & IPV6_AF_NEW) {
@@ -3968,8 +3965,10 @@ dhcp6_start(struct interface *ifp, enum 
                        {
                                /* We don't want log spam when the RA
                                 * has just adjusted it's prefix times. */
-                               if (state->state != DH6S_INFORMED)
+                               if (state->state != DH6S_INFORMED) {
                                        state->new_start = true;
+                                       state->failed = false;
+                               }
                                dhcp6_startinform(ifp);
                        }
                        break;
diff -r 421ee693f29e -r 29b3ae9aebef external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c    Tue Jun 27 17:04:19 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c    Wed Jul 19 13:51:07 2023 +0000
@@ -235,6 +235,7 @@ const char dhcpcd_embedded_conf[] =
 "define 100 string posix_timezone\n"
 "define 101 string tzdb_timezone\n"
 "define 108 uint32 ipv6_only_preferred\n"
+"define 114 string captive_portal_uri\n"



Home | Main Index | Thread Index | Old Index