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.3.3 with the follo...



details:   https://anonhg.NetBSD.org/src/rev/b876d7d6636f
branches:  roy
changeset: 946178:b876d7d6636f
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Nov 20 13:23:38 2020 +0000

description:
Update to dhcpcd-9.3.3 with the following changes:

 * dhcpcd: Don't create a launcher process if keeping in foreground
 * dhcpcd: Add --noconfigure option
 * control: Create an unpriv socket for non master mode
 * options: Don't log unknown ones when printing pidfile location

diffstat:

 external/bsd/dhcpcd/dist/hooks/15-timezone    |   2 +-
 external/bsd/dhcpcd/dist/hooks/20-resolv.conf |  10 +++--
 external/bsd/dhcpcd/dist/hooks/50-ntp.conf    |  10 +++--
 external/bsd/dhcpcd/dist/hooks/50-ypbind.in   |   4 +-
 external/bsd/dhcpcd/dist/src/control.c        |  36 ++++++++++++----------
 external/bsd/dhcpcd/dist/src/defs.h           |   7 +---
 external/bsd/dhcpcd/dist/src/dhcp.c           |  42 +++++++++++++++++++++++++-
 external/bsd/dhcpcd/dist/src/dhcp6.c          |  14 +++++++-
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in      |  23 ++++++++++++++-
 external/bsd/dhcpcd/dist/src/dhcpcd.c         |   9 +++++-
 external/bsd/dhcpcd/dist/src/dhcpcd.h         |   1 +
 external/bsd/dhcpcd/dist/src/if-options.c     |  24 ++++++++++++++-
 external/bsd/dhcpcd/dist/src/if-options.h     |   4 +-
 external/bsd/dhcpcd/dist/src/ipv4ll.c         |  18 ++++++++---
 external/bsd/dhcpcd/dist/src/ipv6.c           |   3 +
 external/bsd/dhcpcd/dist/src/ipv6nd.c         |   7 +++-
 external/bsd/dhcpcd/dist/src/route.c          |   3 +-
 external/bsd/dhcpcd/dist/src/script.c         |   3 +
 18 files changed, 172 insertions(+), 48 deletions(-)

diffs (truncated from 645 to 300 lines):

diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/hooks/15-timezone
--- a/external/bsd/dhcpcd/dist/hooks/15-timezone        Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/15-timezone        Fri Nov 20 13:23:38 2020 +0000
@@ -42,6 +42,6 @@
        ;;
 esac
 
-if $if_up; then
+if $if_configured && $if_up; then
        set_zoneinfo
 fi
diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/hooks/20-resolv.conf
--- a/external/bsd/dhcpcd/dist/hooks/20-resolv.conf     Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/20-resolv.conf     Fri Nov 20 13:23:38 2020 +0000
@@ -198,8 +198,10 @@
        ;;
 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
diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/hooks/50-ntp.conf
--- a/external/bsd/dhcpcd/dist/hooks/50-ntp.conf        Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/50-ntp.conf        Fri Nov 20 13:23:38 2020 +0000
@@ -135,8 +135,10 @@
 ;;
 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
diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/hooks/50-ypbind.in
--- a/external/bsd/dhcpcd/dist/hooks/50-ypbind.in       Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/50-ypbind.in       Fri Nov 20 13:23:38 2020 +0000
@@ -68,7 +68,9 @@
        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
diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/src/control.c
--- a/external/bsd/dhcpcd/dist/src/control.c    Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/control.c    Fri Nov 20 13:23:38 2020 +0000
@@ -274,9 +274,11 @@
 }
 
 static int
-make_path(char *path, size_t len, const char *ifname, sa_family_t family)
+make_path(char *path, size_t len, const char *ifname, sa_family_t family,
+    bool unpriv)
 {
        const char *per;
+       const char *sunpriv;
 
        switch(family) {
        case AF_INET:
@@ -289,8 +291,13 @@
                per = "";
                break;
        }
+       if (unpriv)
+               sunpriv = ifname ? ".unpriv" : "unpriv.";
+       else
+               sunpriv = "";
        return snprintf(path, len, CONTROLSOCKET,
-           ifname ? ifname : "", ifname ? per : "", ifname ? "." : "");
+           ifname ? ifname : "", ifname ? per : "",
+           sunpriv, ifname ? "." : "");
 }
 
 static int
@@ -303,10 +310,7 @@
                return -1;
        memset(sa, 0, sizeof(*sa));
        sa->sun_family = AF_UNIX;
-       if (unpriv)
-               strlcpy(sa->sun_path, UNPRIVSOCKET, sizeof(sa->sun_path));
-       else
-               make_path(sa->sun_path, sizeof(sa->sun_path), ifname, family);
+       make_path(sa->sun_path, sizeof(sa->sun_path), ifname, family, unpriv);
        return fd;
 }
 
@@ -346,9 +350,12 @@
        }
 #endif
 
-       if ((fmode & S_UNPRIV) != S_UNPRIV)
+       if ((fmode & S_PRIV) == S_PRIV)
                strlcpy(ctx->control_sock, sa.sun_path,
                    sizeof(ctx->control_sock));
+       else
+               strlcpy(ctx->control_sock_unpriv, sa.sun_path,
+                   sizeof(ctx->control_sock_unpriv));
        return fd;
 }
 
@@ -360,7 +367,9 @@
 #ifdef PRIVSEP
        if (IN_PRIVSEP_SE(ctx)) {
                make_path(ctx->control_sock, sizeof(ctx->control_sock),
-                   ifname, family);
+                   ifname, family, false);
+               make_path(ctx->control_sock_unpriv, sizeof(ctx->control_sock),
+                   ifname, family, true);
                return 0;
        }
 #endif
@@ -371,11 +380,7 @@
        ctx->control_fd = fd;
        eloop_event_add(ctx->eloop, fd, control_handle, ctx);
 
-       if (ifname == NULL &&
-           (fd = control_start1(ctx, NULL, AF_UNSPEC, S_UNPRIV)) != -1)
-       {
-               /* We must be in master mode, so create an unprivileged socket
-                * to allow normal users to learn the status of dhcpcd. */
+       if ((fd = control_start1(ctx, ifname, family, S_UNPRIV)) != -1) {
                ctx->control_unpriv_fd = fd;
                eloop_event_add(ctx->eloop, fd, control_handle_unpriv, ctx);
        }
@@ -414,8 +419,7 @@
        if (IN_PRIVSEP_SE(ctx)) {
                if (ps_root_unlink(ctx, ctx->control_sock) == -1)
                        retval = -1;
-               if (ctx->options & DHCPCD_MASTER &&
-                   control_unlink(ctx, UNPRIVSOCKET) == -1)
+               if (ps_root_unlink(ctx, ctx->control_sock_unpriv) == -1)
                        retval = -1;
                return retval;
        } else if (ctx->options & DHCPCD_FORKED)
@@ -434,7 +438,7 @@
                eloop_event_delete(ctx->eloop, ctx->control_unpriv_fd);
                close(ctx->control_unpriv_fd);
                ctx->control_unpriv_fd = -1;
-               if (control_unlink(ctx, UNPRIVSOCKET) == -1)
+               if (control_unlink(ctx, ctx->control_sock_unpriv) == -1)
                        retval = -1;
        }
 
diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Fri Nov 20 13:23:38 2020 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "9.3.2"
+#define VERSION                        "9.3.3"
 
 #ifndef PRIVSEP_USER
 # define PRIVSEP_USER          "_" PACKAGE
@@ -60,10 +60,7 @@
 # define PIDFILE               RUNDIR "/%s%s%spid"
 #endif
 #ifndef CONTROLSOCKET
-# define CONTROLSOCKET         RUNDIR "/%s%s%ssock"
-#endif
-#ifndef UNPRIVSOCKET
-# define UNPRIVSOCKET          RUNDIR "/unpriv.sock"
+# define CONTROLSOCKET         RUNDIR "/%s%s%s%ssock"
 #endif
 #ifndef RDM_MONOFILE
 # define RDM_MONOFILE          DBDIR "/rdm_monotonic"
diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Fri Nov 20 13:23:38 2020 +0000
@@ -2346,6 +2346,24 @@
 
        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 @@
        /* 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 @@
                return;
 
        dhcp_closeinet(ifp);
-
 #ifdef PRIVSEP
        if (IN_PRIVSEP_SE(ctx)) {
                if (ps_inet_openbootp(state->addr) == -1)
@@ -2805,7 +2823,13 @@
        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 @@
 #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);
diff -r 47a2059e9efb -r b876d7d6636f external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Sun Nov 01 14:23:02 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Fri Nov 20 13:23:38 2020 +0000
@@ -2877,6 +2877,8 @@
        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 @@
        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 @@
                        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);
+               }



Home | Main Index | Thread Index | Old Index