From 44b37ddcb7e9aeaf2f11c0e18e19da9cfac100cd Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 22 Sep 2015 15:33:12 +0200 Subject: [PATCH 153/257] Attempt to fix MAC address randomization after r287197 Obtained from: ElectroBSD --- etc/Makefile | 1 + etc/{rc.d/rether => mac-randomization.subr} | 35 ++++++----------------------- etc/rc.d/Makefile | 1 - etc/rc.d/netif | 3 +++ 4 files changed, 11 insertions(+), 29 deletions(-) rename etc/{rc.d/rether => mac-randomization.subr} (74%) diff --git a/etc/Makefile b/etc/Makefile index fe518d283d19..67bb39e701d9 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -31,6 +31,7 @@ BIN1= crontab \ login.access \ login.conf \ mac.conf \ + mac-randomization.subr \ motd \ netconfig \ network.subr \ diff --git a/etc/rc.d/rether b/etc/mac-randomization.subr similarity index 74% rename from etc/rc.d/rether rename to etc/mac-randomization.subr index 51e860353458..d486bf454591 100755 --- a/etc/rc.d/rether +++ b/etc/mac-randomization.subr @@ -2,7 +2,7 @@ # ########################################################################### # -# rether - Randomizes MAC addresses +# Sub routines to randomizes MAC addresses after r287197 (WIP!) # # Add the following line to /etc/rc.conf to randomize the MAC # address for all recognized network interfaces that got one @@ -14,16 +14,6 @@ # # rether_interfaces="bge0 iwn0" # -# By default rether runs before netif so cloned devices aren't -# expected to exist yet. In case of wlan clones the MAC address -# of the parent is inherited so as long as it's randomized the -# clone should be fine too. -# -# Note that MAC address mismatches between clone and parent may -# prevent the clone from working as expected. If you intend to -# run this script after the system is up, you may want to -# explicitly set rether_interfaces to skip clones. -# # Rether requires an ifconfig version that understands "ether random". # ########################################################################### @@ -45,21 +35,8 @@ # ACCEPTABLE, YOU SHOULD PROBABLY MAKE BACKUPS BEFORE USING THE SOFTWARE. ########################################################################### -# PROVIDE: rether -# REQUIRE: FILESYSTEMS -# BEFORE: netif - -. /etc/rc.subr - -name="rether" -rcvar="rether_enable" - rether_enable="${rether_enable-NO}" -start_cmd="rether_start" -stop_cmd=":" - -# For the reason given above, it may make sense to skip cloned devices. get_ethernet_interfaces() { ifconfig -l ether } @@ -70,11 +47,16 @@ get_ethernet_address() { ifconfig "${interface}" ether | awk '/ether/ {print $2}' } -rether_start() { +randomize_mac_addresses() { local \ interface \ ethernet_address + if [ "${rether_enable}" = "NO" ]; then + echo "Not randomizing any MAC addresses!" + return 0 + fi + if [ -z "${rether_interfaces}" ]; then rether_interfaces="$(get_ethernet_interfaces)" fi @@ -92,6 +74,3 @@ rether_start() { fi done } - -load_rc_config "${name}" -run_rc_command "${1}" diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index 578e69ababd5..ac3dda4100a2 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -89,7 +89,6 @@ FILES= DAEMON \ rarpd \ rctl \ resolv \ - rether \ root \ route6d \ routing \ diff --git a/etc/rc.d/netif b/etc/rc.d/netif index a1543e63e704..6b52c50e7f4f 100755 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -32,6 +32,7 @@ . /etc/rc.subr . /etc/network.subr +. /etc/mac-randomization.subr name="netif" desc="Network interface setup" @@ -74,6 +75,8 @@ netif_start() # Create cloned interfaces clone_up $cmdifn + randomize_mac_addresses + # Rename interfaces. ifnet_rename $cmdifn -- 2.11.0