about summary refs log tree commit diff
path: root/debian/patches
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/01-supplicant_timeout.patch (renamed from debian/patches/timeout.patch)6
-rw-r--r--debian/patches/02-dbus_access_network_manager.patch19
-rw-r--r--debian/patches/04-if_fix.patch12
-rw-r--r--debian/patches/05-debian_backend.patch371
-rw-r--r--debian/patches/06-dispatch_more_events.patch99
-rw-r--r--debian/patches/11-man_page_sh_name.patch15
-rw-r--r--debian/patches/12_readme_format.patch14
-rw-r--r--debian/patches/13-validate_mac_addr.patch33
-rw-r--r--debian/patches/20-stable_branch_updates_r2652.patch914
-rw-r--r--debian/patches/21-endianess_fix_r2754.patch28
-rw-r--r--debian/patches/22-fix_vpn_ftbfs_dont_disable_gnome_deprecated.patch44
-rw-r--r--debian/patches/23-rfkill_return_type.patch22
-rw-r--r--debian/patches/24-get_mode_fix_r3122.patch13
-rw-r--r--debian/patches/25-libnl_unique_pid_r3155.patch417
-rw-r--r--debian/patches/26-libnl_1.0-pre8_r3206.patch202
-rw-r--r--debian/patches/27-dont_repeat_errors.patch37
-rw-r--r--debian/patches/dbus_access_network_manager.patch11
-rw-r--r--debian/patches/dbus_access_nm_applet.patch11
-rw-r--r--debian/patches/if_fix.patch33
19 files changed, 2243 insertions, 58 deletions
diff --git a/debian/patches/timeout.patch b/debian/patches/01-supplicant_timeout.patch
index 0723c83a..45060db4 100644
--- a/debian/patches/timeout.patch
+++ b/debian/patches/01-supplicant_timeout.patch
@@ -1,6 +1,6 @@
---- src/nm-device-802-11-wireless.c.orig	2006-02-13 11:46:50.000000000 +0100
-+++ src/nm-device-802-11-wireless.c	2006-02-13 11:47:08.000000000 +0100
-@@ -2205,7 +2205,7 @@
+--- src/nm-device-802-11-wireless.c	2006-06-20 20:15:45.000000000 +0200
++++ src/nm-device-802-11-wireless.c.new	2006-08-13 22:32:13.000000000 +0200
+@@ -2329,7 +2329,7 @@
  }
  
  
