From: Roy Marples Date: Fri, 7 Feb 2020 15:04:25 +0000 (+0000) Subject: dhcpcd: randomise hardware address on start if no carrier X-Git-Tag: v9.0.0~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db9b001ddf0ead9adfe1b2022d583cb94a7e2d6b;p=thirdparty%2Fdhcpcd.git dhcpcd: randomise hardware address on start if no carrier For more anonymity. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 3da52982..46564d01 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -940,9 +940,19 @@ static void 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 && diff --git a/src/if.c b/src/if.c index 2172ec4e..a4bf4d61 100644 --- a/src/if.c +++ b/src/if.c @@ -213,7 +213,7 @@ if_randomisemac(struct interface *ifp) 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);