about summary refs log tree commit diff
path: root/debian/patches/08-disabled_devices.patch
blob: d5392c9f8b2aea75802d5362b3019cfeab268fdd (plain)
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
51
52
--- src/backends/NetworkManagerDebian.c.orig	2006-05-05 19:59:18.000000000 +0200
+++ src/backends/NetworkManagerDebian.c	2006-05-05 20:04:34.000000000 +0200
@@ -521,7 +521,48 @@
  */
 gboolean nm_system_device_get_disabled (NMDevice *dev)
 {
-	return FALSE;
+	const char      *iface;
+	if_block	*curr_device, *curr_b;
+	if_data		*curr_d;
+	gboolean	 blacklist = TRUE;
+
+	g_return_val_if_fail (dev != NULL, TRUE);
+
+	iface = nm_device_get_iface (dev);
+
+	ifparser_init ();
+
+	/* If the interface isn't listed in /etc/network/interfaces then
+	 * it's considered okay to control it.
+ 	 */
+	curr_device = ifparser_getif (iface);
+	if (curr_device == NULL) {
+		blacklist = FALSE;
+		goto out;
+	}
+
+	/* If the interface is listed and isn't marked "auto" then it's
+	 * definitely not okay to control it.
+	 */
+	for (curr_b = ifparser_getfirst(); curr_b; curr_b = curr_b->next) {
+		if (!strcmp (curr_b->type, "auto")
+		    && strstr (curr_b->name, iface))
+			blacklist = FALSE;
+	}
+
+	/* If the interface has no options other than just "inet dhcp"
+	 * it's probably ok to fiddle with it.
+	 */
+	for (curr_d = curr_device->info; curr_d; curr_d = curr_d->next) {
+		if (strcmp (curr_d->key, "inet")
+		    || strcmp (curr_d->data, "dhcp"))
+			blacklist = TRUE;
+	}
+
+out:
+	ifparser_destroy ();
+
+	return blacklist;
 }