Control: tag -1 + patch Hello NM maintainers,
I was affected by this problem recently (trying to change my MAC in an airport with macchanger) and many Kali users are also complaining of this behaviour. Upstream largely improved this behaviour in NM 1.3.x by making it configurable, see: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=8eed67122c58540360b617eb42d5df8328e21b5d For 1.3.x, we should definitely provide by default configuration file that changes {wifi,ethernet}.cloned-mac-address to "preserve". I'm just not sure how this should look like in the configuration file... For 1.2.x, I would like us to revert the upstream patch that broke this. The justification for the change was not a very good one (recovering from a crashed NM with bonded network interfaces) and breaks more use cases than it solves... please find the patch attached. I would like to see this patch applied in Debian as I applied it in Kali. Let me know if you want me to make a non-maintainer upload with that patch. Cheers, -- Raphaël Hertzog ◈ Debian Developer Support Debian LTS: http://www.freexian.com/services/debian-lts.html Learn to master Debian: http://debian-handbook.info/get/
From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= <hert...@debian.org> Date: Tue, 12 Jul 2016 15:51:20 +0200 Subject: Revert "device: when activating without cloned-mac-address, set the permanent one" This reverts commit f541a17270f3ff69d2ea7a3262d15dc63abb74b7 so that a custom MAC is not overwritten when a connection is setup. Upstream has largely refactored/changed this for NetworkManager 1.3 and this can be dropped for this version although we might want to add some default configuration file to set wifi.cloned-mac-address=pres See upstream commit for details of settings for 1.3: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=8eed67122c58540360b617eb42d5df8328e21b5d Bug-Debian: https://bugs.debian.org/686505 --- src/devices/nm-device-ethernet.c | 3 ++- src/devices/nm-device-macvlan.c | 3 ++- src/devices/nm-device-tun.c | 3 ++- src/devices/nm-device-vlan.c | 3 ++- src/devices/nm-device-vxlan.c | 3 ++- src/devices/nm-device.c | 6 +----- src/devices/wifi/nm-device-wifi.c | 3 ++- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index d27f7dc..5b8968e 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -824,7 +824,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_ETHER); + if (cloned_mac) + nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_ETHER); } /* If we're re-activating a PPPoE connection a short while after diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index c431fe8..9c1946a 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -516,7 +516,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_HW); + if (cloned_mac) + nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_HW); } return TRUE; diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index eac2fb8..a042645 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -303,7 +303,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); + if (cloned_mac) + nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); } return NM_ACT_STAGE_RETURN_SUCCESS; diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index eb6527d..1c7e63b 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -563,7 +563,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN); + if (cloned_mac) + nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN); } /* Change MAC address to parent's one if needed */ diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index d308d47..8da8292 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -518,7 +518,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) if (s_wired) { /* Set device MAC address if the connection wants to change it */ cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired); - nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); + if (cloned_mac) + nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_DEVICE); } return NM_ACT_STAGE_RETURN_SUCCESS; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 8472ff8..8cf3559 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -10992,11 +10992,7 @@ nm_device_set_hw_addr (NMDevice *self, const char *addr, const char *cur_addr = nm_device_get_hw_address (self); guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX]; - /* Fall back to the permanent address */ - if (!addr) - addr = priv->perm_hw_addr; - if (!addr) - return FALSE; + g_return_val_if_fail (addr != NULL, FALSE); /* Do nothing if current MAC is same */ if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, -1)) { diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 95a89ea..0fc8547 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -2317,7 +2317,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) /* Set spoof MAC to the interface */ cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless); - nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_WIFI); + if (cloned_mac) + nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_WIFI); /* AP mode never uses a specific object or existing scanned AP */ if (priv->mode != NM_802_11_MODE_AP) {