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-6.5.0 with the follow...



details:   https://anonhg.NetBSD.org/src/rev/37623fcb13f9
branches:  trunk
changeset: 802876:37623fcb13f9
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Oct 06 18:20:16 2014 +0000

description:
Import dhcpcd-6.5.0 with the following changes:

  *  Fix an unaligned access error on BeagleBone Black with FreeBSD.
     Thanks to Guy Yur for the patch.
  *  Remove the fast loop trying to up an interface which does not
     report carrier.
  *  Remove vis based encoding - instead validate against option type and
     stop at invalid [1]
     This removes all shell escaped encoding - dhcpcd will assume that IF
     the --script option is a shell, it will quote variables correctly.
     The stock dhcpcd-run-hooks does.
  *  dhcpcd -V now prints how the variables will be decoded.
  *  Changed some options in dhcpcd-definitions.conf to more sensible defaults.
  *  Don't daemonise on delegated address dad.
  *  Don't drop delegated reject route when forking.
  *  Fix IPv6 handling of link-local addresses on KAME stacks.
  *  Work on OpenBSD-5.6 without any special interface setup needed.
  *  Callout to handlecarrier when we don't have real carrier support and
     rely on looking at IFF_UP and IFF_RUNNING.
     This allows our hooks to know that dhcpcd thinks we have a carrier or not.

[1] DHCP option encodings defined in dhcpcd-definitions.conf
  *  domain (RFC3397)/dname (string) is strict domain name allowance
     (ie, [alnum] with _- (but not at the start or end))
  *  string is now printable ascii (1-127) until invalid
  *  ascii is all ascii (1-127) until invalid
  *  raw is all chars (1-255) until NUL
  *  binhex is a hex representation of the option including embedded NULs
  *  ssid is still escpaed octal because it's expected to be human readable
     AND can technically be all NUL
  *  everything else has strict option -> value encoding

diffstat:

 external/bsd/dhcpcd/dist/config.h                |    3 +-
 external/bsd/dhcpcd/dist/control.c               |    6 +-
 external/bsd/dhcpcd/dist/defs.h                  |    4 +-
 external/bsd/dhcpcd/dist/dev.h                   |    6 +-
 external/bsd/dhcpcd/dist/dhcp-common.c           |  284 ++++++++++++++++++----
 external/bsd/dhcpcd/dist/dhcp-common.h           |    9 +-
 external/bsd/dhcpcd/dist/dhcp6.c                 |  111 +++++---
 external/bsd/dhcpcd/dist/dhcp6.h                 |    4 +-
 external/bsd/dhcpcd/dist/dhcpcd-definitions.conf |   48 ++-
 external/bsd/dhcpcd/dist/dhcpcd-embedded.c       |   46 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test    |    4 +-
 external/bsd/dhcpcd/dist/if.c                    |   22 +-
 external/bsd/dhcpcd/dist/if.h                    |    4 +-
 external/bsd/dhcpcd/dist/ipv6.c                  |    4 +-
 14 files changed, 381 insertions(+), 174 deletions(-)

diffs (truncated from 1231 to 300 lines):

diff -r d3e3a29494e4 -r 37623fcb13f9 external/bsd/dhcpcd/dist/config.h
--- a/external/bsd/dhcpcd/dist/config.h Mon Oct 06 14:42:08 2014 +0000
+++ b/external/bsd/dhcpcd/dist/config.h Mon Oct 06 18:20:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.1.1.27 2014/09/27 01:14:55 roy Exp $ */
+/* $NetBSD: config.h,v 1.1.1.28 2014/10/06 18:20:19 roy Exp $ */
 
 /* netbsd */
 #define SYSCONFDIR     "/etc"
@@ -7,7 +7,6 @@
 #define LIBEXECDIR     "/libexec"
 #define DBDIR          "/var/db"
 #define RUNDIR         "/var/run"
-#define HAVE_VIS_H
 #define HAVE_SPAWN_H
 #define HAVE_MD5_H
 #define SHA2_H         <sha2.h>
