summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/devices/nm-device-ethernet.c28
-rw-r--r--src/devices/wifi/nm-device-wifi.c28
2 files changed, 30 insertions, 26 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index e3f664cb50..e127f61bc2 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -383,22 +383,24 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
return FALSE;
perm_hw_addr = nm_device_get_permanent_hw_address (device);
-
mac = nm_setting_wired_get_mac_address (s_wired);
- if (try_mac && mac && perm_hw_addr && !nm_utils_hwaddr_matches (mac, -1, perm_hw_addr, -1))
- return FALSE;
-
- /* Check for MAC address blacklist */
- mac_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired);
- for (i = 0; mac_blacklist[i]; i++) {
- if (!nm_utils_hwaddr_valid (mac_blacklist[i], ETH_ALEN)) {
- g_warn_if_reached ();
+ if (perm_hw_addr) {
+ if (try_mac && mac && !nm_utils_hwaddr_matches (mac, -1, perm_hw_addr, -1))
return FALSE;
- }
- if (perm_hw_addr && nm_utils_hwaddr_matches (mac_blacklist[i], -1, perm_hw_addr, -1))
- return FALSE;
- }
+ /* Check for MAC address blacklist */
+ mac_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired);
+ for (i = 0; mac_blacklist[i]; i++) {
+ if (!nm_utils_hwaddr_valid (mac_blacklist[i], ETH_ALEN)) {
+ g_warn_if_reached ();
+ return FALSE;
+ }
+
+ if (nm_utils_hwaddr_matches (mac_blacklist[i], -1, perm_hw_addr, -1))
+ return FALSE;
+ }
+ } else if (mac)
+ return FALSE;
}
return TRUE;
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index b0d2f654be..3ee2c78ac2 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -813,22 +813,24 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
return FALSE;
perm_hw_addr = nm_device_get_permanent_hw_address (device);
-
mac = nm_setting_wireless_get_mac_address (s_wireless);
- if (mac && perm_hw_addr && !nm_utils_hwaddr_matches (mac, -1, perm_hw_addr, -1))
- return FALSE;
-
- /* Check for MAC address blacklist */
- mac_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless);
- for (i = 0; mac_blacklist[i]; i++) {
- if (!nm_utils_hwaddr_valid (mac_blacklist[i], ETH_ALEN)) {
- g_warn_if_reached ();
+ if (perm_hw_addr) {
+ if (mac && !nm_utils_hwaddr_matches (mac, -1, perm_hw_addr, -1))
return FALSE;
- }
- if (perm_hw_addr && nm_utils_hwaddr_matches (mac_blacklist[i], -1, perm_hw_addr, -1))
- return FALSE;
- }
+ /* Check for MAC address blacklist */
+ mac_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless);
+ for (i = 0; mac_blacklist[i]; i++) {
+ if (!nm_utils_hwaddr_valid (mac_blacklist[i], ETH_ALEN)) {
+ g_warn_if_reached ();
+ return FALSE;
+ }
+
+ if (nm_utils_hwaddr_matches (mac_blacklist[i], -1, perm_hw_addr, -1))
+ return FALSE;
+ }
+ } else if (mac)
+ return FALSE;
if (is_adhoc_wpa (connection))
return FALSE;