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/src Update to dhcpcd-9.1.1 with the...



details:   https://anonhg.NetBSD.org/src/rev/eec89455c313
branches:  trunk
changeset: 934031:eec89455c313
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Jun 04 13:07:12 2020 +0000

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

 * Restore dumping leases from stdin
 * auth: Only accept RECONFIGURE messages from LL addresses
 * auth: Access the RDM monotonic counter file via privsep
 * ARP: call arp_announced() when cancelling it
 * BSD: fwip(4) interfaces are now ignored by default
 * privsep: Ensure IPC buffers are large enough to carry messages
 * privsep: Only open RAW sockets for the needed protocols
 * privsep: Fix indirect ioctls returning data
 * privsep: wait for processes on SIGCHLD rather than when sent a STOP cmd
 * eloop: just use ppoll/pollts(2), falling back to pselect(2)

diffstat:

 external/bsd/dhcpcd/dist/src/arp.c          |    4 +-
 external/bsd/dhcpcd/dist/src/auth.c         |   74 ++-
 external/bsd/dhcpcd/dist/src/auth.h         |    6 +-
 external/bsd/dhcpcd/dist/src/defs.h         |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp.h         |    1 +
 external/bsd/dhcpcd/dist/src/dhcp6.h        |    3 +-
 external/bsd/dhcpcd/dist/src/eloop.c        |  549 ++++-----------------------
 external/bsd/dhcpcd/dist/src/eloop.h        |    4 +-
 external/bsd/dhcpcd/dist/src/privsep-bpf.c  |    2 +-
 external/bsd/dhcpcd/dist/src/privsep-bsd.c  |   54 +-
 external/bsd/dhcpcd/dist/src/privsep-inet.c |    4 +-
 external/bsd/dhcpcd/dist/src/privsep-root.c |  110 ++++-
 external/bsd/dhcpcd/dist/src/privsep-root.h |    3 +-
 external/bsd/dhcpcd/dist/src/privsep.h      |    1 +
 external/bsd/dhcpcd/dist/src/script.h       |    1 +
 15 files changed, 276 insertions(+), 542 deletions(-)

diffs (truncated from 1464 to 300 lines):

diff -r c4266cd96a7f -r eec89455c313 external/bsd/dhcpcd/dist/src/arp.c
--- a/external/bsd/dhcpcd/dist/src/arp.c        Thu Jun 04 11:28:00 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/arp.c        Thu Jun 04 13:07:12 2020 +0000
@@ -466,11 +466,13 @@
                            a2);
                        if (r == -1)
                                logerr(__func__);
-                       else if (r != 0)
+                       else if (r != 0) {
                                logdebugx("%s: ARP announcement "
                                    "of %s cancelled",
                                    a2->iface->name,
                                    inet_ntoa(a2->addr));
+                               arp_announced(a2);
+                       }
                }
        }
 
diff -r c4266cd96a7f -r eec89455c313 external/bsd/dhcpcd/dist/src/auth.c
--- a/external/bsd/dhcpcd/dist/src/auth.c       Thu Jun 04 11:28:00 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/auth.c       Thu Jun 04 13:07:12 2020 +0000
@@ -27,6 +27,8 @@
  */
 
 #include <sys/file.h>
+#include <sys/stat.h>
+
 #include <errno.h>
 #include <fcntl.h>
 #include <inttypes.h>
@@ -42,6 +44,7 @@
 #include "dhcp.h"
 #include "dhcp6.h"
 #include "dhcpcd.h"
+#include "privsep-root.h"
 
 #ifdef HAVE_HMAC_H
 #include <hmac.h>
@@ -408,11 +411,11 @@
        return t;
 }
 
-static uint64_t
-get_next_rdm_monotonic_counter(struct auth *auth)
+int
+auth_get_rdm_monotonic(uint64_t *rdm)
 {
        FILE *fp;
-       uint64_t rdm;
+       int err;
 #ifdef LOCK_EX
        int flocked;
 #endif
@@ -420,41 +423,43 @@
        fp = fopen(RDM_MONOFILE, "r+");
        if (fp == NULL) {
                if (errno != ENOENT)
-                       return ++auth->last_replay; /* report error? */
+                       return -1;
                fp = fopen(RDM_MONOFILE, "w");
                if (fp == NULL)
-                       return ++auth->last_replay; /* report error? */
+                       return -1;
+               if (chmod(RDM_MONOFILE, 0400) == -1) {
+                       fclose(fp);
+                       unlink(RDM_MONOFILE);
+                       return -1;
+               }
 #ifdef LOCK_EX
                flocked = flock(fileno(fp), LOCK_EX);
 #endif
-               rdm = 0;
+               *rdm = 0;
        } else {
 #ifdef LOCK_EX
                flocked = flock(fileno(fp), LOCK_EX);
 #endif
-               if (fscanf(fp, "0x%016" PRIu64, &rdm) != 1)
-                       rdm = 0; /* truncated? report error? */
+               if (fscanf(fp, "0x%016" PRIu64, rdm) != 1) {
+                       fclose(fp);
+                       return -1;
+               }
        }
 
-       rdm++;
+       (*rdm)++;
        if (fseek(fp, 0, SEEK_SET) == -1 ||
            ftruncate(fileno(fp), 0) == -1 ||
-           fprintf(fp, "0x%016" PRIu64 "\n", rdm) != 19 ||
+           fprintf(fp, "0x%016" PRIu64 "\n", *rdm) != 19 ||
            fflush(fp) == EOF)
-       {
-               if (!auth->last_replay_set) {
-                       auth->last_replay = rdm;
-                       auth->last_replay_set = 1;
-               } else
-                       rdm = ++auth->last_replay;
-               /* report error? */
-       }
+               err = -1;
+       else
+               err = 0;
 #ifdef LOCK_EX
        if (flocked == 0)
                flock(fileno(fp), LOCK_UN);
 #endif
        fclose(fp);
-       return rdm;
+       return err;
 }
 
 #define        NTP_EPOCH       2208988800U     /* 1970 - 1900 in seconds */
@@ -476,11 +481,29 @@
 }
 
 static uint64_t
-get_next_rdm_monotonic(struct auth *auth)
+get_next_rdm_monotonic(struct dhcpcd_ctx *ctx, struct auth *auth)
 {
+#ifndef PRIVSEP
+       UNUSED(ctx);
+#endif
+
+       if (auth->options & DHCPCD_AUTH_RDM_COUNTER) {
+               uint64_t rdm;
+               int err;
 
-       if (auth->options & DHCPCD_AUTH_RDM_COUNTER)
-               return get_next_rdm_monotonic_counter(auth);
+#ifdef PRIVSEP
+               if (IN_PRIVSEP(ctx)) {
+
+                       err = ps_root_getauthrdm(ctx, &rdm);
+               } else
+#endif
+                       err = auth_get_rdm_monotonic(&rdm);
+               if (err == -1)
+                       return ++auth->last_replay;
+
+               auth->last_replay = rdm;
+               return rdm;
+       }
        return get_next_rdm_monotonic_clock(auth);
 }
 
@@ -495,7 +518,8 @@
  * data and dlen refer to the authentication option within the message.
  */
 ssize_t
