mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-11 08:40:19 +01:00
ifcfg-rh: support "mac-address-blacklist" property in ifcfg-rh plugin
ifcfg-rh plugin now reads/writes the property as MACADDR_BLACKLIST variable. The variable is space-separated list of MAC addresses in the standard hex-digits-and-colons notation. E.g. MACADDR_BLACKLIST="7e:d8:c0:85:58:7f 00:1e:65:30:d5:c7"
This commit is contained in:
parent
a6733c8b4f
commit
b1afd46f65
2 changed files with 86 additions and 0 deletions
|
|
@ -2736,6 +2736,7 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||
{
|
||||
NMSettingWireless *s_wireless;
|
||||
GByteArray *array = NULL;
|
||||
GSList *macaddr_blacklist = NULL;
|
||||
char *value;
|
||||
|
||||
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
||||
|
|
@ -2774,6 +2775,30 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||
g_clear_error (error);
|
||||
}
|
||||
|
||||
value = svGetValue (ifcfg, "MACADDR_BLACKLIST", FALSE);
|
||||
if (value) {
|
||||
char **list = NULL, **iter;
|
||||
struct ether_addr addr;
|
||||
|
||||
list = g_strsplit_set (value, " \t", 0);
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (**iter == '\0')
|
||||
continue;
|
||||
if (!ether_aton_r (*iter, &addr)) {
|
||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid MAC in MACADDR_BLACKLIST '%s'", *iter);
|
||||
continue;
|
||||
}
|
||||
macaddr_blacklist = g_slist_prepend (macaddr_blacklist, *iter);
|
||||
}
|
||||
if (macaddr_blacklist) {
|
||||
macaddr_blacklist = g_slist_reverse (macaddr_blacklist);
|
||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, macaddr_blacklist, NULL);
|
||||
g_slist_free (macaddr_blacklist);
|
||||
}
|
||||
g_free (value);
|
||||
g_strfreev (list);
|
||||
}
|
||||
|
||||
value = svGetValue (ifcfg, "ESSID", TRUE);
|
||||
if (value) {
|
||||
gsize ssid_len = 0, value_len = strlen (value);
|
||||
|
|
@ -3032,6 +3057,7 @@ make_wired_setting (shvarFile *ifcfg,
|
|||
char *value = NULL;
|
||||
int mtu;
|
||||
GByteArray *mac = NULL;
|
||||
GSList *macaddr_blacklist = NULL;
|
||||
char *nettype;
|
||||
|
||||
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
|
||||
|
|
@ -3169,6 +3195,30 @@ make_wired_setting (shvarFile *ifcfg,
|
|||
g_clear_error (error);
|
||||
}
|
||||
|
||||
value = svGetValue (ifcfg, "MACADDR_BLACKLIST", FALSE);
|
||||
if (value) {
|
||||
char **list = NULL, **iter;
|
||||
struct ether_addr addr;
|
||||
|
||||
list = g_strsplit_set (value, " \t", 0);
|
||||
for (iter = list; iter && *iter; iter++) {
|
||||
if (**iter == '\0')
|
||||
continue;
|
||||
if (!ether_aton_r (*iter, &addr)) {
|
||||
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid MAC in MACADDR_BLACKLIST '%s'", *iter);
|
||||
continue;
|
||||
}
|
||||
macaddr_blacklist = g_slist_prepend (macaddr_blacklist, *iter);
|
||||
}
|
||||
if (macaddr_blacklist) {
|
||||
macaddr_blacklist = g_slist_reverse (macaddr_blacklist);
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, macaddr_blacklist, NULL);
|
||||
g_slist_free (macaddr_blacklist);
|
||||
}
|
||||
g_free (value);
|
||||
g_strfreev (list);
|
||||
}
|
||||
|
||||
value = svGetValue (ifcfg, "KEY_MGMT", FALSE);
|
||||
if (value) {
|
||||
if (!strcmp (value, "IEEE8021X")) {
|
||||
|
|
|
|||
|
|
@ -758,6 +758,7 @@ write_wireless_setting (NMConnection *connection,
|
|||
char buf[33];
|
||||
guint32 mtu, chan, i;
|
||||
gboolean adhoc = FALSE, hex_ssid = FALSE;
|
||||
const GSList *macaddr_blacklist;
|
||||
|
||||
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
if (!s_wireless) {
|
||||
|
|
@ -786,6 +787,23 @@ write_wireless_setting (NMConnection *connection,
|
|||
g_free (tmp);
|
||||
}
|
||||
|
||||
svSetValue (ifcfg, "MACADDR_BLACKLIST", NULL, FALSE);
|
||||
macaddr_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless);
|
||||
if (macaddr_blacklist) {
|
||||
const GSList *iter;
|
||||
GString *blacklist_str = g_string_new (NULL);
|
||||
|
||||
for (iter = macaddr_blacklist; iter; iter = g_slist_next (iter)) {
|
||||
g_string_append (blacklist_str, iter->data);
|
||||
g_string_append_c (blacklist_str, ' ');
|
||||
|
||||
}
|
||||
if (blacklist_str->len > 0)
|
||||
g_string_truncate (blacklist_str, blacklist_str->len - 1);
|
||||
svSetValue (ifcfg, "MACADDR_BLACKLIST", blacklist_str->str, FALSE);
|
||||
g_string_free (blacklist_str, TRUE);
|
||||
}
|
||||
|
||||
svSetValue (ifcfg, "MTU", NULL, FALSE);
|
||||
mtu = nm_setting_wireless_get_mtu (s_wireless);
|
||||
if (mtu) {
|
||||
|
|
@ -934,6 +952,7 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
|||
guint32 mtu, num_opts, i;
|
||||
const GPtrArray *s390_subchannels;
|
||||
GString *str;
|
||||
const GSList *macaddr_blacklist;
|
||||
|
||||
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
|
||||
if (!s_wired) {
|
||||
|
|
@ -961,6 +980,23 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
|||
g_free (tmp);
|
||||
}
|
||||
|
||||
svSetValue (ifcfg, "MACADDR_BLACKLIST", NULL, FALSE);
|
||||
macaddr_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired);
|
||||
if (macaddr_blacklist) {
|
||||
const GSList *iter;
|
||||
GString *blacklist_str = g_string_new (NULL);
|
||||
|
||||
for (iter = macaddr_blacklist; iter; iter = g_slist_next (iter)) {
|
||||
g_string_append (blacklist_str, iter->data);
|
||||
g_string_append_c (blacklist_str, ' ');
|
||||
|
||||
}
|
||||
if (blacklist_str->len > 0)
|
||||
g_string_truncate (blacklist_str, blacklist_str->len - 1);
|
||||
svSetValue (ifcfg, "MACADDR_BLACKLIST", blacklist_str->str, FALSE);
|
||||
g_string_free (blacklist_str, TRUE);
|
||||
}
|
||||
|
||||
svSetValue (ifcfg, "MTU", NULL, FALSE);
|
||||
mtu = nm_setting_wired_get_mtu (s_wired);
|
||||
if (mtu) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue