Re: Patch: Wildcard for no-auto-default.



On Friday 09 of July 2010 18:59:08 Pat Suwalski wrote:
> Hello,
> 
> I had a request a few weeks back about how to get the system settings
> daemon to ignore all cards without hardcoding MAC addresses into the
> nm-system-settings.conf file. It was mentioned that there's a workaround
> for RedHat-based systems. I wanted something more explicit.
> 
> The attached trivial patch lets the user specify "no-auto-default=*" to
> have all of the connections blacklisted by the system settings daemon.
> 
> --Pat

Strictly speaking, "no-auto-default" option doesn't cause ignoring devices. 
Rather it is used to specify that for a device, NM shouldn't create a default 
wired connection (Auto eth0), which is normally done for all managed devices 
that doesn't any connection.

If you would have a connection with 'autoconnect=true' that applies to a 
device, listing the device in "no-auto-default" doesn't prevent the device 
from being activated.

Nevertheless, I think it's a good feature to support glob. And in case you 
didn't configure a connection manually, it will solve your issue.

I've updated a patch a bit not to add the MAC to the list when "*" is already 
there. And to ignore leading and trailing whitespaces.

Dan, are you for the patch?

Jirka
diff --git a/src/system-settings/nm-sysconfig-settings.c b/src/system-settings/nm-sysconfig-settings.c
index a9bae14..ecb512b 100644
--- a/src/system-settings/nm-sysconfig-settings.c
+++ b/src/system-settings/nm-sysconfig-settings.c
@@ -1077,6 +1077,12 @@ is_mac_auto_wired_blacklisted (NMSysconfigSettings *self, const GByteArray *mac)
 	for (iter = list; iter && *iter; iter++) {
 		struct ether_addr *candidate;
 
+		if (strcmp(g_strstrip(*iter), "*") == 0)
+		{
+			found = TRUE;
+			break;
+		}
+
 		candidate = ether_aton (*iter);
 		if (candidate && !memcmp (mac->data, candidate->ether_addr_octet, ETH_ALEN)) {
 			found = TRUE;
@@ -1136,13 +1142,21 @@ default_wired_deleted (NMDefaultWiredConnection *wired,
 	g_key_file_load_from_file (config, priv->config_file, G_KEY_FILE_KEEP_COMMENTS, NULL);
 
 	list = g_key_file_get_string_list (config, "main", CONFIG_KEY_NO_AUTO_DEFAULT, &len, NULL);
-	/* Traverse entire list to get count of # items */
 	for (iter = list; iter && *iter; iter++) {
 		struct ether_addr *candidate;
 
+		if (strcmp(g_strstrip(*iter), "*") == 0)
+		{
+			found = TRUE;
+			break;
+		}
+
 		candidate = ether_aton (*iter);
 		if (candidate && !memcmp (mac->data, candidate->ether_addr_octet, ETH_ALEN))
+		{
 			found = TRUE;
+			break;
+		}
 	}
 
 	/* Add this device's MAC to the list */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]