mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
all: use the new NMSettingWired mac-address-denylist property
This commit is contained in:
parent
f2d91b4a68
commit
0e283a8917
|
@ -370,7 +370,7 @@ check_connection_compatible(NMDevice *device,
|
||||||
if (s_wired) {
|
if (s_wired) {
|
||||||
const char *mac, *perm_hw_addr;
|
const char *mac, *perm_hw_addr;
|
||||||
gboolean try_mac = TRUE;
|
gboolean try_mac = TRUE;
|
||||||
const char *const *mac_blacklist;
|
const char *const *mac_denylist;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!match_subchans(self, s_wired, &try_mac)) {
|
if (!match_subchans(self, s_wired, &try_mac)) {
|
||||||
|
@ -390,17 +390,17 @@ check_connection_compatible(NMDevice *device,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for MAC address blacklist */
|
/* Check for MAC address denylist */
|
||||||
mac_blacklist = nm_setting_wired_get_mac_address_blacklist(s_wired);
|
mac_denylist = nm_setting_wired_get_mac_address_denylist(s_wired);
|
||||||
for (i = 0; mac_blacklist[i]; i++) {
|
for (i = 0; mac_denylist[i]; i++) {
|
||||||
if (!nm_utils_hwaddr_valid(mac_blacklist[i], ETH_ALEN)) {
|
if (!nm_utils_hwaddr_valid(mac_denylist[i], ETH_ALEN)) {
|
||||||
nm_utils_error_set_literal(error,
|
nm_utils_error_set_literal(error,
|
||||||
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
||||||
"invalid MAC in blacklist");
|
"invalid MAC in blacklist");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nm_utils_hwaddr_matches(mac_blacklist[i], -1, perm_hw_addr, -1)) {
|
if (nm_utils_hwaddr_matches(mac_denylist[i], -1, perm_hw_addr, -1)) {
|
||||||
nm_utils_error_set_literal(error,
|
nm_utils_error_set_literal(error,
|
||||||
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
||||||
"permanent MAC address of device blacklisted");
|
"permanent MAC address of device blacklisted");
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ write_wired_setting_impl(NMSettingWired *s_wired, shvarFile *ifcfg, gboolean is_
|
||||||
"GENERATE_MAC_ADDRESS_MASK",
|
"GENERATE_MAC_ADDRESS_MASK",
|
||||||
nm_setting_wired_get_generate_mac_address_mask(s_wired));
|
nm_setting_wired_get_generate_mac_address_mask(s_wired));
|
||||||
|
|
||||||
macaddr_blacklist = nm_setting_wired_get_mac_address_blacklist(s_wired);
|
macaddr_blacklist = nm_setting_wired_get_mac_address_denylist(s_wired);
|
||||||
if (macaddr_blacklist[0]) {
|
if (macaddr_blacklist[0]) {
|
||||||
gs_free char *blacklist_str = NULL;
|
gs_free char *blacklist_str = NULL;
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ connection_compatible(NMDevice *device, NMConnection *connection, GError **error
|
||||||
if (s_wired) {
|
if (s_wired) {
|
||||||
const char *perm_addr, *s_mac;
|
const char *perm_addr, *s_mac;
|
||||||
gboolean try_mac = TRUE;
|
gboolean try_mac = TRUE;
|
||||||
const char *const *mac_blacklist;
|
const char *const *mac_denylist;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Check s390 subchannels */
|
/* Check s390 subchannels */
|
||||||
|
@ -232,20 +232,20 @@ connection_compatible(NMDevice *device, NMConnection *connection, GError **error
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for MAC address blacklist */
|
/* Check for MAC address denylist */
|
||||||
mac_blacklist = nm_setting_wired_get_mac_address_blacklist(s_wired);
|
mac_denylist = nm_setting_wired_get_mac_address_denylist(s_wired);
|
||||||
for (i = 0; mac_blacklist[i]; i++) {
|
for (i = 0; mac_denylist[i]; i++) {
|
||||||
if (!nm_utils_hwaddr_valid(mac_blacklist[i], ETH_ALEN)) {
|
if (!nm_utils_hwaddr_valid(mac_denylist[i], ETH_ALEN)) {
|
||||||
g_warn_if_reached();
|
g_warn_if_reached();
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
NM_DEVICE_ERROR,
|
NM_DEVICE_ERROR,
|
||||||
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||||
_("Invalid MAC in the blacklist: %s."),
|
_("Invalid MAC in the blacklist: %s."),
|
||||||
mac_blacklist[i]);
|
mac_denylist[i]);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nm_utils_hwaddr_matches(mac_blacklist[i], -1, perm_addr, -1)) {
|
if (nm_utils_hwaddr_matches(mac_denylist[i], -1, perm_addr, -1)) {
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
NM_DEVICE_ERROR,
|
NM_DEVICE_ERROR,
|
||||||
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||||
|
|
Loading…
Reference in a new issue