changeset 5055:db92f78f92b4 draft

dhcpcd: randomise hardware address on start if no carrier For more anonymity.
author Roy Marples <roy@marples.name>
date Fri, 07 Feb 2020 15:04:25 +0000
parents 1f0bec62471a
children f402f3ef7c23
files src/dhcpcd.c src/if.c
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/dhcpcd.c	Fri Feb 07 14:13:59 2020 +0000
+++ b/src/dhcpcd.c	Fri Feb 07 15:04:25 2020 +0000
@@ -940,9 +940,19 @@
 dhcpcd_prestartinterface(void *arg)
 {
 	struct interface *ifp = arg;
+	bool anondown;
+
+	if (ifp->carrier == LINK_DOWN &&
+	    ifp->options->options & DHCPCD_ANONYMOUS &&
+	    ifp->flags & IFF_UP)
+	{
+		if_down(ifp);
+		anondown = true;
+	} else
+		anondown = false;
 
 	if ((!(ifp->ctx->options & DHCPCD_MASTER) ||
-	    ifp->options->options & DHCPCD_IF_UP) &&
+	    ifp->options->options & DHCPCD_IF_UP || anondown) &&
 	    !(ifp->flags & IFF_UP))
 	{
 		if (ifp->options->options & DHCPCD_ANONYMOUS &&
--- a/src/if.c	Fri Feb 07 14:13:59 2020 +0000
+++ b/src/if.c	Fri Feb 07 15:04:25 2020 +0000
@@ -213,7 +213,7 @@
 
 	logdebugx("%s: hardware address randomised to %s",
 	    ifp->name,
-	    hwaddr_ntoa(buf, sizeof(buf), sbuf, sizeof(sbuf)));
+	    hwaddr_ntoa(buf, ifp->hwlen, sbuf, sizeof(sbuf)));
 	retval = if_setmac(ifp, buf, ifp->hwlen);
 	if (retval == 0)
 		memcpy(ifp->hwaddr, buf, ifp->hwlen);