diff -r d3e3a29494e4 -r 37623fcb13f9 external/bsd/dhcpcd/dist/control.c
--- a/external/bsd/dhcpcd/dist/control.c        Mon Oct 06 14:42:08 2014 +0000
+++ b/external/bsd/dhcpcd/dist/control.c        Mon Oct 06 18:20:16 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: control.c,v 1.1.1.8 2014/09/16 22:23:17 roy Exp $");
+ __RCSID("$NetBSD: control.c,v 1.1.1.9 2014/10/06 18:20:16 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -301,6 +301,9 @@
        int retval = 0;
        struct fd_list *l;
 
+       if (ctx->options & DHCPCD_FORKED)
+               goto freeit;
+
        if (ctx->control_fd == -1)
                return 0;
        eloop_event_delete(ctx->eloop, ctx->control_fd, 0);
@@ -317,6 +320,7 @@
                        retval = -1;
        }
 
+freeit:
        while ((l = TAILQ_FIRST(&ctx->control_fds))) {
                TAILQ_REMOVE(&ctx->control_fds, l, next);
                eloop_event_delete(ctx->eloop, l->fd, 0);
diff -r d3e3a29494e4 -r 37623fcb13f9 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Mon Oct 06 14:42:08 2014 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Mon Oct 06 18:20:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.1.1.45 2014/09/27 10:58:10 roy Exp $ */
+/* $NetBSD: defs.h,v 1.1.1.46 2014/10/06 18:20:19 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.4.7"
+#define VERSION                        "6.5.0"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r d3e3a29494e4 -r 37623fcb13f9 external/bsd/dhcpcd/dist/dev.h
--- a/external/bsd/dhcpcd/dist/dev.h    Mon Oct 06 14:42:08 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dev.h    Mon Oct 06 18:20:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dev.h,v 1.1.1.4 2014/06/14 20:51:09 roy Exp $ */
+/* $NetBSD: dev.h,v 1.1.1.5 2014/10/06 18:20:19 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -51,12 +51,12 @@
 int dev_initialized(struct dhcpcd_ctx *, const char *);
 int dev_listening(struct dhcpcd_ctx *);
 int dev_start(struct dhcpcd_ctx *);
-void dev_stop(struct dhcpcd_ctx *, int);
+void dev_stop(struct dhcpcd_ctx *);
 #else
 #define dev_initialized(a, b) (1)
 #define dev_listening(a) (0)
 #define dev_start(a) {}
-#define dev_stop(a, b) {}
+#define dev_stop(a) {}
 #endif
 
 #endif
diff -r d3e3a29494e4 -r 37623fcb13f9 external/bsd/dhcpcd/dist/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/dhcp-common.c    Mon Oct 06 14:42:08 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp-common.c    Mon Oct 06 18:20:16 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.9 2014/09/27 01:14:51 roy Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.10 2014/10/06 18:20:17 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -40,16 +40,70 @@
 
 #include "config.h"
 
-#ifdef HAVE_VIS_H
-#include <vis.h>
-#endif
-
 #include "common.h"
 #include "dhcp-common.h"
 #include "dhcp.h"
 #include "if.h"
 #include "ipv6.h"
 
+void
+dhcp_print_option_encoding(const struct dhcp_opt *opt, int cols)
+{
+
+       while (cols < 40) {
+               putchar(' ');
+               cols++;
+       }
+       putchar('\t');
+       if (opt->type & EMBED)
+               printf(" embed");
+       if (opt->type & ENCAP)
+               printf(" encap");
+       if (opt->type & INDEX)
+               printf(" index");
+       if (opt->type & ARRAY)
+               printf(" array");
+       if (opt->type & UINT8)
+               printf(" byte");
+       else if (opt->type & UINT16)
+               printf(" uint16");
+       else if (opt->type & SINT16)
+               printf(" sint16");
+       else if (opt->type & UINT32)
+               printf(" uint32");
+       else if (opt->type & SINT32)
+               printf(" sint32");
+       else if (opt->type & ADDRIPV4)
+               printf(" ipaddress");
+       else if (opt->type & ADDRIPV6)
+               printf(" ip6address");
+       else if (opt->type & FLAG)
+               printf(" flag");
+       else if (opt->type & RFC3397)
+               printf(" domain");
+       else if (opt->type & DOMAIN)
+               printf(" dname");
+       else if (opt->type & ASCII)
+               printf(" ascii");
+       else if (opt->type & RAW)
+               printf(" raw");
+       else if (opt->type & BINHEX)
+               printf(" binhex");
+       else if (opt->type & STRING)    
+               printf(" string");
+       if (opt->type & RFC3361)        
+               printf(" rfc3361");
+       if (opt->type & RFC3442)
+               printf(" rfc3442");
+       if (opt->type & RFC5969)
+               printf(" rfc5969");
+       if (opt->type & REQUEST)
+               printf(" request");
+       if (opt->type & NOREQ)
+               printf(" norequest");
+       putchar('\n');
+}
+
 struct dhcp_opt *
 vivso_find(uint32_t iana_en, const void *arg)
 {
@@ -296,60 +350,179 @@
                        *out = '\0';
        }
 
+       if (count)
+               /* Don't count the trailing NUL */
+               count--;
        return (ssize_t)count;
 }
 
-/*
- * Escape these characters to avoid any nastiness passing to a POSIX shell.
- * See IEEE Std 1003.1, 2004 Shell Command Language, 2.2 Quoting
- * space is not escaped.
- */
-#define ESCAPE_CHARS   "|&;<>()$`\\\"'\t\n"
+/* Check for a valid domain name as per RFC1123 with the exception of
+ * allowing - and _ (but not at start or end) as they seem to be widely used. */
+static int
+valid_domainname(char *lbl, int type)
+{
+       char *slbl, *lst;
+       unsigned char c;
+       int start, len, errset;
+
+       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;
+               if (c == ' ') {
+                       if (lbl - 1 == slbl) /* No space at start */
+                               break;
+                       if (!(type & ARRAY))
+                               break;
+                       /* Skip to the next label */
+                       if (!start) {
+                               start = 1;
+                               lst = lbl - 1;
+                       }
+                       if (len)
+                               len = 0;
+                       continue;
+               }
+               if (c == '.') {
+                       if (*lbl == '.')
+                               break;
+                       len = 0;
+                       continue;
+               }
+               if (((c == '-' || c == '_') &&
+                   !start && *lbl != ' ' && *lbl != '\0') ||
+                   isalnum(c))
+               {
+                       if (++len > 63) {
+                               errno = ERANGE;
+                               errset = 1;
+                               break;
+                       }
+               } else
+                       break;
+               if (start)
+                       start = 0;
+       }
+
+       if (!errset)
+               errno = EINVAL;
+       if (lst) {
+               /* At least one valid domain, return it */
+               *lst = '\0';
+               return 1;
+       }
+       return 0;
+}
 
 /*
  * Prints a chunk of data to a string.
- * Escapes some characters defnined above to try and avoid any loopholes
- * in the shell we're passing to.
- * Any non visible characters are escaped as an octal number.
+ * PS_SHELL goes as it is these days, it's upto the target to validate it.
+ * PS_SAFE has all non ascii and non printables changes to escaped octal.
  */
+static const char hexchrs[] = "0123456789abcdef";
 ssize_t
-print_string(char *s, size_t len, const uint8_t *data, size_t dl)
+print_string(char *dst, size_t len, int type, const uint8_t *data, size_t dl)
 {
+       char *odst;
        uint8_t c;
-       const uint8_t *e, *p;
+       const uint8_t *e;
        size_t bytes;
-       char v[5], *vp, *ve;
 
+       odst = dst;
        bytes = 0;
        e = data + dl;
+
        while (data < e) {
                c = *data++;
-               if (c == '\0') {
-                       /* If rest is all NULL, skip it. */
-                       for (p = data; p < e; p++)
-                               if (*p != '\0')
-                                       break;
-                       if (p == e)
-                               break;
+               if (type & BINHEX) {
+                       if (dst) {
+                               if (len  == 0 || len == 1) {
+                                       errno = ENOSPC;
+                                       return -1;
+                               }
+                               *dst++ = hexchrs[(c & 0xF0) >> 4];
+                               *dst++ = hexchrs[(c & 0x0F)];
+                               len -= 2;
+                       }
+                       bytes += 2;
+                       continue;



Home | Main Index | Thread Index | Old Index