diff --git a/debian/patches/02-dbus_access_network_manager.patch b/debian/patches/02-dbus_access_network_manager.patch
new file mode 100644
index 00000000..ced5effe
--- /dev/null
+++ b/debian/patches/02-dbus_access_network_manager.patch
@@ -0,0 +1,19 @@
+Index: src/NetworkManager.conf
+===================================================================
+--- src/NetworkManager.conf	(Revision 2735)
++++ src/NetworkManager.conf	(Arbeitskopie)
+@@ -8,6 +8,14 @@
+                 <allow send_destination="org.freedesktop.NetworkManager"/>
+                 <allow send_interface="org.freedesktop.NetworkManager"/>
+         </policy>
++        <policy user="haldaemon">
++                <allow send_destination="org.freedesktop.NetworkManager"/>
++                <allow send_interface="org.freedesktop.NetworkManager"/>
++        </policy>
++        <policy group="netdev">
++                <allow send_destination="org.freedesktop.NetworkManager"/>
++                <allow send_interface="org.freedesktop.NetworkManager"/>
++        </policy>
+         <policy at_console="true">
+                 <allow send_destination="org.freedesktop.NetworkManager"/>
+                 <allow send_interface="org.freedesktop.NetworkManager"/>
diff --git a/debian/patches/04-if_fix.patch b/debian/patches/04-if_fix.patch
new file mode 100644
index 00000000..ca0b1574
--- /dev/null
+++ b/debian/patches/04-if_fix.patch
@@ -0,0 +1,12 @@
+--- src/nm-device-802-3-ethernet.c	2006-05-13 21:06:05.000000000 +0200
++++ src/nm-device-802-3-ethernet.c.new	2006-08-13 22:34:56.000000000 +0200
+@@ -376,7 +376,9 @@
+ /**************************************/
+ /*    MII capability detection        */
+ /**************************************/
++#define _LINUX_IF_H
+ #include <linux/mii.h>
++#undef _LINUX_IF_H
+ 
+ static int
+ mdio_read (NMDevice8023Ethernet *self, NMSock *sk, struct ifreq *ifr, int location)
diff --git a/debian/patches/05-debian_backend.patch b/debian/patches/05-debian_backend.patch
new file mode 100644
index 00000000..931a2063
--- /dev/null
+++ b/debian/patches/05-debian_backend.patch
@@ -0,0 +1,371 @@
+diff --git a/src/backends/NetworkManagerDebian.c b/src/backends/NetworkManagerDebian.c
+index 740572a..4e3e44a 100644
+--- a/src/backends/NetworkManagerDebian.c
++++ b/src/backends/NetworkManagerDebian.c
+@@ -37,6 +37,7 @@
+ #include "nm-utils.h"
+ 
+ #define ARPING "/usr/sbin/arping"
++#define RESOLVCONF "resolvconf"
+ 
+ /*
+  * nm_system_init
+@@ -238,14 +239,16 @@ void nm_system_kill_all_dhcp_daemons (void)
+ /*
+  * nm_system_update_dns
+  *
+- * Make glibc/nscd aware of any changes to the resolv.conf file by
+- * restarting nscd.
++ * Invalidate the nscd host cache, if it exists, since
++ * we changed resolv.conf.
+  *
+  */
+ void nm_system_update_dns (void)
+ {
+-	nm_spawn_process ("/usr/sbin/invoke-rc.d nscd restart");
+-
++	if (g_file_test ("/usr/sbin/nscd", G_FILE_TEST_IS_EXECUTABLE)) {
++		nm_info ("Clearing nscd hosts cache.");
++		nm_spawn_process ("/usr/sbin/nscd -i hosts");
++	}
+ }
+ 
+ 
+@@ -257,8 +260,7 @@ void nm_system_update_dns (void)
+  *
+  */
+ void nm_system_restart_mdns_responder (void)
+-{
+-	nm_spawn_process ("/usr/bin/killall -q -USR1 mDNSResponder");
++{	
+ }
+ 
+ 
+@@ -514,13 +516,60 @@ gboolean nm_system_device_get_use_dhcp (NMDevice *dev)
+ /*
+  * nm_system_device_get_disabled
+  *
+- * Return whether the distro-specific system config tells us to use
+- * dhcp for this device.
++ * Return whether the distro-specific system config tells us to disable 
++ * this device.
+  *
+  */
+ 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 device is listed in a mapping, do not control it */
++	if (ifparser_getmapping (iface) != NULL) {
++		blacklist = TRUE;
++		goto out;
++	}
++
++	/* 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") || !strcmp (curr_b->type, "allow-hotplug"))
++		    && 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;
+ }
+ 
+ 
+@@ -563,12 +612,18 @@ gboolean nm_system_deactivate_dialup (GSList *list, const char *dialup)
+ 		if (strcmp (dialup, config->name) == 0)
+ 		{
+ 			char *cmd;
++			int status;
+ 
+ 			nm_info ("Deactivating dialup device %s (%s) ...", dialup, (char *) config->data);
+ 			cmd = g_strdup_printf ("/sbin/ifdown %s", (char *) config->data);
+-			nm_spawn_process (cmd);
++			status = nm_spawn_process (cmd);
+ 			g_free (cmd);
+-			ret = TRUE;
++			if (status == 0) {
++				ret = TRUE;
++			} else {
++				nm_warning ("Couldn't deactivate dialup device %s (%s) - %d", dialup, (char *) config->data, status);
++				ret = FALSE;
++			}
+ 			break;
+ 		}
+ 	}
+@@ -587,12 +642,18 @@ gboolean nm_system_activate_dialup (GSList *list, const char *dialup)
+ 		if (strcmp (dialup, config->name) == 0)
+ 		{
+ 			char *cmd;
++			int status;
+ 
+ 			nm_info ("Activating dialup device %s (%s) ...", dialup, (char *) config->data);
+ 			cmd = g_strdup_printf ("/sbin/ifup %s", (char *) config->data);
+-			nm_spawn_process (cmd);
++			status = nm_spawn_process (cmd);
+ 			g_free (cmd);
+-			ret = TRUE;
++			if (status == 0) {
++				ret = TRUE;
++			} else {
++				nm_warning ("Couldn't activate dialup device %s (%s) - %d", dialup, (char *) config->data, status);
++				ret = FALSE;
++			}
+ 			break;
+ 		}
+ 	}
+@@ -603,23 +664,26 @@ gboolean nm_system_activate_dialup (GSList *list, const char *dialup)
+ GSList * nm_system_get_dialup_config (void)
+ {
+ 	const char *buf;
+-	unsigned int i = 0;
++	const char *provider;
+ 	GSList *list = NULL;
+ 	if_block *curr;
+ 	ifparser_init();
+ 
+ 	/* FIXME: get all ppp(and others?) lines from /e/n/i here */
+ 	curr = ifparser_getfirst();
+-	while(curr!=NULL)
++	while (curr != NULL)
+ 	{
+ 		NMDialUpConfig *config;
+-		if (strcmp(curr->type,"iface")==0) 
++		if (strcmp(curr->type, "iface") == 0) 
+ 		{
+-			buf = ifparser_getkey(curr,"inet");
+-			if (buf && strcmp (buf, "ppp")==0)
++			buf = ifparser_getkey(curr, "inet");
++			if (buf && strcmp (buf, "ppp") == 0)
+ 			{
++				provider = ifparser_getkey(curr, "provider");
++				if (!provider) 
++					provider = "default provider";
+ 				config = g_malloc (sizeof (NMDialUpConfig));
+-				config->name = g_strdup_printf ("Modem (#%d)", i++);
++				config->name = g_strdup_printf ("%s via Modem", provider);
+ 				config->data = g_strdup (curr->name);	/* interface name */
+ 
+ 				list = g_slist_append (list, config);
+@@ -631,14 +695,6 @@ GSList * nm_system_get_dialup_config (void)
+ 	}
+ 	ifparser_destroy();
+ 
+-	/* Hack: Go back and remove the "(#0)" if there is only one device */
+-	if (i == 1)
+-	{
+-		NMDialUpConfig *config = (NMDialUpConfig *) list->data;
+-		g_free (config->name);
+-		config->name = g_strdup ("Modem");
+-	}
+-
+ 	return list;
+ }
+ 
+@@ -679,7 +735,10 @@ void nm_system_set_hostname (NMIP4Config *config)
+  */
+ gboolean nm_system_should_modify_resolv_conf (void)
+ {
+-	return TRUE;
++	if (g_find_program_in_path(RESOLVCONF) != NULL)
++		return FALSE;
++	else
++		return TRUE;
+ }
+ 
+ 
+diff --git a/src/backends/interface_parser.c b/src/backends/interface_parser.c
+index 53d6487..b3ad300 100644
+--- a/src/backends/interface_parser.c
++++ b/src/backends/interface_parser.c
+@@ -71,14 +73,18 @@ void add_data(const char *key,const char *data)
+ 	//printf("added data '%s' with key '%s'\n",data,key);
+ }
+ 
+-#define SPACE_OR_TAB(string,ret) {ret = strchr(string,' ');ret=(ret == NULL?strchr(string,'\t'):ret);}
++// define what we consider a whitespace
++#define WS " \t"
+ 
+ void ifparser_init(void)
+ {
+ 	FILE *inp = fopen(INTERFACES,"r");
+ 	int ret = 0;
++	int pos;
++	int len;
+ 	char *line;
+-	char *space;
++	char *key;
++	char *data;
+ 	char rline[255];
+ 
+ 	if (inp == NULL)
+@@ -89,7 +95,7 @@ void ifparser_init(void)
+ 	first = last = NULL;
+ 	while(1)
+ 	{
+-		line = space = NULL;
++		line = NULL;
+ 		ret = fscanf(inp,"%255[^\n]\n",rline);
+ 		if (ret == EOF)
+ 			break;
+@@ -102,50 +108,71 @@ void ifparser_init(void)
+ 		line = rline;
+ 		while(line[0] == ' ')
+ 			line++;
+-		if (line[0]=='#' || line[0]=='\0')
++		if (line[0] == '#' || line[0] == '\0')
+ 			continue;
+ 		
+-		SPACE_OR_TAB(line,space)
+-		if (space == NULL)
++		len = strlen(line);
++		pos = 0;
++		while (!strchr(WS, line[pos]) && pos < len) pos++;
++
++		// terminate key string and skip further whitespaces
++		line[pos++] = '\0';
++		while (strchr(WS, line[pos]) && pos < len) pos++;
++
++		if (pos >= len)
+ 		{
+-			nm_warning ("Error: Can't parse interface line '%s'\n",line);
++			nm_warning ("Error: Can't parse line '%s'\n", line);
+ 			continue;
+ 		}
+-		space[0] = '\0';
+-		
++		key = &line[0];
++		data = &line[pos];
++
+ 		// There are four different stanzas:
+ 		// iface, mapping, auto and allow-*. Create a block for each of them.
+-		if (strcmp(line,"iface")==0)
++		if (strcmp(key, "iface") == 0)
+ 		{
+-			char *space2 = strchr(space+1,' ');
+-			if (space2 == NULL)
++			char *key2;
++
++			while (!strchr(WS, line[pos]) && pos < len ) pos++;
++
++			// terminate first data string and skip further whitespaces
++			line[pos++] = '\0';
++			while (strchr(WS, line[pos]) && pos < len) pos++;
++			if (pos >= len)
+ 			{
+-				nm_warning ("Error: Can't parse iface line '%s'\n",space+1);
++				nm_warning ("Error: Can't parse iface line '%s'\n", data);
+ 				continue;
+ 			}
+-			space2[0]='\0';
+-			add_block(line,space+1);
++			key2 = &line[pos];
++			
++			add_block(key, data);
+ 
+-			if (space2[1]!='\0')
++			if (pos < len)
+ 			{
+-				space = strchr(space2+1,' ');
+-				if (space == NULL)
++				
++				while (!strchr(WS, line[pos]) && pos < len ) pos++;
++
++				// terminate key2 string and skip further whitespaces
++				line[pos++] = '\0';
++				while (strchr(WS, line[pos]) && pos < len) pos++;
++				if (pos >= len)
+ 				{
+-					nm_warning ("Error: Can't parse data '%s'\n",space2+1);
++					nm_warning ("Error: Can't parse inet line '%s'\n", key2);
+ 					continue;
+ 				}
+-				space[0] = '\0';
+-				add_data(space2+1,space+1);
++				data = &line[pos];
++
++				add_data(key2, data);
+ 			}
+ 		}
+-		else if (strcmp(line,"auto")==0)
+-			add_block(line,space+1);
+-		else if (strcmp(line,"mapping")==0)
+-			add_block(line,space+1);
+-		else if (strncmp(line,"allow-",6)==0)
+-			add_block(line,space+1);
++		else if (strcmp(key, "auto") == 0)
++			add_block(key, data);
++		else if (strcmp(key, "mapping") == 0)
++			add_block(key, data);
++		else if (strncmp(key, "allow-", 6) == 0)
++			add_block(key, data);
+ 		else
+-			add_data(line,space+1);
++			add_data(key, data);
+ 		
+ 		//printf("line: '%s' ret=%d\n",rline,ret);
+ 	}
+@@ -198,6 +225,18 @@ if_block *ifparser_getif(const char* iface)
+ 	return NULL;
+ }
+ 
++if_block *ifparser_getmapping(const char* iface)
++{
++	if_block *curr = first;
++	while(curr!=NULL)
++	{
++		if (strcmp(curr->type,"mapping")==0 && strcmp(curr->name,iface)==0)
++			return curr;
++		curr = curr->next;
++	}
++	return NULL;
++}
++
+ const char *ifparser_getkey(if_block* iface, const char *key)
+ {
+ 	if_data *curr = iface->info;
+diff --git a/src/backends/interface_parser.h b/src/backends/interface_parser.h
+index 075f454..8914283 100644
+--- a/src/backends/interface_parser.h
++++ b/src/backends/interface_parser.h
+@@ -44,6 +44,7 @@ void ifparser_init(void);
+ void ifparser_destroy(void);
+ 
+ if_block *ifparser_getif(const char* iface);
++if_block *ifparser_getmapping(const char* iface);
+ if_block *ifparser_getfirst(void);
+ const char *ifparser_getkey(if_block* iface, const char *key);
+ 
diff --git a/debian/patches/06-dispatch_more_events.patch b/debian/patches/06-dispatch_more_events.patch
new file mode 100644
index 00000000..60d50432
--- /dev/null
+++ b/debian/patches/06-dispatch_more_events.patch
@@ -0,0 +1,99 @@
+--- dispatcher-daemon/NetworkManagerDispatcher.c.old	2006-08-13 22:40:18.000000000 +0200
++++ dispatcher-daemon/NetworkManagerDispatcher.c	2006-08-13 22:40:27.000000000 +0200
+@@ -44,6 +44,8 @@
+ 	NMD_DEVICE_DONT_KNOW,
+ 	NMD_DEVICE_NOW_INACTIVE,
+ 	NMD_DEVICE_NOW_ACTIVE,
++	NMD_DEVICE_GOING_INACTIVE,
++	NMD_DEVICE_GOING_ACTIVE,
+ };
+ typedef enum NMDAction	NMDAction;
+ 
+@@ -95,6 +97,10 @@
+ 	if (action == NMD_DEVICE_NOW_ACTIVE)
+ 		char_act = "up";
+ 	else if (action == NMD_DEVICE_NOW_INACTIVE)
++		char_act = "post-down";
++	else if (action == NMD_DEVICE_GOING_ACTIVE)
++		char_act = "pre-up";
++	else if (action == NMD_DEVICE_GOING_INACTIVE)
+ 		char_act = "down";
+ 	else
+ 		return;
+@@ -217,9 +223,13 @@
+ 	}
+ 
+ 	if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive"))
+-		action = NMD_DEVICE_NOW_INACTIVE;
++		action = NMD_DEVICE_GOING_INACTIVE;
+ 	else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive"))
+ 		action = NMD_DEVICE_NOW_ACTIVE;
++	else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivating"))
++		action = NMD_DEVICE_GOING_ACTIVE;
++	else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceDeactivated"))
++		action = NMD_DEVICE_NOW_INACTIVE;
+ 
+ 	if (action != NMD_DEVICE_DONT_KNOW)
+ 	{
+@@ -234,8 +244,10 @@
+ 			if (dev_object_path && dev_iface_name)
+ 			{
+ 				nm_info ("Device %s (%s) is now %s.", dev_object_path, dev_iface_name,
+-						(action == NMD_DEVICE_NOW_INACTIVE ? "down" :
+-						(action == NMD_DEVICE_NOW_ACTIVE ? "up" : "error")));
++						(action == NMD_DEVICE_NOW_INACTIVE ? "going down" :
++						(action == NMD_DEVICE_NOW_ACTIVE ? "up" :
++						(action == NMD_DEVICE_GOING_INACTIVE ? "going down" :
++						(action == NMD_DEVICE_GOING_ACTIVE ? "going up" : "error")))));
+ 
+ 				nmd_execute_scripts (action, dev_iface_name);
+ 			}
+--- man/NetworkManagerDispatcher.1.in	2006-02-01 19:14:15.000000000 +0100
++++ man/NetworkManagerDispatcher.1.in.new	2006-08-15 20:13:00.000000000 +0200
+@@ -12,10 +12,14 @@
+ directory in response to interfaces coming up and down.  The scripts are run
+ alphabetically.  The first parameter is the network interface name.  The second
+ parameter is
++.I pre\-up
++before bringing the interface up,
+ .I up
+-if the interface is now up and
++after bringing the interface up,
+ .I down
+-if the interface is now down.
++before taking the interface down and
++.I post\-down
++after taking the interface down.
+ .SH OPTIONS
+ The following options are supported:
+ .TP
+--- src/NetworkManagerDbus.c	2006-05-21 19:28:02.000000000 +0200
++++ src/NetworkManagerDbus.c.new	2006-08-15 20:15:18.000000000 +0200
+@@ -191,6 +191,7 @@
+ 	{ DEVICE_NOW_ACTIVE,		"DeviceNowActive"		},
+ 	{ DEVICE_ACTIVATING,		"DeviceActivating"		},
+ 	{ DEVICE_ACTIVATION_FAILED,	"DeviceActivationFailed"	},
++	{ DEVICE_DEACTIVATED,       "DeviceDeactivated"     },
+ 	{ DEVICE_ADDED,			"DeviceAdded"			},
+ 	{ DEVICE_REMOVED,			"DeviceRemoved"		},
+ 	{ DEVICE_CARRIER_ON,		"DeviceCarrierOn"		},
+--- src/NetworkManagerDbus.h	2006-05-21 19:28:02.000000000 +0200
++++ src/NetworkManagerDbus.h.new	2006-08-15 20:15:39.000000000 +0200
+@@ -40,6 +40,7 @@
+ 	DEVICE_ACTIVATING,
+ 	DEVICE_ACTIVATION_FAILED,
+ 	DEVICE_ACTIVATION_CANCELED,
++	DEVICE_DEACTIVATED,
+ 	DEVICE_ADDED,
+ 	DEVICE_REMOVED,
+ 	DEVICE_CARRIER_ON,
+--- src/nm-device.c	2006-07-10 22:30:49.000000000 +0200
++++ src/nm-device.c.new	2006-08-15 20:16:11.000000000 +0200
+@@ -1436,6 +1436,7 @@
+ 		NM_DEVICE_GET_CLASS (self)->deactivate (self);
+ 
+ 	nm_schedule_state_change_signal_broadcast (self->priv->app_data);
++	nm_dbus_schedule_device_status_change_signal (self->priv->app_data, self, NULL, DEVICE_DEACTIVATED);
+ }
+ 
+ 
diff --git a/debian/patches/11-man_page_sh_name.patch b/debian/patches/11-man_page_sh_name.patch
new file mode 100644
index 00000000..b363268c
--- /dev/null
+++ b/debian/patches/11-man_page_sh_name.patch
@@ -0,0 +1,15 @@
+Index: man/nm-tool.1.in
+===================================================================
+RCS file: /cvs/gnome/NetworkManager/man/nm-tool.1.in,v
+retrieving revision 1.1
+diff -u -3 -p -r1.1 nm-tool.1.in
+--- man/nm-tool.1.in	1 Feb 2006 18:14:15 -0000	1.1
++++ man/nm-tool.1.in	30 Nov 2006 19:33:39 -0000
+@@ -3,6 +3,7 @@
+ .\" Copyright (C) 2005 Robert Love
+ .\"
+ .TH NM-TOOL "1"
++.SH NAME
+ nm-tool \- utility to report NetworkManager state 
+ .SH SYNOPSIS
+ .B nm-tool
diff --git a/debian/patches/12_readme_format.patch b/debian/patches/12_readme_format.patch
new file mode 100644
index 00000000..5fa39d24
--- /dev/null
+++ b/debian/patches/12_readme_format.patch
@@ -0,0 +1,14 @@
+Index: README
+===================================================================
+--- README	(Revision 3190)
++++ README	(Arbeitskopie)
+@@ -20,7 +20,8 @@
+ For wireless networking support, NetworkManager keeps a list of wireless
+ networks, the preferred list.  Preferred Networks are wireless networks that
+ the user has explicitly made NetworkManager associate with at some previous
+-time.  So if the user walks into a Starbucks and explicitly asks NetworkManager to associate with that Starbucks network, NetworkManager will remember the
++time.  So if the user walks into a Starbucks and explicitly asks NetworkManager
++to associate with that Starbucks network, NetworkManager will remember the
+ Starbucks network information from that point on.  Upon returning to that
+ Starbucks, NetworkManager will attempt to associate _automatically_ with the
+ Starbucks network since it is now in the Preferred Networks list.  The point of
diff --git a/debian/patches/13-validate_mac_addr.patch b/debian/patches/13-validate_mac_addr.patch
new file mode 100644
index 00000000..47a81e19
--- /dev/null
+++ b/debian/patches/13-validate_mac_addr.patch
@@ -0,0 +1,33 @@
+--- network-manager-0.6.5.orig/src/nm-device-802-11-wireless.c
++++ network-manager-0.6.5/src/nm-device-802-11-wireless.c
+@@ -3439,6 +3439,20 @@
+ }
+ 
+ static gboolean
++has_valid_ether_addr (NMAccessPoint *ap)
++{
++	struct ether_addr *addr;
++	int i;
++
++	addr = nm_ap_get_address (ap);
++	for (i = 0 ; i < ETH_ALEN; i++)
++		if (addr->ether_addr_octet[i] != 0)
++			return TRUE;
++
++	return FALSE;
++}
++
++static gboolean
+ process_scan_results (NMDevice80211Wireless *dev,
+                       const guint8 *res_buf,
+                       guint32 res_buf_len)
+@@ -3474,7 +3488,8 @@
+ 
+ 				/* Merge previous AP */
+ 				if (ap) {
+-					add_new_ap_to_device_list (dev, ap);
++					if (has_valid_ether_addr (ap))
++						add_new_ap_to_device_list (dev, ap);
+ 					nm_ap_unref (ap);
+ 					ap = NULL;
+ 				}
diff --git a/debian/patches/20-stable_branch_updates_r2652.patch b/debian/patches/20-stable_branch_updates_r2652.patch
new file mode 100644
index 00000000..aea8e86f
--- /dev/null
+++ b/debian/patches/20-stable_branch_updates_r2652.patch
@@ -0,0 +1,914 @@
+Index: ChangeLog
+===================================================================
+--- ChangeLog	(Revision 2558)
++++ ChangeLog	(Revision 2652)
+@@ -1,3 +1,99 @@
++2007-07-26  Dan Williams  <dcbw@redhat.com>
++
++	Patch from Bernhard Miklautz <bernhard.miklautz@shacknet.at>
++
++	* src/NetworkManagerSystem.c
++		- (nm_system_device_set_ip4_route): don't add the route if it's on the
++			same subnet (#437396)
++
++2007-07-26  Dan Williams  <dcbw@redhat.com>
++
++	* src/nm-device-802-11-wireless.c
++		- (real_start): I hate orinoco; apparently has trouble scanning too soon
++			after being brought up, so do the initial scan a bit later.
++
++2007-06-27  Dan Williams  <dcbw@redhat.com>
++
++	* src/NetworkManager.c
++		- (nm_hal_init): set hardware RF to enabled if no killswitches are found
++			after the initial discovery
++
++2007-06-21  Dan Williams  <dcbw@redhat.com>
++
++	More fixes for Fedora #194124, gnome.org #354565
++
++	* src/nm-device-802-3-ethernet.c
++		- (real_act_stage1_prepare): new function; fail activation if device
++			doesn't have a link
++
++	* src/NetworkManagerPolicy.c
++		- (nm_policy_activation_finish): ensure device is actually activated
++			before sending out signals.  Fixes a race where device cancellation
++			would be processed right after finish was scheduled, but not run.
++		- (nm_policy_device_change_check, nm_policy_schedule_device_change_check):
++			ensure device change check GSource ID is locked across threads;
++			allow interruption of activation of 802.3 ethernet devices that no
++			longer have an active link, and ensure that 802.3 ethernet devices
++			have an active link before starting activation
++
++2007-06-21  Dan Williams  <dcbw@redhat.com>
++
++	Add HAL-based rfkill support, based on a patch from Benjamin Kahn.
++
++	* src/NetworkManagerDbus.[ch]
++		- (nm_dbus_signal_wireless_enabled): new function, emit signals when
++			wireless enabled status changes
++
++	* src/nm-dbus-nm.c
++		- (nm_dbus_nm_set_wireless_enabled): handle hardware rfkill correctly;
++			send errors when hardware switch overrides user request, and send
++			signals when wireless enabled state changes
++		- (nm_dbus_nm_get_wireless_enabled): send additional 'hardware rf enabled'
++			argument in method reply
++
++	* src/NetworkManager.c
++		- (handle_killswitch_pcall_done, nm_killswitch_getpower_reply_cb,
++		   nm_poll_killswitches, nm_add_killswitch_device,
++		   nm_add_initial_killswitch_devices): new functions; detect and handle
++			hardware killswitches exported by HAL.  Unfortunately we have to
++			poll the switches because HAL doesn't support signals for killswitches
++			yet.
++		- (nm_hal_device_new_capability): detect killswitches added asynchronously
++		- (nm_hal_init): look for killswitches when connecting to HAL
++		- (nm_hal_deinit): dispose of killswitches when deiniting HAL data
++
++	* src/NetworkManagerMain.h
++		- Add bits to track killswitches
++
++2007-06-12  Dan Williams  <dcbw@redhat.com>
++
++	* src/nm-device.c
++		- (real_act_stage3_ip_config_start): sometimes the device gets downed
++			during the wpa_supplicant association.  Ensure the device is up
++			before it's used for IP configuration.
++
++2007-06-07  Dan Williams  <dcbw@redhat.com>
++
++	Patch from Jon Nettleton <jon.nettleton@gmail.com>
++
++	* src/nm-device-802-11-wireless.c:
++		- (real_act_stage2_config): sleep 1 second to allow link status
++		to stabilize
++
++2007-06-07  Dan Williams  <dcbw@redhat.com>
++
++	* (nm_device_802_3_ethernet_link_activated,
++	   nm_device_802_3_ethernet_link_deactivated): fix ethernet link detection
++		behavior due to races between the netlink code and when the
++		device thread recognizes the change.  Checking the link state
++		before scheduling the change even on the device thread is wrong.
++		(gnome.org #354565, rh #194124)
++
++2007-04-25  Dan Williams  <dcbw@redhat.com>
++
++	* initscript/RedHat/NetworkManager.in: remove trailing backslash
++		(gnome.org #432401)
++
+ 2007-04-18  Tambet Ingo  <tambet@ximian.com>
+ 
+ 	* src/nm-dbus-nmi.c (nm_dbus_get_user_key_for_network_cb): Update the security
+Index: src/NetworkManagerDbus.c
+===================================================================
+--- src/NetworkManagerDbus.c	(Revision 2558)
++++ src/NetworkManagerDbus.c	(Revision 2652)
+@@ -434,6 +434,29 @@
+ }
+ 
+ 
++void nm_dbus_signal_wireless_enabled (NMData * data)
++{
++	DBusMessage *	message;
++
++	g_return_if_fail (data != NULL);
++	g_return_if_fail (data->dbus_connection != NULL);
++
++	if (!(message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "WirelessEnabled")))
++	{
++		nm_warning ("%s(): Not enough memory for new dbus message!", __func__);
++		return;
++	}
++
++	dbus_message_append_args (message,
++	                          DBUS_TYPE_BOOLEAN, &data->wireless_enabled,
++	                          DBUS_TYPE_BOOLEAN, &data->hw_rf_enabled,
++	                          DBUS_TYPE_INVALID);
++	if (!dbus_connection_send (data->dbus_connection, message, NULL))
++		nm_warning ("%s(): Could not emit the WirelessEnabled signal!", __func__);
++
++	dbus_message_unref (message);
++}
++
+ /*
+  * nm_dbus_signal_filter
+  *
+Index: src/NetworkManagerDbus.h
+===================================================================
+--- src/NetworkManagerDbus.h	(Revision 2558)
++++ src/NetworkManagerDbus.h	(Revision 2652)
+@@ -68,6 +68,7 @@
+ 
+ void			nm_dbus_signal_wireless_network_change	(DBusConnection *connection, NMDevice80211Wireless *dev, NMAccessPoint *ap, NMNetworkStatus status, gint strength);
+ void			nm_dbus_signal_device_strength_change	(DBusConnection *connection, NMDevice80211Wireless *dev, gint strength);
++void			nm_dbus_signal_wireless_enabled (NMData * data);
+ 
+ NMDevice *	nm_dbus_get_device_from_escaped_object_path	(NMData *data, const char *path);
+ 
+Index: src/nm-dbus-nm.c
+===================================================================
+--- src/nm-dbus-nm.c	(Revision 2558)
++++ src/nm-dbus-nm.c	(Revision 2652)
+@@ -483,53 +483,84 @@
+ 	return (reply);
+ }
+ 
+-static DBusMessage *nm_dbus_nm_set_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
++static DBusMessage *nm_dbus_nm_set_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *cb_data)
+ {
+ 	gboolean	enabled = FALSE;
+ 	DBusError	err;
+-	NMData	*app_data;
++	NMData	*	data;
++	DBusMessage * ret = NULL;
+ 
+-	g_return_val_if_fail (data && data->data && connection && message, NULL);
++	g_return_val_if_fail (cb_data && cb_data->data && connection && message, NULL);
+ 
+ 	dbus_error_init (&err);
+ 	if (!dbus_message_get_args (message, &err, DBUS_TYPE_BOOLEAN, &enabled, DBUS_TYPE_INVALID))
+-		return NULL;
++		goto out;
+ 
+-	app_data = data->data;
+-	app_data->wireless_enabled = enabled;
++	data = cb_data->data;
++	if (enabled == data->wireless_enabled)
++		goto out;
+ 
+-	if (!enabled)
+-	{
+-		GSList	*elt;
++	/* Hardware rfkill overrides whatever user wants */
++	if (!data->hw_rf_enabled) {
++		nm_info ("User request to %s wireless overridden by radio killswitch.",
++		         enabled ? "enable" : "disable");
+ 
+-		/* Physically down all wireless devices */
+-		nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
+-		for (elt = app_data->dev_list; elt; elt = g_slist_next (elt))
+-		{
+-			NMDevice	*dev = (NMDevice *)(elt->data);
+-			if (nm_device_is_802_11_wireless (dev))
+-			{
++		/* Return error if user tries to re-enable wireless, or just ignore
++		 * a disable wireless request when wireless is already disabled.
++		 */
++		if (enabled) {
++			ret = nm_dbus_create_error_message (message,
++			                                    NM_DBUS_INTERFACE,
++			                                    "DisabledBySystem",
++			                                    "Wireless disabled by hardware switch.");
++		}
++		goto out;
++	}
++
++	nm_info ("User request to %s wireless.", enabled ? "enable" : "disable");
++
++	data->wireless_enabled = enabled;
++	if (!data->wireless_enabled) {
++		GSList * elt;
++
++		/* Deactivate all wireless devices and force them down so they
++		 * turn off their radios.
++		 */
++		nm_lock_mutex (data->dev_list_mutex, __FUNCTION__);
++		for (elt = data->dev_list; elt; elt = g_slist_next (elt)) {
++			NMDevice * dev = (NMDevice *) elt->data;
++			if (nm_device_is_802_11_wireless (dev)) {
+ 				nm_device_deactivate (dev);
+ 				nm_device_bring_down (dev);
+ 			}
+ 		}
+-		nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
++		nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
+ 	}
+ 
+-	nm_policy_schedule_device_change_check (data->data);
++	nm_policy_schedule_device_change_check (data);
++	nm_dbus_signal_wireless_enabled (data);
+ 
+-	return NULL;
++out:
++	return ret;
+ }
+ 
+-static DBusMessage *nm_dbus_nm_get_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
++static DBusMessage *nm_dbus_nm_get_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *cb_data)
+ {
++	NMData * data;
+ 	DBusMessage	*reply = NULL;
+ 
+-	g_return_val_if_fail (data && data->data && connection && message, NULL);
++	g_return_val_if_fail (cb_data && connection && message, NULL);
+ 
+-	if ((reply = dbus_message_new_method_return (message)))
+-		dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &data->data->wireless_enabled, DBUS_TYPE_INVALID);
++	data = cb_data->data;
++	g_return_val_if_fail (data != NULL, NULL);
+ 
++	if ((reply = dbus_message_new_method_return (message))) {
++		dbus_message_append_args (reply,
++		                          DBUS_TYPE_BOOLEAN, &data->wireless_enabled,
++		                          DBUS_TYPE_BOOLEAN, &data->hw_rf_enabled,
++		                          DBUS_TYPE_INVALID);
++	}
++
+ 	return reply;
+ }
+ 
+Index: src/nm-device-802-3-ethernet.c
+===================================================================
+--- src/nm-device-802-3-ethernet.c	(Revision 2558)
++++ src/nm-device-802-3-ethernet.c	(Revision 2652)
+@@ -108,18 +108,16 @@
+                                          GObject *obj,
+                                          NMDevice8023Ethernet *self)
+ {
++	GSource * source;
++
+ 	/* Make sure signal is for us */
+ 	if (NM_DEVICE (self) != NM_DEVICE (obj))
+ 		return;
+ 
+-	if (!nm_device_has_active_link (NM_DEVICE (self)))
+-	{
+-		GSource *	source = g_idle_source_new ();
+-
+-		g_source_set_callback (source, (GSourceFunc) link_activated_helper, self, NULL);
+-		g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
+-		g_source_unref (source);
+-	}
++	source = g_idle_source_new ();
++	g_source_set_callback (source, (GSourceFunc) link_activated_helper, self, NULL);
++	g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
++	g_source_unref (source);
+ }
+ 
+ 
+@@ -135,18 +133,16 @@
+                                            GObject *obj,
+                                            NMDevice8023Ethernet *self)
+ {
++	GSource * source;
++
+ 	/* Make sure signal is for us */
+ 	if (NM_DEVICE (self) != NM_DEVICE (obj))
+ 		return;
+ 
+-	if (nm_device_has_active_link (NM_DEVICE (self)))
+-	{
+-		GSource *	source = g_idle_source_new ();
+-
+-		g_source_set_callback (source, (GSourceFunc) link_deactivated_helper, self, NULL);
+-		g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
+-		g_source_unref (source);
+-	}
++	source = g_idle_source_new ();
++	g_source_set_callback (source, (GSourceFunc) link_deactivated_helper, self, NULL);
++	g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
++	g_source_unref (source);
+ }
+ 
+ static void
+@@ -211,6 +207,26 @@
+ 	return caps;
+ }
+ 
++
++static NMActStageReturn
++real_act_stage1_prepare (NMDevice *dev, NMActRequest *req)
++{
++	NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (dev);
++	NMDevice8023EthernetClass *	klass;
++	NMDeviceClass * parent_class;
++
++	/* Ensure ethernet devices have a link before going further with activation,
++	 * partially works around Fedora #194124.
++	 */
++	if (!nm_device_has_active_link (dev))
++		return NM_ACT_STAGE_RETURN_FAILURE;
++
++	/* Chain up to parent */
++	klass = NM_DEVICE_802_3_ETHERNET_GET_CLASS (self);
++	parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
++	return parent_class->act_stage1_prepare (dev, req);
++}
++
+ static void
+ nm_device_802_3_ethernet_dispose (GObject *object)
+ {
+@@ -275,6 +291,7 @@
+ 	parent_class->get_generic_capabilities = real_get_generic_capabilities;
+ 	parent_class->init = real_init;
+ 	parent_class->update_link = real_update_link;
++	parent_class->act_stage1_prepare = real_act_stage1_prepare;
+ 
+ 	g_type_class_add_private (object_class, sizeof (NMDevice8023EthernetPrivate));
+ }
+Index: src/NetworkManagerPolicy.c
+===================================================================
+--- src/NetworkManagerPolicy.c	(Revision 2558)
++++ src/NetworkManagerPolicy.c	(Revision 2652)
+@@ -52,6 +52,7 @@
+ 	NMDevice			*dev = NULL;
+ 	NMData			*data = NULL;
+ 	NMAccessPoint *	ap = NULL;
++	NMActRequest * dev_req;
+ 
+ 	g_return_val_if_fail (req != NULL, FALSE);
+ 
+@@ -61,6 +62,13 @@
+ 	dev = nm_act_request_get_dev (req);
+ 	g_assert (dev);
+ 
++	/* Ensure that inactive devices don't get the activated signal
++	 * sent due to race conditions.
++	 */
++	dev_req = nm_device_get_act_request (dev);
++	if (!dev_req || (dev_req != req))
++		return FALSE;
++
+     if (nm_device_is_802_11_wireless (dev))
+         ap = nm_act_request_get_ap (req);
+ 
+@@ -265,14 +273,16 @@
+ 	}
+ 
+ #if 0
+-	nm_info ("AUTO: Best wired device = %s, best wireless device = %s (%s)", best_wired_dev ? nm_device_get_iface (best_wired_dev) : "(null)",
+-			best_wireless_dev ? nm_device_get_iface (best_wireless_dev) : "(null)", (best_wireless_dev && *ap) ? nm_ap_get_essid (*ap) : "null" );
++	nm_info ("AUTO: Best wired device = %s, best wireless device = %s (%s)", best_wired_dev ? nm_device_get_iface (NM_DEVICE (best_wired_dev)) : "(null)",
++			best_wireless_dev ? nm_device_get_iface (NM_DEVICE (best_wireless_dev)) : "(null)", (best_wireless_dev && *ap) ? nm_ap_get_essid (*ap) : "null" );
+ #endif
+ 
+ 	return highest_priority_dev;
+ }
+ 
+ 
++static GStaticMutex dcc_mutex = G_STATIC_MUTEX_INIT;
++
+ /*
+  * nm_policy_device_change_check
+  *
+@@ -294,7 +304,9 @@
+ 
+ 	g_return_val_if_fail (data != NULL, FALSE);
+ 
++	g_static_mutex_lock (&dcc_mutex);
+ 	data->dev_change_check_idle_id = 0;
++	g_static_mutex_unlock (&dcc_mutex);
+ 
+ 	old_dev = nm_get_active_device (data);
+ 
+@@ -303,11 +315,19 @@
+ 
+ 	if (old_dev)
+ 	{
++		gboolean has_link = TRUE;
+ 		guint32 caps = nm_device_get_capabilities (old_dev);
+ 
++		/* Ensure ethernet devices have a link before starting activation,
++		 * partially works around Fedora #194124.
++		 */
++		if (nm_device_is_802_3_ethernet (old_dev))
++			has_link = nm_device_has_active_link (old_dev);
++
+ 		/* Don't interrupt a currently activating device. */
+ 		if (   nm_device_is_activating (old_dev)
+-		    && !nm_device_can_interrupt_activation (old_dev))
++		    && !nm_device_can_interrupt_activation (old_dev)
++		    && has_link)
+ 		{
+ 			nm_info ("Old device '%s' activating, won't change.", nm_device_get_iface (old_dev));
+ 			goto out;
+@@ -425,13 +445,36 @@
+ 	if (do_switch && (nm_device_is_802_3_ethernet (new_dev) || (nm_device_is_802_11_wireless (new_dev) && ap)))
+ 	{
+ 		NMActRequest *	act_req = NULL;
++		gboolean has_link = TRUE;
+ 
+-		if ((act_req = nm_act_request_new (data, new_dev, ap, FALSE)))
++		/* Ensure ethernet devices have a link before starting activation,
++		 * partially works around Fedora #194124.
++		 */
++		if (nm_device_is_802_3_ethernet (new_dev))
++			has_link = nm_device_has_active_link (new_dev);
++
++		if (has_link)
+ 		{
+-			nm_info ("Will activate connection '%s%s%s'.", nm_device_get_iface (new_dev), ap ? "/" : "", ap ? nm_ap_get_essid (ap) : "");
+-			nm_policy_schedule_device_activation (act_req);
+-			nm_act_request_unref (act_req);
++			if ((act_req = nm_act_request_new (data, new_dev, ap, FALSE)))
++			{
++				nm_info ("Will activate connection '%s%s%s'.",
++				         nm_device_get_iface (new_dev),
++				         ap ? "/" : "",
++				         ap ? nm_ap_get_essid (ap) : "");
++				nm_policy_schedule_device_activation (act_req);
++				nm_act_request_unref (act_req);
++			}
++			else
++			{
++				nm_info ("Error creating activation request for %s",
++				         nm_device_get_iface (new_dev));
++			}
+ 		}
++		else
++		{
++			nm_info ("Won't activate %s because it no longer has a link.",
++			         nm_device_get_iface (new_dev));
++		}
+ 	}
+ 
+ 	if (ap)
+@@ -452,11 +495,9 @@
+  */
+ void nm_policy_schedule_device_change_check (NMData *data)
+ {
+-	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+-
+ 	g_return_if_fail (data != NULL);
+ 
+-	g_static_mutex_lock (&mutex);
++	g_static_mutex_lock (&dcc_mutex);
+ 
+ 	if (data->dev_change_check_idle_id == 0)
+ 	{
+@@ -466,8 +507,7 @@
+ 		data->dev_change_check_idle_id = g_source_attach (source, data->main_context);
+ 		g_source_unref (source);
+ 	}
+-
+-	g_static_mutex_unlock (&mutex);
++	g_static_mutex_unlock (&dcc_mutex);
+ }
+ 
+ 
+Index: src/nm-ap-security-wpa-eap.c
+===================================================================
+--- src/nm-ap-security-wpa-eap.c	(Revision 2558)
++++ src/nm-ap-security-wpa-eap.c	(Revision 2652)
+@@ -57,7 +57,6 @@
+ 	NMAPSecurityWPA_EAP *	security = NULL;
+ 	int					eap_method;
+ 	int					key_type;
+-	int					phase2_type;
+ 	int					wpa_version;
+ 	char *				identity = NULL;
+ 	char *				passwd = NULL;
+Index: src/nm-device.c
+===================================================================
+--- src/nm-device.c	(Revision 2558)
++++ src/nm-device.c	(Revision 2652)
+@@ -856,6 +856,12 @@
+ 	data = nm_act_request_get_data (req);
+ 	g_assert (data);
+ 
++	/* Sometimes the device gets downed by wpa_supplicant; in any case, make
++	 * sure it's up before anything tries to use it.
++	 */
++	if (!nm_device_is_up (self))
++		nm_device_bring_up (self);
++
+ 	/* DHCP devices try DHCP, non-DHCP default to SUCCESS */
+ 	if (nm_device_get_use_dhcp (self))
+ 	{
+Index: src/NetworkManager.c
+===================================================================
+--- src/NetworkManager.c	(Revision 2558)
++++ src/NetworkManager.c	(Revision 2652)
+@@ -67,6 +67,7 @@
+ 
+ static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, gpointer data);
+ static void nm_data_free (NMData *data);
++static gboolean nm_poll_killswitches(gpointer user_data);
+ 
+ /*
+  * nm_get_device_interface_from_hal
+@@ -274,7 +275,184 @@
+ }
+ 
+ 
++static void handle_killswitch_pcall_done (NMData *data, DBusPendingCall * pcall)
++{
++	GSource * source;
++	gboolean now_enabled = FALSE;
++	gboolean now_disabled = FALSE;
++
++	data->ks_pcall_list = g_slist_remove (data->ks_pcall_list, pcall);
++	if (g_slist_length (data->ks_pcall_list) > 0)
++		return;  /* not done with all killswitches yet */
++
++	if (data->hw_rf_enabled != data->tmp_hw_rf_enabled) {
++		nm_info ("Wireless now %s by radio killswitch",
++		         data->tmp_hw_rf_enabled ? "enabled" : "disabled");
++		if (data->tmp_hw_rf_enabled)
++			now_enabled = TRUE;
++		else
++			now_disabled = TRUE;
++
++		data->hw_rf_enabled = data->tmp_hw_rf_enabled;
++	}
++
++	if (data->hw_rf_enabled == data->wireless_enabled)
++		goto out;
++
++	/* Only re-enabled wireless if killswitch just changed, otherwise
++	 * ignore hardware rf enabled state.
++	 */
++	if (now_enabled && !data->wireless_enabled) {
++		data->wireless_enabled = TRUE;
++		nm_policy_schedule_device_change_check (data);
++		nm_dbus_signal_wireless_enabled (data);
++	} else if (!data->hw_rf_enabled && data->wireless_enabled) {
++		GSList * elt;
++
++		/* Deactivate all wireless devices and force them down so they
++		 * turn off their radios.
++		 */
++		nm_lock_mutex (data->dev_list_mutex, __FUNCTION__);
++		for (elt = data->dev_list; elt; elt = g_slist_next (elt)) {
++			NMDevice * dev = (NMDevice *) elt->data;
++			if (nm_device_is_802_11_wireless (dev)) {
++				nm_device_deactivate (dev);
++				nm_device_bring_down (dev);
++			}
++		}
++		nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
++
++		data->wireless_enabled = FALSE;
++		nm_policy_schedule_device_change_check (data);
++		nm_dbus_signal_wireless_enabled (data);
++	}
++
++out:
++	/* Schedule another killswitch poll */
++	source = g_timeout_source_new (6000);
++	g_source_set_callback (source, nm_poll_killswitches, data, NULL);
++	g_source_attach (source, data->main_context);
++	g_source_unref (source);
++}
++
++static void nm_killswitch_getpower_reply_cb (DBusPendingCall *pcall, NMData * data)
++{
++	DBusError		err;
++	DBusMessage *	reply = NULL;
++	guint32			status;
++
++	g_return_if_fail (pcall != NULL);
++	g_return_if_fail (data != NULL);
++
++	if (!dbus_pending_call_get_completed (pcall))
++		goto out;
++
++	if (!(reply = dbus_pending_call_steal_reply (pcall)))
++		goto out;
++
++	if (message_is_error (reply)) {
++		dbus_error_init (&err);
++		dbus_set_error_from_message (&err, reply);
++		nm_info ("Error getting killswitch power: %s - %s", err.name, err.message);
++		dbus_error_free (&err);
++		goto out;
++	}
++
++	if (!dbus_message_get_args (reply, &err, DBUS_TYPE_UINT32, &status, DBUS_TYPE_INVALID)) {
++		nm_info ("Error getting killswitch power arguments: %s - %s", err.name, err.message);
++		dbus_error_free (&err);
++		goto out;
++	}
++
++	if (status == 0)
++		data->tmp_hw_rf_enabled = FALSE;
++
++out:
++	if (reply)
++		dbus_message_unref (reply);
++
++	handle_killswitch_pcall_done (data, pcall);
++	dbus_pending_call_unref (pcall);
++}
++
++
++static gboolean nm_poll_killswitches (gpointer user_data)
++{
++	NMData * data = (NMData *) user_data;
++	DBusConnection * connection = data->dbus_connection;
++	GSList * elt;
++
++	g_return_val_if_fail (data != NULL, FALSE);
++
++	data->tmp_hw_rf_enabled = TRUE;
++
++	for (elt = data->killswitch_list; elt; elt = g_slist_next (elt))
++	{
++		DBusPendingCall * pcall;
++		DBusMessage * message;
++
++		message = dbus_message_new_method_call ("org.freedesktop.Hal",
++		                                        elt->data,
++		                                        "org.freedesktop.Hal.Device.KillSwitch",
++		                                        "GetPower");
++		if (!dbus_connection_send_with_reply (connection, message, &pcall, 5000)) {
++			nm_warning ("%s(): could not send dbus message", __func__);
++		} else if (!pcall) {
++			nm_warning ("%s(): could not send dbus message; pcall was NULL", __func__);
++		} else {
++			dbus_pending_call_set_notify (pcall,
++			                              (DBusPendingCallNotifyFunction) nm_killswitch_getpower_reply_cb,
++			                              data,
++			                              NULL);
++			data->ks_pcall_list = g_slist_append (data->ks_pcall_list, pcall);
++		}
++		dbus_message_unref (message);
++	}
++	return FALSE;
++}
++
++
+ /*
++ * nm_add_killswitch_device
++ *
++ * Adds a killswitch device to the list
++ *
++ */
++static void nm_add_killswitch_device (NMData * data, const char * udi)
++{
++	char * type;
++	GSList * elt;
++
++	type = libhal_device_get_property_string (data->hal_ctx, udi, "killswitch.type", NULL);
++	if (!type)
++		return;
++
++	if (strcmp (type, "wlan") != 0)
++		goto out;
++
++	/* see if it's already in the list */
++	for (elt = data->killswitch_list; elt; elt = g_slist_next (elt)) {
++		const char * list_udi = (const char *) elt->data;
++		if (strcmp (list_udi, udi) == 0)
++			goto out;
++	}
++
++	/* Start polling switches if this is the first switch we've found */
++	if (g_slist_length (data->killswitch_list) == 0) {
++		GSource * source = g_idle_source_new ();
++		g_source_set_callback (source, nm_poll_killswitches, data, NULL);
++		g_source_attach (source, data->main_context);
++		g_source_unref (source);
++	}
++
++	data->killswitch_list = g_slist_append (data->killswitch_list, g_strdup (udi));
++	nm_info ("Found radio killswitch %s", udi);
++
++out:
++	libhal_free_string (type);
++}
++
++/*
+  * nm_hal_device_new_capability
+  *
+  */
+@@ -283,10 +461,9 @@
+ 	NMData	*data = (NMData *)libhal_ctx_get_user_data (ctx);
+ 
+ 	g_return_if_fail (data != NULL);
++	g_return_if_fail (capability != NULL);
+ 
+-	/*nm_debug ("nm_hal_device_new_capability() called with udi = %s, capability = %s", udi, capability );*/
+-
+-	if (capability && ((strcmp (capability, "net.80203") == 0) || (strcmp (capability, "net.80211") == 0)))
++	if (((strcmp (capability, "net.80203") == 0) || (strcmp (capability, "net.80211") == 0)))
+ 	{
+ 		char *iface;
+ 
+@@ -296,6 +473,10 @@
+ 			g_free (iface);
+ 		}
+ 	}
++	else if (strcmp (capability, "killswitch") == 0)
++	{
++		nm_add_killswitch_device (data, udi);
++	}
+ }
+ 
+ 
+@@ -340,7 +521,31 @@
+ 	libhal_free_string_array (net_devices);
+ }
+ 
++void nm_add_initial_killswitch_devices (NMData * data)
++{
++	char ** udis;
++	int		num_udis, i;
++	DBusError	error;
+ 
++	g_return_if_fail (data != NULL);
++
++	dbus_error_init (&error);
++	udis = libhal_find_device_by_capability (data->hal_ctx, "killswitch", &num_udis, &error);
++	if (!udis)
++		return;
++
++	if (dbus_error_is_set (&error)) {
++		nm_warning("Could not find killswitch devices: %s", error.message);
++		dbus_error_free (&error);
++		return;
++	}
++
++	for (i = 0; i < num_udis; i++)
++		nm_add_killswitch_device (data, udis[i]);
++	libhal_free_string_array (udis);
++}
++
++
+ /*
+  * nm_state_change_signal_broadcast
+  *
+@@ -616,28 +821,39 @@
+ 	g_return_if_fail (data != NULL);
+ 
+ 	if ((data->hal_ctx = nm_get_hal_ctx (data)))
++	{
++		nm_add_initial_killswitch_devices (data);
+ 		nm_add_initial_devices (data);
++	}
++
++	/* If there weren't any killswitches, mark hardware RF to on */
++	if (g_slist_length (data->killswitch_list) == 0)
++		data->hw_rf_enabled = TRUE;
+ }
+ 
+ 
+ void nm_hal_deinit (NMData *data)
+ {
++	DBusError error;
++
+ 	g_return_if_fail (data != NULL);
+ 
+-	if (data->hal_ctx)
++	if (!data->hal_ctx)
++		return;
++
++	g_slist_foreach (data->killswitch_list, (GFunc) g_free, NULL);
++	g_slist_free (data->killswitch_list);
++	data->killswitch_list = NULL;
++
++	dbus_error_init (&error);
++	libhal_ctx_shutdown (data->hal_ctx, &error);
++	if (dbus_error_is_set (&error))
+ 	{
+-		DBusError error;
+-
+-		dbus_error_init (&error);
+-		libhal_ctx_shutdown (data->hal_ctx, &error);
+-		if (dbus_error_is_set (&error))
+-		{
+-			nm_warning ("libhal shutdown failed - %s", error.message);
+-			dbus_error_free (&error);
+-		}
+-		libhal_ctx_free (data->hal_ctx);
+-		data->hal_ctx = NULL;
++		nm_warning ("libhal shutdown failed - %s", error.message);
++		dbus_error_free (&error);
+ 	}
++	libhal_ctx_free (data->hal_ctx);
++	data->hal_ctx = NULL;
+ }
+ 
+ 
+Index: src/nm-device-802-11-wireless.c
+===================================================================
+--- src/nm-device-802-11-wireless.c	(Revision 2558)
++++ src/nm-device-802-11-wireless.c	(Revision 2652)
+@@ -617,7 +617,10 @@
+ 	/* Start the scanning timeout for devices that can do scanning */
+ 	if (nm_device_get_capabilities (dev) & NM_DEVICE_CAP_WIRELESS_SCAN)
+ 	{
+-		self->priv->pending_scan = g_idle_source_new ();
++		/* Stupid orinoco has problems scanning immediately after being up,
++		 * so wait a bit before triggering a scan.
++		 */
++		self->priv->pending_scan = g_timeout_source_new (600);
+ 		g_source_set_callback (self->priv->pending_scan,
+ 							   nm_device_802_11_wireless_scan,
+ 							   self,
+@@ -2981,6 +2984,9 @@
+ 		return NM_ACT_STAGE_RETURN_POSTPONE;
+ 	}
+ 
++	/* Some cards are dumb.  Wait a second */
++	sleep (1);
++
+ 	iface = nm_device_get_iface (dev);
+ 	if (!supplicant_exec (self))
+ 	{
+@@ -3446,10 +3452,9 @@
+ 	char *genie, *gpos, *gend, *custom;
+ 	NMAccessPoint *ap = NULL;
+ 	size_t clen;
+-	int maxrate;
++	int maxrate = 0;
+ 	struct iw_event iwe_buf, *iwe = &iwe_buf;
+ 	struct stream_descr	stream;
+-	struct wireless_scan *	wscan = NULL;
+ 	int			ret;
+ 
+ 	g_return_val_if_fail (dev != NULL, FALSE);
+Index: src/NetworkManagerMain.h
+===================================================================
+--- src/NetworkManagerMain.h	(Revision 2558)
++++ src/NetworkManagerMain.h	(Revision 2652)
+@@ -82,6 +82,7 @@
+ 	GSList *				dev_list;
+ 	GMutex *				dev_list_mutex;
+ 
++	gboolean				hw_rf_enabled;
+ 	gboolean				wireless_enabled;
+ 	gboolean				modem_active;
+ 	gboolean				asleep;
+@@ -90,6 +91,10 @@
+ 	GSList *				dialup_list;
+ 	GMutex *				dialup_list_mutex;
+ 
++	GSList *				killswitch_list;
++	GSList *				ks_pcall_list; /* track killswitch D-Bus pending calls */
++	gboolean				tmp_hw_rf_enabled;
++
+ 	struct NMAccessPointList	*allowed_ap_list;
+ 	struct NMAccessPointList	*invalid_ap_list;
+ } NMData;
+Index: src/NetworkManagerSystem.c
+===================================================================
+--- src/NetworkManagerSystem.c	(Revision 2558)
++++ src/NetworkManagerSystem.c	(Revision 2652)
+@@ -64,6 +64,7 @@
+ 	struct sockaddr_in *p;
+ 	const char *		iface;
+ 	int				err;
++	NMIP4Config * config = NULL;
+ 
+ 	iface = nm_device_get_iface (dev);
+ 
+@@ -75,6 +76,15 @@
+ 	if (ip4_gateway == 0)
+ 		return TRUE;
+ 
++	/*
++	 * Do not add the route if the destination is on the same subnet.
++	 */
++	config = nm_device_get_ip4_config(dev);
++	if (config &&
++	    ((guint32)ip4_dest & nm_ip4_config_get_netmask(config)) ==
++	        (nm_ip4_config_get_address(config) & nm_ip4_config_get_netmask(config)))
++		return TRUE;
++
+ 	if ((sk = nm_dev_sock_open (dev, NETWORK_CONTROL, __FUNCTION__, NULL)) == NULL)
+ 		return FALSE;
+ 
diff --git a/debian/patches/21-endianess_fix_r2754.patch b/debian/patches/21-endianess_fix_r2754.patch
new file mode 100644
index 00000000..4932e22a
--- /dev/null
+++ b/debian/patches/21-endianess_fix_r2754.patch
@@ -0,0 +1,28 @@
+Index: ChangeLog
+===================================================================
+--- ChangeLog	(Revision 2753)
++++ ChangeLog	(Revision 2754)
+@@ -1,3 +1,8 @@
++2007-08-30  Dan Williams  <dcbw@redhat.com>
++
++	* libnm-util/sha1.c
++		- Include config.h to get defines for endiannes (gnome.org #420216)
++
+ 2007-07-26  Dan Williams  <dcbw@redhat.com>
+ 
+ 	Patch from Bernhard Miklautz <bernhard.miklautz@shacknet.at>
+Index: libnm-util/sha1.c
+===================================================================
+--- libnm-util/sha1.c	(Revision 2753)
++++ libnm-util/sha1.c	(Revision 2754)
+@@ -12,6 +12,10 @@
+  * See README and COPYING for more details.
+  */
+ 
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
+ #include <stdlib.h>
+ #include <string.h>
+ 
diff --git a/debian/patches/22-fix_vpn_ftbfs_dont_disable_gnome_deprecated.patch b/debian/patches/22-fix_vpn_ftbfs_dont_disable_gnome_deprecated.patch
new file mode 100644
index 00000000..ac0459b6
--- /dev/null
+++ b/debian/patches/22-fix_vpn_ftbfs_dont_disable_gnome_deprecated.patch
@@ -0,0 +1,44 @@
+=== modified file 'gnome/vpn-properties/Makefile.am'
+--- network-manager-0.6.5.old/gnome/vpn-properties/Makefile.am	2007-06-25 13:51:34 +0000
++++ network-manager-0.6.5/gnome/vpn-properties/Makefile.am	2007-08-03 11:50:32 +0000
+@@ -21,17 +21,16 @@ nm_vpn_properties_CFLAGS =              
+         $(GCONF_CFLAGS)                                 \
+         $(GMODULE_CFLAGS)                               \
+         $(LIBGNOMEUI_CFLAGS)                            \
+         -DSYSCONFDIR=\"$(sysconfdir)\"			\
+         -DICONDIR=\""$(datadir)/icons"\"                \
+         -DGLADEDIR=\""$(gladedir)"\"                    \
+         -DG_DISABLE_DEPRECATED                          \
+         -DGDK_DISABLE_DEPRECATED                        \
+-        -DGNOME_DISABLE_DEPRECATED                      \
+ 	-DGNOMELOCALEDIR=\"$(datadir)/locale\"		\
+         -DVERSION=\"$(VERSION)\" \
+         $(NULL)
+ 
+ nm_vpn_properties_LDADD =               \
+         $(GLADE_LIBS)                   \
+         $(GTK_LIBS)                     \
+         $(GCONF_LIBS)                   \
+
+=== modified file 'gnome/vpn-properties/Makefile.in'
+--- network-manager-0.6.5.old/gnome/vpn-properties/Makefile.in	2007-06-25 13:51:34 +0000
++++ network-manager-0.6.5/gnome/vpn-properties/Makefile.in	2007-08-03 11:50:32 +0000
+@@ -258,17 +258,16 @@ nm_vpn_properties_CFLAGS = \
+         $(GCONF_CFLAGS)                                 \
+         $(GMODULE_CFLAGS)                               \
+         $(LIBGNOMEUI_CFLAGS)                            \
+         -DSYSCONFDIR=\"$(sysconfdir)\"			\
+         -DICONDIR=\""$(datadir)/icons"\"                \
+         -DGLADEDIR=\""$(gladedir)"\"                    \
+         -DG_DISABLE_DEPRECATED                          \
+         -DGDK_DISABLE_DEPRECATED                        \
+-        -DGNOME_DISABLE_DEPRECATED                      \
+ 	-DGNOMELOCALEDIR=\"$(datadir)/locale\"		\
+         -DVERSION=\"$(VERSION)\" \
+         $(NULL)
+ 
+ 
+ nm_vpn_properties_LDADD = \
+         $(GLADE_LIBS)                   \
+         $(GTK_LIBS)                     \
+
diff --git a/debian/patches/23-rfkill_return_type.patch b/debian/patches/23-rfkill_return_type.patch
new file mode 100644
index 00000000..1e327d46
--- /dev/null
+++ b/debian/patches/23-rfkill_return_type.patch
@@ -0,0 +1,22 @@
+Index: src/NetworkManager.c
+===================================================================
+--- src/NetworkManager.c	(Revision 2974)
++++ src/NetworkManager.c	(Arbeitskopie)
+@@ -339,7 +339,7 @@
+ {
+ 	DBusError		err;
+ 	DBusMessage *	reply = NULL;
+-	guint32			status;
++	gint32			status;
+ 
+ 	g_return_if_fail (pcall != NULL);
+ 	g_return_if_fail (data != NULL);
+@@ -358,7 +358,7 @@
+ 		goto out;
+ 	}
+ 
+-	if (!dbus_message_get_args (reply, &err, DBUS_TYPE_UINT32, &status, DBUS_TYPE_INVALID)) {
++	if (!dbus_message_get_args (reply, &err, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
+ 		nm_info ("Error getting killswitch power arguments: %s - %s", err.name, err.message);
+ 		dbus_error_free (&err);
+ 		goto out;
diff --git a/debian/patches/24-get_mode_fix_r3122.patch b/debian/patches/24-get_mode_fix_r3122.patch
new file mode 100644
index 00000000..f89db8d5
--- /dev/null
+++ b/debian/patches/24-get_mode_fix_r3122.patch
@@ -0,0 +1,13 @@
+Index: src/nm-device-802-11-wireless.c
+===================================================================
+--- src/nm-device-802-11-wireless.c	(Revision 3121)
++++ src/nm-device-802-11-wireless.c	(Revision 3122)
+@@ -1144,7 +1144,7 @@
+ #endif
+ 		if (iw_get_ext (nm_dev_sock_get_fd (sk), nm_device_get_iface (NM_DEVICE (self)), SIOCGIWMODE, &wrq) == 0)
+ 		{
+-			if ((mode == IW_MODE_ADHOC) || (mode == IW_MODE_INFRA))
++			if ((wrq.u.mode == IW_MODE_ADHOC) || (wrq.u.mode == IW_MODE_INFRA))
+ 				mode = wrq.u.mode;
+ 		}
+ 		else
diff --git a/debian/patches/25-libnl_unique_pid_r3155.patch b/debian/patches/25-libnl_unique_pid_r3155.patch
new file mode 100644
index 00000000..a14aad83
--- /dev/null
+++ b/debian/patches/25-libnl_unique_pid_r3155.patch
@@ -0,0 +1,417 @@
+Index: src/NetworkManagerSystem.c
+===================================================================
+--- src/NetworkManagerSystem.c	(Revision 3154)
++++ src/NetworkManagerSystem.c	(Revision 3155)
+@@ -177,24 +177,6 @@
+ }
+ 
+ 
+-static struct nl_cache * get_link_cache (struct nl_handle *nlh)
+-{
+-	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+-	static struct nl_cache * link_cache = NULL;
+-
+-	g_static_mutex_lock (&mutex);
+-	if (!link_cache)
+-		link_cache = rtnl_link_alloc_cache (nlh);
+-	if (!link_cache)
+-		nm_warning ("ERROR: couldn't allocate rtnl link cache!");
+-	else
+-		nl_cache_update (nlh, link_cache);
+-	g_static_mutex_unlock (&mutex);
+-
+-	return link_cache;
+-}
+-
+-
+ static void iface_to_rtnl_index (const char *iface, struct nl_handle *nlh, struct rtnl_addr *addr)
+ {
+ 	struct nl_cache *	cache = NULL;
+@@ -204,14 +186,17 @@
+ 	g_return_if_fail (nlh != NULL);
+ 	g_return_if_fail (addr != NULL);
+ 
+-	if ((cache = get_link_cache (nlh)))
+-	{
+-		i = rtnl_link_name2i (cache, iface);
+-		if (RTNL_LINK_NOT_FOUND != i)
+-			rtnl_addr_set_ifindex (addr, i);
++	cache = rtnl_link_alloc_cache (nlh);
++	if (!cache) {
++		nm_warning ("%s: couldn't allocate link cache.", __func__);
++		return;
+ 	}
+-	else
+-		nm_warning ("iface_to_rtnl_link() couldn't allocate link cache.");
++
++	nl_cache_update (nlh, cache);
++	i = rtnl_link_name2i (cache, iface);
++	if (RTNL_LINK_NOT_FOUND != i)
++		rtnl_addr_set_ifindex (addr, i);
++	nl_cache_destroy_and_free (cache);
+ }
+ 
+ 
+@@ -223,45 +208,104 @@
+ 	g_return_val_if_fail (iface != NULL, NULL);
+ 	g_return_val_if_fail (nlh != NULL, NULL);
+ 
+-	if ((cache = get_link_cache (nlh)))
+-		have_link = rtnl_link_get_by_name (cache, iface);
+-	else
+-		nm_warning ("iface_to_rtnl_link() couldn't allocate link cache.");
++	cache = rtnl_link_alloc_cache (nlh);
++	if (!cache) {
++		nm_warning ("%s: couldn't allocate link cache.", __func__);
++		return NULL;
++	}
+ 
++	nl_cache_update (nlh, cache);
++	have_link = rtnl_link_get_by_name (cache, iface);
++	nl_cache_destroy_and_free (cache);
++
+ 	return have_link;
+ }
+ 
++static GStaticMutex nlh_mutex = G_STATIC_MUTEX_INIT;
+ 
+-static struct nl_handle * new_nl_handle (void)
++GHashTable *nl_pids = NULL;
++
++static struct
++nl_handle * new_nl_handle (void)
+ {
+-	struct nl_handle *	nlh = NULL;
++	struct nl_handle * nlh = NULL;
++	guint32 nl_pid;
++	int i = 0;
+ 
+-	nlh = nl_handle_alloc_nondefault(NL_CB_VERBOSE);
+-	nl_handle_set_pid (nlh, (pthread_self() << 16 | getpid()));
+-	if (nl_connect(nlh, NETLINK_ROUTE) < 0)
+-	{
+-		nm_warning ("%s: couldn't connecto to netlink: %s", __func__, nl_geterror());
+-		nl_handle_destroy (nlh);
+-		nlh = NULL;
++	g_static_mutex_lock (&nlh_mutex);
++
++	if (nl_pids == NULL) {
++		nl_pids = g_hash_table_new (g_direct_hash, g_direct_equal);
++		g_assert (nl_pids);
++
++		/* Insert the PID used by nm-netlink-monitor.c */
++		g_hash_table_insert (nl_pids, GUINT_TO_POINTER (getpid ()), GUINT_TO_POINTER (1));
+ 	}
+ 
++	while (i++ < 10) {
++		nl_pid = g_random_int ();
++		if (!g_hash_table_lookup (nl_pids, GUINT_TO_POINTER (nl_pid)))
++			break;
++	}
++
++	if (i < 10) {
++		nlh = nl_handle_alloc_nondefault (NL_CB_VERBOSE);
++		nl_handle_set_pid (nlh, nl_pid);
++
++		if (nl_connect (nlh, NETLINK_ROUTE) < 0) {
++			nm_warning ("%s: couldn't connect to netlink: %s", __func__, nl_geterror ());
++			nl_handle_destroy (nlh);
++			nlh = NULL;
++		} else {
++			g_hash_table_insert (nl_pids, GUINT_TO_POINTER (nl_pid), GUINT_TO_POINTER (1));
++		}
++	} else {
++		g_warning ("%s: couldn't find free netlink pid.", __func__);
++	}
++
++	g_static_mutex_unlock (&nlh_mutex);
++
+ 	return nlh;
+ }
+ 
++static void
++destroy_nl_handle (struct nl_handle *nlh)
++{
++	g_return_if_fail (nlh != NULL);
+ 
++	g_static_mutex_lock (&nlh_mutex);
++	g_hash_table_remove (nl_pids, GUINT_TO_POINTER (nl_handle_get_pid (nlh)));
++	g_static_mutex_unlock (&nlh_mutex);
++
++	nl_close (nlh);
++	nl_handle_destroy (nlh);
++
++}
++
++
+ int
+ nm_system_get_rtnl_index_from_iface (const char *iface)
+ {
+ 	struct nl_handle *	nlh = NULL;
+-	struct nl_cache *	cache = NULL;
++	struct nl_cache *	cache;
+ 	int				i = RTNL_LINK_NOT_FOUND;
+ 
+ 	nlh = new_nl_handle ();
+-	if (nlh && (cache = get_link_cache (nlh)))
+-		i = rtnl_link_name2i (cache, iface);
+-	nl_close (nlh);
+-	nl_handle_destroy (nlh);
++	if (!nlh)
++		return RTNL_LINK_NOT_FOUND;
+ 
++	cache = rtnl_link_alloc_cache (nlh);
++	if (!cache) {
++		nm_warning ("%s: couldn't allocate link cache.");
++		goto out;
++	}
++
++	nl_cache_update (nlh, cache);
++	i = rtnl_link_name2i (cache, iface);
++	nl_cache_destroy_and_free (cache);
++
++out:
++	destroy_nl_handle (nlh);
+ 	return i;
+ }
+ 
+@@ -275,18 +319,31 @@
+ 	char *			buf = NULL;
+ 
+ 	nlh = new_nl_handle ();
+-	if (nlh && (cache = get_link_cache (nlh)))
+-	{
+-		buf = g_malloc0 (MAX_IFACE_LEN);
+-		if (!rtnl_link_i2name (cache, rtnl_index, buf, MAX_IFACE_LEN - 1))
+-		{
+-			g_free (buf);
+-			buf = NULL;
+-		}
++	if (!nlh)
++		return NULL;
++
++	cache = rtnl_link_alloc_cache (nlh);
++	if (!cache) {
++		nm_warning ("%s: couldn't allocate link cache.");
++		goto out;
+ 	}
+-	nl_close (nlh);
+-	nl_handle_destroy (nlh);
+ 
++	nl_cache_update (nlh, cache);
++
++	buf = g_malloc0 (MAX_IFACE_LEN);
++	if (!buf)
++		goto destroy_cache;
++
++	if (!rtnl_link_i2name (cache, rtnl_index, buf, MAX_IFACE_LEN - 1)) {
++		g_free (buf);
++		buf = NULL;
++	}
++
++destroy_cache:
++	nl_cache_destroy_and_free (cache);
++
++out:
++	destroy_nl_handle (nlh);
+ 	return buf;
+ }
+ 
+@@ -313,13 +370,15 @@
+ 	config = nm_device_get_ip4_config (dev);
+ 	g_return_val_if_fail (config != NULL, FALSE);
+ 
++	nlh = new_nl_handle ();
++	if (!nlh)
++		return FALSE;
++
+ 	nm_system_delete_default_route ();
+ 	nm_system_device_flush_addresses (dev);
+ 	nm_system_device_flush_routes (dev);
+ 	nm_system_flush_arp_cache ();
+ 
+-	nlh = new_nl_handle ();
+-
+ 	if ((addr = nm_ip4_config_to_rtnl_addr (config, NM_RTNL_ADDR_DEFAULT)))
+ 	{
+ 		iface_to_rtnl_index (nm_device_get_iface (dev), nlh, addr);
+@@ -330,8 +389,7 @@
+ 	else
+ 		nm_warning ("nm_system_device_set_from_ip4_config(): couldn't create rtnl address!\n");
+ 
+-	nl_close (nlh);
+-	nl_handle_destroy (nlh);
++	destroy_nl_handle (nlh);
+ 
+ 	sleep (1);
+ 	nm_system_device_set_ip4_route (dev, nm_ip4_config_get_gateway (config), 0, 0, nm_ip4_config_get_mss (config));
+@@ -424,7 +482,13 @@
+  * Set IPv4 configuration of a VPN device from an NMIP4Config object.
+  *
+  */
+-gboolean nm_system_vpn_device_set_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config, char **routes, int num_routes)
++gboolean
++nm_system_vpn_device_set_from_ip4_config (NMNamedManager *named,
++                                          NMDevice *active_device,
++                                          const char *iface,
++                                          NMIP4Config *config,
++                                          char **routes,
++                                          int num_routes)
+ {
+ 	NMIP4Config *		ad_config = NULL;
+ 	struct nl_handle *	nlh = NULL;
+@@ -437,71 +501,73 @@
+ 	if (active_device && (ad_config = nm_device_get_ip4_config (active_device)))
+ 		nm_system_device_set_ip4_route (active_device, nm_ip4_config_get_gateway (ad_config), nm_ip4_config_get_gateway (config), 0xFFFFFFFF, nm_ip4_config_get_mss (config));
+ 
+-	if (iface != NULL && strlen (iface))
+-	{
+-		nm_system_device_set_up_down_with_iface (iface, TRUE);
++	if (!iface || !strlen (iface))
++		goto done;
+ 
+-		nlh = new_nl_handle ();
++	nlh = new_nl_handle ();
++	if (!nlh)
++		goto done;
+ 
+-		if ((addr = nm_ip4_config_to_rtnl_addr (config, NM_RTNL_ADDR_PTP_DEFAULT)))
+-		{
+-			int err = 0;
+-			iface_to_rtnl_index (iface, nlh, addr);
+-			if ((err = rtnl_addr_add (nlh, addr, 0)) < 0)
+-				nm_warning ("nm_system_device_set_from_ip4_config(): error %d returned from rtnl_addr_add():\n%s", err, nl_geterror());
+-			rtnl_addr_put (addr);
+-		}
+-		else
+-			nm_warning ("nm_system_vpn_device_set_from_ip4_config(): couldn't create rtnl address!\n");
++	nm_system_device_set_up_down_with_iface (iface, TRUE);
+ 
+-		/* Set the MTU */
+-		if ((request = rtnl_link_alloc ()))
+-		{
+-			struct rtnl_link * old;
++	if ((addr = nm_ip4_config_to_rtnl_addr (config, NM_RTNL_ADDR_PTP_DEFAULT)))
++	{
++		int err = 0;
++		iface_to_rtnl_index (iface, nlh, addr);
++		if ((err = rtnl_addr_add (nlh, addr, 0)) < 0)
++			nm_warning ("nm_system_device_set_from_ip4_config(): error %d returned from rtnl_addr_add():\n%s", err, nl_geterror());
++		rtnl_addr_put (addr);
++	}
++	else
++		nm_warning ("nm_system_vpn_device_set_from_ip4_config(): couldn't create rtnl address!\n");
+ 
+-			old = iface_to_rtnl_link (iface, nlh);
+-			rtnl_link_set_mtu (request, 1412);
+-			rtnl_link_change (nlh, old, request, 0);
++	/* Set the MTU */
++	if ((request = rtnl_link_alloc ()))
++	{
++		struct rtnl_link * old;
+ 
+-			rtnl_link_put (old);
+-			rtnl_link_put (request);
+-		}
++		old = iface_to_rtnl_link (iface, nlh);
++		rtnl_link_set_mtu (request, 1412);
++		rtnl_link_change (nlh, old, request, 0);
+ 
+-		nl_close (nlh);
+-		nl_handle_destroy (nlh);
++		rtnl_link_put (old);
++		rtnl_link_put (request);
++	}
+ 
+-		sleep (1);
++	destroy_nl_handle (nlh);
+ 
+-		nm_system_device_flush_routes_with_iface (iface);
+-		if (num_routes <= 0)
++	sleep (1);
++
++	nm_system_device_flush_routes_with_iface (iface);
++	if (num_routes <= 0)
++	{
++		nm_system_delete_default_route ();
++		nm_system_device_add_default_route_via_device_with_iface (iface);
++	}
++	else
++	{
++		int i;
++		for (i = 0; i < num_routes; i++)
+ 		{
+-			nm_system_delete_default_route ();
+-			nm_system_device_add_default_route_via_device_with_iface (iface);
+-		}
+-		else
+-		{
+-			int i;
+-			for (i = 0; i < num_routes; i++)
++			char *valid_ip4_route;
++
++			/* Make sure the route is valid, otherwise it's a security risk as the route
++			 * text is simply taken from the user, and passed directly to system().  If
++			 * we did not check the route, think of:
++			 *
++			 *     system("/sbin/ip route add `rm -rf /` dev eth0")
++			 *
++			 * where `rm -rf /` was the route text.  As UID 0 (root), we have to be careful.
++			 */
++			if ((valid_ip4_route = validate_ip4_route (routes[i])))
+ 			{
+-				char *valid_ip4_route;
+-
+-				/* Make sure the route is valid, otherwise it's a security risk as the route
+-				 * text is simply taken from the user, and passed directly to system().  If
+-				 * we did not check the route, think of:
+-				 *
+-				 *     system("/sbin/ip route add `rm -rf /` dev eth0")
+-				 *
+-				 * where `rm -rf /` was the route text.  As UID 0 (root), we have to be careful.
+-				 */
+-				if ((valid_ip4_route = validate_ip4_route (routes[i])))
+-				{
+-					nm_system_device_add_route_via_device_with_iface (iface, valid_ip4_route);
+-					g_free (valid_ip4_route);
+-				}
++				nm_system_device_add_route_via_device_with_iface (iface, valid_ip4_route);
++				g_free (valid_ip4_route);
+ 			}
+ 		}
+ 	}
+ 
++done:
+ 	nm_named_manager_add_ip4_config (named, config);
+ 
+ 	return TRUE;
+@@ -548,7 +614,8 @@
+ 
+ 	g_return_val_if_fail (iface != NULL, FALSE);
+ 
+-	if (!(nlh = new_nl_handle ()))
++	nlh = new_nl_handle ();
++	if (!nlh)
+ 		return FALSE;
+ 
+ 	if (!(request = rtnl_link_alloc ()))
+@@ -569,9 +636,7 @@
+ 	success = TRUE;
+ 
+ out:
+-	nl_close (nlh);
+-	nl_handle_destroy (nlh);
+-
++	destroy_nl_handle (nlh);
+ 	return success;
+ }
+ 
+@@ -614,6 +679,6 @@
+ out_request:
+ 	rtnl_link_put (request);
+ out_nl_close:
+-	nl_close (nlh);
+-	nl_handle_destroy (nlh);
++	destroy_nl_handle (nlh);
+ }
++
diff --git a/debian/patches/26-libnl_1.0-pre8_r3206.patch b/debian/patches/26-libnl_1.0-pre8_r3206.patch
new file mode 100644
index 00000000..6f96215d
--- /dev/null
+++ b/debian/patches/26-libnl_1.0-pre8_r3206.patch
@@ -0,0 +1,202 @@
+Index: src/nm-netlink-monitor.c
+===================================================================
+--- src/nm-netlink-monitor.c	(Revision 3205)
++++ src/nm-netlink-monitor.c	(Revision 3206)
+@@ -174,7 +174,7 @@
+ 	}
+ 
+ 	monitor_address.nl_family = AF_NETLINK;
+-	monitor_address.nl_pid = getpid ();
++	monitor_address.nl_pid = UINT_MAX;
+ 	monitor_address.nl_groups = RTMGRP_LINK;
+ 
+ 	if (bind (fd, 
+@@ -365,7 +365,7 @@
+ 	packet.header.nlmsg_len = NLMSG_LENGTH (sizeof (struct rtgenmsg));
+ 	packet.header.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
+ 	packet.header.nlmsg_type = RTM_GETLINK;
+-	packet.header.nlmsg_pid = getpid ();
++	packet.header.nlmsg_pid = UINT_MAX;
+ 	/* Might be good to generate a unique sequence number and track
+ 	   the response */
+ 	packet.header.nlmsg_seq = sequence_number << 16;
+Index: src/NetworkManagerSystem.c
+===================================================================
+--- src/NetworkManagerSystem.c	(Revision 3205)
++++ src/NetworkManagerSystem.c	(Revision 3206)
+@@ -196,7 +196,7 @@
+ 	i = rtnl_link_name2i (cache, iface);
+ 	if (RTNL_LINK_NOT_FOUND != i)
+ 		rtnl_addr_set_ifindex (addr, i);
+-	nl_cache_destroy_and_free (cache);
++	nl_cache_free (cache);
+ }
+ 
+ 
+@@ -216,55 +216,42 @@
+ 
+ 	nl_cache_update (nlh, cache);
+ 	have_link = rtnl_link_get_by_name (cache, iface);
+-	nl_cache_destroy_and_free (cache);
++	nl_cache_free (cache);
+ 
+ 	return have_link;
+ }
+ 
+-static GStaticMutex nlh_mutex = G_STATIC_MUTEX_INIT;
+-
+-GHashTable *nl_pids = NULL;
+-
+ static struct
+-nl_handle * new_nl_handle (void)
++nl_handle *new_nl_handle (gboolean recursive)
+ {
+-	struct nl_handle * nlh = NULL;
+-	guint32 nl_pid;
+-	int i = 0;
++	struct nl_handle *nlh = NULL;
++	struct nl_cb *cb;
+ 
+-	g_static_mutex_lock (&nlh_mutex);
+-
+-	if (nl_pids == NULL) {
+-		nl_pids = g_hash_table_new (g_direct_hash, g_direct_equal);
+-		g_assert (nl_pids);
+-
+-		/* Insert the PID used by nm-netlink-monitor.c */
+-		g_hash_table_insert (nl_pids, GUINT_TO_POINTER (getpid ()), GUINT_TO_POINTER (1));
++	cb = nl_cb_alloc (NL_CB_VERBOSE);
++	nlh = nl_handle_alloc_cb (cb);
++	if (!nlh) {
++		nm_warning ("%s: couldn't allocate netlink handle: %s", __func__, nl_geterror ());
++		return NULL;
+ 	}
+ 
+-	while (i++ < 10) {
+-		nl_pid = g_random_int ();
+-		if (!g_hash_table_lookup (nl_pids, GUINT_TO_POINTER (nl_pid)))
+-			break;
+-	}
++	if (nl_connect (nlh, NETLINK_ROUTE) < 0) {
++		/* HACK: try one more time. Because the netlink monitor for link state
++		 * inits before we get here, it grabs the port that matches the PID
++		 * of the NM process, which also happens to be the PID that libnl uses
++		 * the first time too.  The real fix is to convert nm-netlink-monitor.c
++		 * over to use libnl.
++		 */
++		nl_handle_destroy (nlh);
++		if (recursive)
++			return NULL;
+ 
+-	if (i < 10) {
+-		nlh = nl_handle_alloc_nondefault (NL_CB_VERBOSE);
+-		nl_handle_set_pid (nlh, nl_pid);
+-
+-		if (nl_connect (nlh, NETLINK_ROUTE) < 0) {
++		nlh = new_nl_handle (TRUE);
++		if (!nlh) {
+ 			nm_warning ("%s: couldn't connect to netlink: %s", __func__, nl_geterror ());
+-			nl_handle_destroy (nlh);
+-			nlh = NULL;
+-		} else {
+-			g_hash_table_insert (nl_pids, GUINT_TO_POINTER (nl_pid), GUINT_TO_POINTER (1));
++			return NULL;
+ 		}
+-	} else {
+-		g_warning ("%s: couldn't find free netlink pid.", __func__);
+ 	}
+ 
+-	g_static_mutex_unlock (&nlh_mutex);
+-
+ 	return nlh;
+ }
+ 
+@@ -273,16 +260,10 @@
+ {
+ 	g_return_if_fail (nlh != NULL);
+ 
+-	g_static_mutex_lock (&nlh_mutex);
+-	g_hash_table_remove (nl_pids, GUINT_TO_POINTER (nl_handle_get_pid (nlh)));
+-	g_static_mutex_unlock (&nlh_mutex);
+-
+ 	nl_close (nlh);
+ 	nl_handle_destroy (nlh);
+-
+ }
+ 
+-
+ int
+ nm_system_get_rtnl_index_from_iface (const char *iface)
+ {
+@@ -290,7 +271,7 @@
+ 	struct nl_cache *	cache;
+ 	int				i = RTNL_LINK_NOT_FOUND;
+ 
+-	nlh = new_nl_handle ();
++	nlh = new_nl_handle (FALSE);
+ 	if (!nlh)
+ 		return RTNL_LINK_NOT_FOUND;
+ 
+@@ -302,7 +283,7 @@
+ 
+ 	nl_cache_update (nlh, cache);
+ 	i = rtnl_link_name2i (cache, iface);
+-	nl_cache_destroy_and_free (cache);
++	nl_cache_free (cache);
+ 
+ out:
+ 	destroy_nl_handle (nlh);
+@@ -318,7 +299,7 @@
+ 	struct nl_cache *	cache = NULL;
+ 	char *			buf = NULL;
+ 
+-	nlh = new_nl_handle ();
++	nlh = new_nl_handle (FALSE);
+ 	if (!nlh)
+ 		return NULL;
+ 
+@@ -340,7 +321,7 @@
+ 	}
+ 
+ destroy_cache:
+-	nl_cache_destroy_and_free (cache);
++	nl_cache_free (cache);
+ 
+ out:
+ 	destroy_nl_handle (nlh);
+@@ -370,7 +351,7 @@
+ 	config = nm_device_get_ip4_config (dev);
+ 	g_return_val_if_fail (config != NULL, FALSE);
+ 
+-	nlh = new_nl_handle ();
++	nlh = new_nl_handle (FALSE);
+ 	if (!nlh)
+ 		return FALSE;
+ 
+@@ -504,7 +485,7 @@
+ 	if (!iface || !strlen (iface))
+ 		goto done;
+ 
+-	nlh = new_nl_handle ();
++	nlh = new_nl_handle (FALSE);
+ 	if (!nlh)
+ 		goto done;
+ 
+@@ -614,7 +595,7 @@
+ 
+ 	g_return_val_if_fail (iface != NULL, FALSE);
+ 
+-	nlh = new_nl_handle ();
++	nlh = new_nl_handle (FALSE);
+ 	if (!nlh)
+ 		return FALSE;
+ 
+@@ -658,7 +639,7 @@
+ 	if (!mtu)
+ 		return;
+ 
+-	nlh = new_nl_handle ();
++	nlh = new_nl_handle (FALSE);
+ 	if (!nlh)
+ 		return;
+ 
diff --git a/debian/patches/27-dont_repeat_errors.patch b/debian/patches/27-dont_repeat_errors.patch
new file mode 100644
index 00000000..64e23223
--- /dev/null
+++ b/debian/patches/27-dont_repeat_errors.patch
@@ -0,0 +1,37 @@
+diff --git a/src/NetworkManager.c b/src/NetworkManager.c
+index 4f89f63..ddb5a4a 100644
+--- a/src/NetworkManager.c
++++ b/src/NetworkManager.c
+@@ -65,6 +65,8 @@
+  */
+ static NMData		*nm_data = NULL;
+ 
++char *ks_err_message = NULL;
++
+ static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, gpointer data);
+ static void nm_data_free (NMData *data);
+ static gboolean nm_poll_killswitches(gpointer user_data);
+@@ -353,13 +355,21 @@ static void nm_killswitch_getpower_reply_cb (DBusPendingCall *pcall, NMData * da
+ 	if (message_is_error (reply)) {
+ 		dbus_error_init (&err);
+ 		dbus_set_error_from_message (&err, reply);
+-		nm_info ("Error getting killswitch power: %s - %s", err.name, err.message);
++		if (!ks_err_message || strcmp (ks_err_message, err.message)) {
++			nm_info ("Error getting killswitch power: %s - %s", err.name, err.message);
++			g_free (ks_err_message);
++			ks_err_message = g_strdup (err.message);
++		}
+ 		dbus_error_free (&err);
+ 		goto out;
+ 	}
+ 
+ 	if (!dbus_message_get_args (reply, &err, DBUS_TYPE_INT32, &status, DBUS_TYPE_INVALID)) {
+-		nm_info ("Error getting killswitch power arguments: %s - %s", err.name, err.message);
++		if (!ks_err_message || strcmp (ks_err_message, err.message)) {
++			nm_info ("Error getting killswitch power arguments: %s - %s", err.name, err.message);
++			g_free (ks_err_message);
++			ks_err_message = g_strdup (err.message);
++		}
+ 		dbus_error_free (&err);
+ 		goto out;
+ 	}
diff --git a/debian/patches/dbus_access_network_manager.patch b/debian/patches/dbus_access_network_manager.patch
deleted file mode 100644
index 06886be3..00000000
--- a/debian/patches/dbus_access_network_manager.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- src/NetworkManager.conf.orig	2006-02-07 04:24:38.000000000 +0100
-+++ src/NetworkManager.conf	2006-02-07 04:25:00.000000000 +0100
-@@ -8,7 +8,7 @@
-                 <allow send_destination="org.freedesktop.NetworkManager"/>
-                 <allow send_interface="org.freedesktop.NetworkManager"/>
-         </policy>
--        <policy at_console="true">
-+        <policy group="netdev">
-                 <allow send_destination="org.freedesktop.NetworkManager"/>
-                 <allow send_interface="org.freedesktop.NetworkManager"/>
-         </policy>
diff --git a/debian/patches/dbus_access_nm_applet.patch b/debian/patches/dbus_access_nm_applet.patch
deleted file mode 100644
index 94053ea2..00000000
--- a/debian/patches/dbus_access_nm_applet.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- gnome/applet/nm-applet.conf.orig	2006-02-07 04:22:39.000000000 +0100
-+++ gnome/applet/nm-applet.conf	2006-02-07 04:23:00.000000000 +0100
-@@ -8,7 +8,7 @@
- 		<allow send_destination="org.freedesktop.NetworkManagerInfo"/>
-                 <allow send_interface="org.freedesktop.NetworkManagerInfo"/>
- 	</policy>
--	<policy at_console="true">
-+	<policy group="netdev">
- 		<allow own="org.freedesktop.NetworkManagerInfo"/>
- 
- 		<allow send_destination="org.freedesktop.NetworkManagerInfo"/>
diff --git a/debian/patches/if_fix.patch b/debian/patches/if_fix.patch
deleted file mode 100644
index 379e9b38..00000000
--- a/debian/patches/if_fix.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-Index: src/nm-device-802-3-ethernet.c
-===================================================================
-RCS file: /cvs/gnome/NetworkManager/src/nm-device-802-3-ethernet.c,v
-retrieving revision 1.3
-diff -u -r1.3 nm-device-802-3-ethernet.c
---- src/nm-device-802-3-ethernet.c	3 Jan 2006 17:47:38 -0000	1.3
-+++ src/nm-device-802-3-ethernet.c	4 Jan 2006 17:13:33 -0000
-@@ -328,7 +328,9 @@
- /**************************************/
- /*    MII capability detection        */
- /**************************************/
-+#define _LINUX_IF_H
- #include <linux/mii.h>
-+#undef _LINUX_IF_H
- 
- static int
- mdio_read (NMDevice8023Ethernet *self, NMSock *sk, struct ifreq *ifr, int location)
-Index: src/nm-netlink-monitor.c
-===================================================================
-RCS file: /cvs/gnome/NetworkManager/src/nm-netlink-monitor.c,v
-retrieving revision 1.17
-diff -u -r1.17 nm-netlink-monitor.c
---- src/nm-netlink-monitor.c	12 Aug 2005 19:06:09 -0000	1.17
-+++ src/nm-netlink-monitor.c	4 Jan 2006 17:13:33 -0000
-@@ -30,7 +30,7 @@
- #include <linux/types.h>
- #include <linux/netlink.h>
- #include <linux/rtnetlink.h>
--#include <linux/if.h>
-+#include <net/if.h>
- #include <linux/unistd.h>
- #include <unistd.h>
-