settings: fix unmanaging of InfiniBand devices

ifcfg-rh didn't let you unmanage an InfiniBand device by hardware
address because it was recording the hardware address with uppercase
letters, while nm_match_spec_hwaddr() required lowercase. Fix this by
making nm_match_spec_hwaddr() match case-insensitively (and remove the
manual lowercasing that several other places were doing to work around
this.)

keyfile didn't let you unmanage an InfiniBand device by hardware
address because it only accepted ARPHRD_ETHER hardware addresses. Fix
that by using nm_utils_hwaddr_valid() instead.
This commit is contained in:
Dan Winship 2013-06-11 11:21:17 -03:00
parent 9a73db17d5
commit d575381c28
4 changed files with 16 additions and 32 deletions

View File

@ -369,7 +369,7 @@ nm_match_spec_string (const GSList *specs, const char *match)
const GSList *iter;
for (iter = specs; iter; iter = g_slist_next (iter)) {
if (!strcmp ((const char *) iter->data, match))
if (!g_ascii_strcasecmp ((const char *) iter->data, match))
return TRUE;
}
@ -379,18 +379,12 @@ nm_match_spec_string (const GSList *specs, const char *match)
gboolean
nm_match_spec_hwaddr (const GSList *specs, const char *hwaddr)
{
char *hwaddr_match, *p;
char *hwaddr_match;
gboolean matched;
g_return_val_if_fail (hwaddr != NULL, FALSE);
p = hwaddr_match = g_strdup_printf ("mac:%s", hwaddr);
while (*p) {
*p = g_ascii_tolower (*p);
p++;
}
hwaddr_match = g_strdup_printf ("mac:%s", hwaddr);
matched = nm_match_spec_string (specs, hwaddr_match);
g_free (hwaddr_match);
return matched;

View File

@ -559,18 +559,7 @@ get_unmanaged_specs (NMSystemConfigInterface *config)
ids = g_strsplit (str, ";", -1);
for (i = 0; ids[i] != NULL; i++) {
/* Verify unmanaged specification and add it to the list */
if (!strncmp (ids[i], "mac:", 4) && ether_aton (ids[i] + 4)) {
char *p = ids[i];
/* To accept uppercase MACs in configuration file, we have to
* convert values to lowercase here. Unmanaged MACs in specs are
* always in lowercase.
*/
while (*p) {
*p = g_ascii_tolower (*p);
p++;
}
if (!strncmp (ids[i], "mac:", 4) && nm_utils_hwaddr_valid (ids[i] + 4)) {
specs = g_slist_append (specs, ids[i]);
} else if (!strncmp (ids[i], "interface-name:", 15) && nm_utils_iface_valid_name (ids[i] + 15)) {
specs = g_slist_append (specs, ids[i]);

View File

@ -147,8 +147,17 @@ _internal_new_connection (SCPluginIfcfg *self,
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, " read connection '%s'", cid);
if (nm_ifcfg_connection_get_unmanaged_spec (connection)) {
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Ignoring connection '%s' and its "
"device due to NM_CONTROLLED/BRIDGE/VLAN.", cid);
const char *spec;
const char *device_id;
spec = nm_ifcfg_connection_get_unmanaged_spec (connection);
device_id = strchr (spec, ':');
if (device_id)
device_id++;
else
device_id = spec;
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Ignoring connection '%s' / device '%s' "
"due to NM_CONTROLLED/BRIDGE/VLAN.", cid, device_id);
} else {
/* Wait for the connection to become unmanaged once it knows the
* hardware IDs of its device, if/when the device gets plugged in.

View File

@ -412,15 +412,7 @@ get_unmanaged_specs (NMSystemConfigInterface *config)
for (i = 0; udis[i] != NULL; i++) {
/* Verify unmanaged specification and add it to the list */
if (!strncmp (udis[i], "mac:", 4) && ether_aton (udis[i] + 4)) {
char *p = udis[i];
/* To accept uppercase MACs in configuration file, we have to convert values to lowercase here.
* Unmanaged MACs in specs are always in lowercase. */
while (*p) {
*p = g_ascii_tolower (*p);
p++;
}
if (!strncmp (udis[i], "mac:", 4) && nm_utils_hwaddr_valid (udis[i] + 4)) {
specs = g_slist_append (specs, udis[i]);
} else if (!strncmp (udis[i], "interface-name:", 15) && nm_utils_iface_valid_name (udis[i] + 15)) {
specs = g_slist_append (specs, udis[i]);