-dhcp_auth_encode(struct auth *auth, const struct token *t,
+dhcp_auth_encode(struct dhcpcd_ctx *ctx, struct auth *auth,
+    const struct token *t,
     void *vm, size_t mlen, int mp, int mt,
     void *vdata, size_t dlen)
 {
@@ -611,11 +635,11 @@
                *data++ = auth->rdm;
                switch (auth->rdm) {
                case AUTH_RDM_MONOTONIC:
-                       rdm = get_next_rdm_monotonic(auth);
+                       rdm = get_next_rdm_monotonic(ctx, auth);
                        break;
                default:
                        /* This block appeases gcc, clang doesn't need it */
-                       rdm = get_next_rdm_monotonic(auth);
+                       rdm = get_next_rdm_monotonic(ctx, auth);
                        break;
                }
                rdm = htonll(rdm);
diff -r c4266cd96a7f -r eec89455c313 external/bsd/dhcpcd/dist/src/auth.h
--- a/external/bsd/dhcpcd/dist/src/auth.h       Thu Jun 04 11:28:00 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/auth.h       Thu Jun 04 13:07:12 2020 +0000
@@ -90,7 +90,11 @@
     const void *, size_t, int, int,
     const void *, size_t);
 
-ssize_t dhcp_auth_encode(struct auth *, const struct token *,
+struct dhcpcd_ctx;
+ssize_t dhcp_auth_encode(struct dhcpcd_ctx *, struct auth *,
+    const struct token *,
     void *, size_t, int, int,
     void *, size_t);
+
+int auth_get_rdm_monotonic(uint64_t *rdm);
 #endif
diff -r c4266cd96a7f -r eec89455c313 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Thu Jun 04 11:28:00 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Thu Jun 04 13:07:12 2020 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "9.1.0"
+#define VERSION                        "9.1.1"
 
 #ifndef PRIVSEP_USER
 # define PRIVSEP_USER          "_" PACKAGE
diff -r c4266cd96a7f -r eec89455c313 external/bsd/dhcpcd/dist/src/dhcp.h
--- a/external/bsd/dhcpcd/dist/src/dhcp.h       Thu Jun 04 11:28:00 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.h       Thu Jun 04 13:07:12 2020 +0000
@@ -276,6 +276,7 @@
 void dhcp_reboot_newopts(struct interface *, unsigned long long);
 void dhcp_close(struct interface *);
 void dhcp_free(struct interface *);
+int dhcp_dump(struct interface *);
 #endif /* INET */
 
 #endif /* DHCP_H */
diff -r c4266cd96a7f -r eec89455c313 external/bsd/dhcpcd/dist/src/dhcp6.h
--- a/external/bsd/dhcpcd/dist/src/dhcp6.h      Thu Jun 04 11:28:00 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.h      Thu Jun 04 13:07:12 2020 +0000
@@ -243,9 +243,10 @@
     const struct dhcp6_message *, size_t);
 void dhcp6_free(struct interface *);
 void dhcp6_handleifa(int, struct ipv6_addr *, pid_t);
-int dhcp6_dadcompleted(const struct interface *);
+bool dhcp6_dadcompleted(const struct interface *);
 void dhcp6_abort(struct interface *);
 void dhcp6_drop(struct interface *, const char *);
+int dhcp6_dump(struct interface *);
 #endif /* DHCP6 */
 
 #endif /* DHCP6_H */
diff -r c4266cd96a7f -r eec89455c313 external/bsd/dhcpcd/dist/src/eloop.c
--- a/external/bsd/dhcpcd/dist/src/eloop.c      Thu Jun 04 11:28:00 2020 +0000
+++ b/external/bsd/dhcpcd/dist/src/eloop.c      Thu Jun 04 13:07:12 2020 +0000
@@ -26,60 +26,30 @@
  * SUCH DAMAGE.
  */
 
-#if (defined(__unix__) || defined(unix)) && !defined(USG)
-#include <sys/param.h>
-#endif
 #include <sys/time.h>
 
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
+#include <poll.h>
 #include <signal.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
-/* config.h should define HAVE_KQUEUE, HAVE_EPOLL, etc. */
+/* config.h should define HAVE_PPOLL, etc. */
 #if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_H)
 #include "config.h"
 #endif
 
-/* Attempt to autodetect kqueue or epoll.
- * Failing that, fall back to pselect. */
-#if !defined(HAVE_KQUEUE) && !defined(HAVE_EPOLL) && !defined(HAVE_PSELECT) && \
-    !defined(HAVE_POLLTS) && !defined(HAVE_PPOLL)
-#if defined(BSD)
-/* Assume BSD has a working sys/queue.h and kqueue(2) interface. */
-#define HAVE_SYS_QUEUE_H
-#define HAVE_KQUEUE
-#define WARN_SELECT
-#elif defined(__linux__) || defined(__sun)
-/* Assume Linux and Solaris have a working epoll(3) interface. */
-#define HAVE_EPOLL
-#define WARN_SELECT
-#else
-/* pselect(2) is a POSIX standard. */
+#if defined(HAVE_PPOLL)
+#elif defined(HAVE_POLLTS)
+#define ppoll pollts
+#elif !defined(HAVE_PSELECT)
+#pragma message("Compiling eloop with pselect(2) support.")
 #define HAVE_PSELECT
-#define WARN_SELECT
-#endif
-#endif
-
-/* pollts and ppoll require poll.
- * pselect is wrapped in a pollts/ppoll style interface
- * and as such require poll as well. */
-#if defined(HAVE_PSELECT) || defined(HAVE_POLLTS) || defined(HAVE_PPOLL)
-#ifndef HAVE_POLL
-#define HAVE_POLL
-#endif
-#if defined(HAVE_POLLTS)
-#define POLLTS pollts
-#elif defined(HAVE_PPOLL)
-#define POLLTS ppoll
-#else
-#define POLLTS eloop_pollts
-#define ELOOP_NEED_POLLTS
-#endif
+#define ppoll eloop_ppoll
 #endif
 
 #include "eloop.h"
@@ -95,42 +65,9 @@
 #endif
 #endif
 



Home | Main Index | Thread Index | Old Index