Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/dhcpcd/dist Import dhcpcd-10.0.2 with the follo...



details:   https://anonhg.NetBSD.org/src/rev/e6d3deaf797d
branches:  trunk
changeset: 378081:e6d3deaf797d
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/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/dhcpcd-embedded.c |   6 ++
 external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h |   4 +-
 external/bsd/dhcpcd/dist/src/eloop.c           |   4 +
 external/bsd/dhcpcd/dist/src/privsep-bpf.c     |   2 +-
 external/bsd/dhcpcd/dist/src/privsep-bsd.c     |  10 ++--
 external/bsd/dhcpcd/dist/src/privsep-control.c |  48 +++++++------------
 external/bsd/dhcpcd/dist/src/privsep-inet.c    |  26 +++++-----
 external/bsd/dhcpcd/dist/src/privsep-root.c    |  62 +++++++++++++------------
 external/bsd/dhcpcd/dist/src/privsep.h         |   4 +-
 14 files changed, 131 insertions(+), 113 deletions(-)

diffs (truncated from 784 to 300 lines):

diff -r b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/README.md
--- a/external/bsd/dhcpcd/dist/README.md        Wed Jul 19 10:22:15 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 b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/common.c
--- a/external/bsd/dhcpcd/dist/src/common.c     Wed Jul 19 10:22:15 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 b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/control.c
--- a/external/bsd/dhcpcd/dist/src/control.c    Wed Jul 19 10:22:15 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 b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Wed Jul 19 10:22:15 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 b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/src/dhcp-common.c        Wed Jul 19 10:22:15 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 b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.c    Wed Jul 19 10:22:15 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"
 "define 116 byte auto_configure\n"
 "define 117 array uint16 name_service_search\n"
 "define 118 ipaddress subnet_selection\n"
@@ -280,6 +281,8 @@ const char dhcpcd_embedded_conf[] =
 "embed ipaddress primary\n"
 "embed ipaddress secondary\n"
 "embed array domain domains\n"
+"define 147 domain dots_ri\n"
+"define 148 array ipaddress dots_address\n"
 "define 150 array ipaddress tftp_servers\n"
 "define 161 string mudurl\n"
 "define 208 binhex pxelinux_magic\n"
@@ -490,6 +493,9 @@ const char dhcpcd_embedded_conf[] =
 "encap 90 option\n"
 "encap 92 option\n"
 "define6 112 string mudurl\n"
+"define6 103 string captive_portal_uri\n"
+"define6 141 domain dots_ri\n"
+"define6 142 array ip6address dots_address\n"
 #endif
 "\0";
 
diff -r b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h
--- a/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h    Wed Jul 19 10:22:15 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd-embedded.h    Wed Jul 19 13:51:07 2023 +0000
@@ -30,9 +30,9 @@
 #define INITDEFINENDS         6
 #define INITDEFINE6S         14
 #else
-#define INITDEFINES         125
+#define INITDEFINES         128
 #define INITDEFINENDS         7
-#define INITDEFINE6S         69
+#define INITDEFINE6S         72
 #endif
 
 extern const char dhcpcd_embedded_conf[];
diff -r b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/eloop.c
--- a/external/bsd/dhcpcd/dist/src/eloop.c      Wed Jul 19 10:22:15 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/eloop.c      Wed Jul 19 13:51:07 2023 +0000
@@ -153,6 +153,10 @@
 #include <stdio.h>
 #endif
 
+#ifndef __arraycount
+#  define __arraycount(__x)       (sizeof(__x) / sizeof(__x[0]))
+#endif
+
 /*
  * Allow a backlog of signals.
  * If you use many eloops in the same process, they should all
diff -r b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/privsep-bpf.c
--- a/external/bsd/dhcpcd/dist/src/privsep-bpf.c        Wed Jul 19 10:22:15 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/privsep-bpf.c        Wed Jul 19 13:51:07 2023 +0000
@@ -328,7 +328,7 @@ ps_bpf_send(const struct interface *ifp,
        if (ia != NULL)
                psm.ps_id.psi_addr.psa_in_addr = *ia;
 
-       return ps_sendpsmdata(ctx, ctx->ps_root->psp_fd, &psm, data, len);
+       return ps_sendpsmdata(ctx, PS_ROOT_FD(ctx), &psm, data, len);
 }
 
 #ifdef ARP
diff -r b925a675b731 -r e6d3deaf797d external/bsd/dhcpcd/dist/src/privsep-bsd.c
--- a/external/bsd/dhcpcd/dist/src/privsep-bsd.c        Wed Jul 19 10:22:15 2023 +0000
+++ b/external/bsd/dhcpcd/dist/src/privsep-bsd.c        Wed Jul 19 13:51:07 2023 +0000
@@ -301,7 +301,7 @@ ps_root_ioctldom(struct dhcpcd_ctx *ctx,
     void *data, size_t len)
 {
 
-       if (ps_sendcmd(ctx, ctx->ps_root->psp_fd, domain,
+       if (ps_sendcmd(ctx, PS_ROOT_FD(ctx), domain,
            request, data, len) == -1)
                return -1;
        return ps_root_readerror(ctx, data, len);
@@ -327,7 +327,7 @@ ssize_t
 ps_root_route(struct dhcpcd_ctx *ctx, void *data, size_t len)



Home | Main Index | Thread Index | Old Index