1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
From e01c7b69abb9c118b9e0087803ca203ff157aa0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
Date: Tue, 23 Nov 2010 16:27:21 +0100
Subject: [PATCH 4/4] keyfile: allow uppercase MAC addresses in unmanaged-devices in config file (rh #654714)
---
system-settings/plugins/keyfile/plugin.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/system-settings/plugins/keyfile/plugin.c b/system-settings/plugins/keyfile/plugin.c
index 5a927ce..da6456d 100644
--- a/system-settings/plugins/keyfile/plugin.c
+++ b/system-settings/plugins/keyfile/plugin.c
@@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
+#include <netinet/ether.h>
#include <string.h>
#include <gmodule.h>
@@ -418,8 +419,23 @@ get_unmanaged_specs (NMSystemConfigInterface *config)
udis = g_strsplit (str, ";", -1);
g_free (str);
- for (i = 0; udis[i] != NULL; i++)
- specs = g_slist_append (specs, udis[i]);
+ for (i = 0; udis[i] != NULL; i++) {
+ /* Verify unmanaged specification and add it to the list */
+ if (strlen (udis[i]) > 4 && !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++;
+ }
+ specs = g_slist_append (specs, udis[i]);
+ } else {
+ g_warning ("Error in file '%s': invalid unmanaged-devices entry: '%s'", priv->conf_file, udis[i]);
+ g_free (udis[i]);
+ }
+ }
g_free (udis); /* Yes, g_free, not g_strfreev because we need the strings in the list */
}
--
1.7.3.4
|