Module Name:    src
Committed By:   roy
Date:           Sat Sep 27 01:17:34 UTC 2014

Modified Files:
        src/external/bsd/dhcpcd/dist: dhcp.c dhcpcd-run-hooks.8.in dhcpcd.8.in
            dhcpcd.c if-bsd.c script.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in
cvs rdiff -u -r1.30 -r1.31 src/external/bsd/dhcpcd/dist/dhcpcd.8.in
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/dhcpcd.c \
    src/external/bsd/dhcpcd/dist/if-bsd.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcpcd/dist/script.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.16 src/external/bsd/dhcpcd/dist/dhcp.c:1.17
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.16	Tue Sep 16 22:27:04 2014
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Sat Sep 27 01:17:34 2014
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.16 2014/09/16 22:27:04 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.17 2014/09/27 01:17:34 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1204,7 +1204,7 @@ dhcp_env(char **env, const char *prefix,
 	struct dhcp_opt *opt, *vo;
 	size_t e, i, pl;
 	char **ep;
-	char cidr[4];
+	char cidr[4], safe[(BOOTFILE_LEN * 4) + 1];
 	uint8_t overl = 0;
 	uint32_t en;
 
@@ -1271,11 +1271,16 @@ dhcp_env(char **env, const char *prefix,
 		setvar(&ep, prefix, "network_number", inet_ntoa(addr));
 	}
 
-	if (*dhcp->bootfile && !(overl & 1))
-		setvar(&ep, prefix, "filename", (const char *)dhcp->bootfile);
-	if (*dhcp->servername && !(overl & 2))
-		setvar(&ep, prefix, "server_name",
-		    (const char *)dhcp->servername);
+	if (*dhcp->bootfile && !(overl & 1)) {
+		print_string(safe, sizeof(safe),
+		    dhcp->bootfile, sizeof(dhcp->bootfile));
+		setvar(&ep, prefix, "filename", safe);
+	}
+	if (*dhcp->servername && !(overl & 2)) {
+		print_string(safe, sizeof(safe),
+		    dhcp->servername, sizeof(dhcp->servername));
+		setvar(&ep, prefix, "server_name", safe);
+	}
 
 	/* Zero our indexes */
 	if (env) {
@@ -2184,7 +2189,7 @@ log_dhcp1(int lvl, const char *msg,
     const struct in_addr *from, int ad)
 {
 	const char *tfrom;
-	char *a;
+	char *a,  sname[sizeof(dhcp->servername) * 4];
 	struct in_addr addr;
 	int r;
 
@@ -2203,12 +2208,14 @@ log_dhcp1(int lvl, const char *msg,
 	tfrom = "from";
 	r = get_option_addr(iface->ctx, &addr, dhcp, DHO_SERVERID);
 	if (dhcp->servername[0] && r == 0) {
+		print_string(sname, sizeof(sname),
+		    dhcp->servername, strlen((const char *)dhcp->servername));
 		if (a == NULL)
 			syslog(lvl, "%s: %s %s %s `%s'", iface->name, msg,
-			    tfrom, inet_ntoa(addr), dhcp->servername);
+			    tfrom, inet_ntoa(addr), sname);
 		else
 			syslog(lvl, "%s: %s %s %s %s `%s'", iface->name, msg, a,
-			    tfrom, inet_ntoa(addr), dhcp->servername);
+			    tfrom, inet_ntoa(addr), sname);
 	} else {
 		if (r != 0) {
 			tfrom = "via";

Index: src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.6 src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.7
--- src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in:1.6	Tue Sep 16 22:27:04 2014
+++ src/external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in	Sat Sep 27 01:17:34 2014
@@ -1,5 +1,5 @@
-.\"     $NetBSD: dhcpcd-run-hooks.8.in,v 1.6 2014/09/16 22:27:04 roy Exp $
-.\" Copyright (c) 2006-2013 Roy Marples
+.\"     $NetBSD: dhcpcd-run-hooks.8.in,v 1.7 2014/09/27 01:17:34 roy Exp $
+.\" Copyright (c) 2006-2014 Roy Marples
 .\" All rights reserved
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 12, 2014
+.Dd September 26, 2014
 .Dt DHCPCD-RUN-HOOKS 8
 .Os
 .Sh NAME
@@ -90,6 +90,8 @@ dhcpcd renewed it's lease.
 dhcpcd has rebound to a new DHCP server.
 .It Dv REBOOT | Dv REBOOT6
 dhcpcd successfully requested a lease from a DHCP server.
+.It Dv DELEGATED6
+dhcpcd assigned a delegated prefix to the interface.
 .It Dv IPV4LL
 dhcpcd failed to contact any DHCP servers but did obtain an IPV4LL address.
 .It Dv STATIC
@@ -135,7 +137,7 @@ and
 .Ev $RC_SVCNAME .
 The following variables will then be set, along with any protocol supplied
 ones.
-.Bl -tag -width Xinterface_order
+.Bl -tag -width xnew_dhcp6_prefix
 .It Ev $interface
 the name of the interface.
 .It Ev $reason
@@ -197,6 +199,8 @@ is connected to.
 the name of the SSID the
 .Ev interface
 was connected to.
+.It Ev $new_dhcp6_prefix
+space separated list of delegated prefixes.
 .El
 .Sh FILES
 When

Index: src/external/bsd/dhcpcd/dist/dhcpcd.8.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.30 src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.31
--- src/external/bsd/dhcpcd/dist/dhcpcd.8.in:1.30	Tue Sep 16 22:27:04 2014
+++ src/external/bsd/dhcpcd/dist/dhcpcd.8.in	Sat Sep 27 01:17:34 2014
@@ -1,4 +1,4 @@
-.\"     $NetBSD: dhcpcd.8.in,v 1.30 2014/09/16 22:27:04 roy Exp $
+.\"     $NetBSD: dhcpcd.8.in,v 1.31 2014/09/27 01:17:34 roy Exp $
 .\" Copyright (c) 2006-2014 Roy Marples
 .\" All rights reserved
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 15, 2014
+.Dd September 26, 2014
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -204,6 +204,17 @@ See
 for details on how these scripts work.
 .Nm
 currently ignores the exit code of the script.
+.Pp
+.Nm
+sanitises each variable passed from the DHCP/RA message by encoding non
+printable characters in escaped octal and escaping the following characters:
+.D1 | \*[Am] \&; \*[Lt] \*[Gt] \&( \&) $ ` \e \*q ' \
+\*[Lt]tab\*[Gt] \*[Lt]newline\*[Gt]
+.Pp
+It is possible to reverse this encoding by passing the variable to
+.Xr unvis 1 ,
+like so:
+.D1 printf \*q%s\*q \*qvariable_name\*q | unvis
 .Ss Fine tuning
 You can fine-tune the behaviour of
 .Nm
@@ -632,6 +643,23 @@ to rebind, reconfigure or exit need to i
 so that
 .Nm
 knows which process to signal.
+.Pp
+.Nm
+sanitises variables using the
+.Xr svis 3
+function with the
+.Dv VIS_CTYPE
+and
+.Dv VIS_OCTAL
+flags which your libc may provide,
+or it's own compatible one if not.
+Some
+.Xr unvis 1
+implementations may not decode either correctly, depending on how they
+handle VIS_CTYPE in both
+.Xr vis 3
+and
+.Xr unvis 3 .
 .Sh FILES
 .Bl -ohang
 .It Pa @SYSCONFDIR@/dhcpcd.conf

Index: src/external/bsd/dhcpcd/dist/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.c:1.9 src/external/bsd/dhcpcd/dist/dhcpcd.c:1.10
--- src/external/bsd/dhcpcd/dist/dhcpcd.c:1.9	Thu Sep 18 20:46:30 2014
+++ src/external/bsd/dhcpcd/dist/dhcpcd.c	Sat Sep 27 01:17:34 2014
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.9 2014/09/18 20:46:30 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.10 2014/09/27 01:17:34 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -457,27 +457,23 @@ configure_interface1(struct interface *i
 	}
 
 #ifdef INET6
-	if (ifo->options & DHCPCD_IPV6) {
-		if (ifo->ia == NULL) {
-			ifo->ia = malloc(sizeof(*ifo->ia));
-			if (ifo->ia == NULL)
-				syslog(LOG_ERR, "%s: %m", __func__);
-			else {
-				ifo->ia_len = 1;
-				ifo->ia->ia_type = D6_OPTION_IA_NA;
+	if (ifo->ia == NULL && ifo->options & DHCPCD_IPV6) {
+		ifo->ia = malloc(sizeof(*ifo->ia));
+		if (ifo->ia == NULL)
+			syslog(LOG_ERR, "%s: %m", __func__);
+		else {
+			ifo->ia_len = 1;
+			ifo->ia->ia_type = D6_OPTION_IA_NA;
+			memcpy(ifo->ia->iaid, ifo->iaid, sizeof(ifo->iaid));
+			memset(&ifo->ia->addr, 0, sizeof(ifo->ia->addr));
+			ifo->ia->sla = NULL;
+			ifo->ia->sla_len = 0;
+		}
+	} else {
+		for (i = 0; i < ifo->ia_len; i++) {
+			if (!ifo->ia[i].iaid_set)
 				memcpy(ifo->ia->iaid, ifo->iaid,
 				    sizeof(ifo->iaid));
-				memset(&ifo->ia->addr, 0,
-				    sizeof(ifo->ia->addr));
-				ifo->ia->sla = NULL;
-				ifo->ia->sla_len = 0;
-			}
-		} else {
-			for (i = 0; i < ifo->ia_len; i++) {
-				if (!ifo->ia[i].iaid_set)
-					memcpy(ifo->ia->iaid, ifo->iaid,
-					    sizeof(ifo->iaid));
-			}
 		}
 	}
 #endif
@@ -1058,7 +1054,7 @@ handle_signal(int sig, siginfo_t *siginf
 }
 
 static int
-signal_init(void (*func)(int, siginfo_t *, void *), sigset_t *oldset)
+signal_init(sigset_t *oldset)
 {
 	unsigned int i;
 	struct sigaction sa;
@@ -1069,7 +1065,7 @@ signal_init(void (*func)(int, siginfo_t 
 		return -1;
 
 	memset(&sa, 0, sizeof(sa));
-	sa.sa_sigaction = func;
+	sa.sa_sigaction = handle_signal;
 	sa.sa_flags = SA_SIGINFO;
 	sigemptyset(&sa.sa_mask);
 
@@ -1606,7 +1602,7 @@ main(int argc, char **argv)
 	ctx.options |= DHCPCD_STARTED;
 #ifdef USE_SIGNALS
 	/* Save signal mask, block and redirect signals to our handler */
-	if (signal_init(handle_signal, &ctx.sigset) == -1) {
+	if (signal_init(&ctx.sigset) == -1) {
 		syslog(LOG_ERR, "signal_setup: %m");
 		goto exit_failure;
 	}
Index: src/external/bsd/dhcpcd/dist/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/if-bsd.c:1.9 src/external/bsd/dhcpcd/dist/if-bsd.c:1.10
--- src/external/bsd/dhcpcd/dist/if-bsd.c:1.9	Thu Sep 18 20:46:30 2014
+++ src/external/bsd/dhcpcd/dist/if-bsd.c	Sat Sep 27 01:17:34 2014
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if-bsd.c,v 1.9 2014/09/18 20:46:30 roy Exp $");
+ __RCSID("$NetBSD: if-bsd.c,v 1.10 2014/09/27 01:17:34 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -88,12 +88,12 @@
 #endif
 
 #define COPYOUT(sin, sa)						      \
-	sin.s_addr = ((sa) != NULL) ?					      \
-	    (((struct sockaddr_in *)(void *)sa)->sin_addr).s_addr : 0
+	if ((sa) && (sa)->sa_family == AF_INET)				      \
+		(sin) = ((struct sockaddr_in*)(void *)(sa))->sin_addr
 
 #define COPYOUT6(sin, sa)						      \
-	sin.s6_addr = ((sa) != NULL) ?					      \
-	    (((struct sockaddr_in6 *)(void *)sa)->sin6_addr).s6_addr : 0
+	if ((sa) && (sa)->sa_family == AF_INET6)			      \
+		(sin) = ((struct sockaddr_in6*)(void *)(sa))->sin6_addr
 
 #ifndef CLLADDR
 #  define CLLADDR(s) ((const char *)((s)->sdl_data + (s)->sdl_nlen))
@@ -786,6 +786,7 @@ if_managelink(struct dhcpcd_ctx *ctx)
 	struct rt rt;
 #endif
 #ifdef INET6
+	struct rt6 rt6;
 	struct in6_addr ia6;
 	struct sockaddr_in6 *sin6;
 	int ifa_flags;
@@ -849,18 +850,29 @@ if_managelink(struct dhcpcd_ctx *ctx)
 				break;
 			cp = (char *)(void *)(rtm + 1);
 			sa = (struct sockaddr *)(void *)cp;
-			if (sa->sa_family != AF_INET)
-				break;
-#ifdef INET
 			get_addrs(rtm->rtm_addrs, cp, rti_info);
-			memset(&rt, 0, sizeof(rt));
-			rt.iface = NULL;
-			COPYOUT(rt.dest, rti_info[RTAX_DST]);
-			COPYOUT(rt.net, rti_info[RTAX_NETMASK]);
-			COPYOUT(rt.gate, rti_info[RTAX_GATEWAY]);
-			ipv4_routedeleted(ctx, &rt);
+			switch (sa->sa_family) {
+#ifdef INET
+			case AF_INET:
+				memset(&rt, 0, sizeof(rt));
+				rt.iface = NULL;
+				COPYOUT(rt.dest, rti_info[RTAX_DST]);
+				COPYOUT(rt.net, rti_info[RTAX_NETMASK]);
+				COPYOUT(rt.gate, rti_info[RTAX_GATEWAY]);
+				ipv4_routedeleted(ctx, &rt);
+				break;
 #endif
-			break;
+#ifdef INET6
+			case AF_INET6:
+				memset(&rt6, 0, sizeof(rt6));
+				rt6.iface = NULL;
+				COPYOUT6(rt6.dest, rti_info[RTAX_DST]);
+				COPYOUT6(rt6.net, rti_info[RTAX_NETMASK]);
+				COPYOUT6(rt6.gate, rti_info[RTAX_GATEWAY]);
+				ipv6_routedeleted(ctx, &rt6);
+				break;
+#endif
+			}
 #ifdef RTM_CHGADDR
 		case RTM_CHGADDR:	/* FALLTHROUGH */
 #endif

Index: src/external/bsd/dhcpcd/dist/script.c
diff -u src/external/bsd/dhcpcd/dist/script.c:1.8 src/external/bsd/dhcpcd/dist/script.c:1.9
--- src/external/bsd/dhcpcd/dist/script.c:1.8	Tue Sep 16 22:27:04 2014
+++ src/external/bsd/dhcpcd/dist/script.c	Sat Sep 27 01:17:34 2014
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: script.c,v 1.8 2014/09/16 22:27:04 roy Exp $");
+ __RCSID("$NetBSD: script.c,v 1.9 2014/09/27 01:17:34 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -473,7 +473,9 @@ dumplease:
 	}
 #endif
 #ifdef INET6
-	if (dhcp6 && d6_state && d6_state->new) {
+	if (dhcp6 && d6_state &&
+	    (d6_state->new || d6_state->state == DH6S_DELEGATED))
+	{
 		n = dhcp6_env(NULL, NULL, ifp,
 		    d6_state->new, d6_state->new_len);
 		if (n > 0) {

Reply via email to