public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in net-misc/networkmanager/files: networkmanager-0.9.2.0-pre-sleep.patch 10-openrc-status-r1 networkmanager-0.9.2.0-ifnet-password-truncated.patch networkmanager-0.9.2.0-init-provide-net-r1.patch
@ 2012-02-20  9:25 Alexandre Rostovtsev (tetromino)
  0 siblings, 0 replies; only message in thread
From: Alexandre Rostovtsev (tetromino) @ 2012-02-20  9:25 UTC (permalink / raw
  To: gentoo-commits

tetromino    12/02/20 09:25:00

  Added:                networkmanager-0.9.2.0-pre-sleep.patch
                        10-openrc-status-r1
                        networkmanager-0.9.2.0-ifnet-password-truncated.patch
                        networkmanager-0.9.2.0-init-provide-net-r1.patch
  Log:
  Fix openrc service going inactive while active connections are present (bug #402613, thanks to Thomas Witt). Try to be more user-friendly by waiting a few seconds before marking the service as inactive. Dispatch a pre-sleep event to unmount network filesystems before suspending (bug #402085, thanks to Marien Zwart). Do not truncate WPA passwords at '#' character (bug #402133, thanks to John Hardin).
  
  (Portage version: 2.2.0_alpha87/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  net-misc/networkmanager/files/networkmanager-0.9.2.0-pre-sleep.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-pre-sleep.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-pre-sleep.patch?rev=1.1&content-type=text/plain

Index: networkmanager-0.9.2.0-pre-sleep.patch
===================================================================
From 00b5c3785f7f5ce8da6db5da3fab814680ff82bc Mon Sep 17 00:00:00 2001
From: Alexandre Rostovtsev <tetromino@gentoo.org>
Date: Mon, 20 Feb 2012 02:14:26 -0500
Subject: [PATCH] Implement "pre-sleep" action dispatch

Based on work by Christian Becke <christianbecke@gmail.com> in
https://bugzilla.gnome.org/show_bug.cgi?id=387832

Adds a nm_utils_call_dispatcher_with_notify variant of the dispatcher
call, and uses it to dispatch a "pre-sleep" action before sleeping.
---
 callouts/nm-dispatcher-utils.c |    3 +-
 src/NetworkManagerUtils.c      |   70 ++++++++++++++++++++++++++++++++++------
 src/NetworkManagerUtils.h      |   12 +++++++
 src/nm-manager.c               |   28 ++++++++++++----
 4 files changed, 95 insertions(+), 18 deletions(-)

diff --git a/callouts/nm-dispatcher-utils.c b/callouts/nm-dispatcher-utils.c
index 887e80d..db66b61 100644
--- a/callouts/nm-dispatcher-utils.c
+++ b/callouts/nm-dispatcher-utils.c
@@ -407,7 +407,8 @@ nm_dispatcher_utils_construct_envp (const char *action,
 	g_return_val_if_fail (*out_iface == NULL, NULL);
 
 	/* Hostname changes don't require a device nor contain a connection */
-	if (!strcmp (action, "hostname"))
+	if (!strcmp (action, "hostname") ||
+	    !strcmp (action, "pre-sleep"))
 		return g_new0 (char *, 1);
 
 	/* Canonicalize the VPN interface name; "" is used when passing it through
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 451de6d..008b94e 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -44,6 +44,13 @@
 #include "nm-setting-wireless-security.h"
 #include "nm-manager-auth.h"
 
+typedef struct
+{
+	NMDBusManager *dbus_mgr;
+	NMUtilsDispatcherDoneCallback notify;
+	gpointer user_data;
+} NMUtilsCallDispatcherNotifyData;
+
 /*
  * nm_ethernet_address_is_valid
  *
@@ -475,18 +482,36 @@ fill_vpn_props (NMIP4Config *ip4_config,
 static void
 dispatcher_done_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 {
+	NMUtilsCallDispatcherNotifyData *notify_data = (NMUtilsCallDispatcherNotifyData *) user_data;
+
 	dbus_g_proxy_end_call (proxy, call, NULL, G_TYPE_INVALID);
 	g_object_unref (proxy);
+	if (notify_data->notify != NULL)
+		notify_data->notify (notify_data->user_data);
+}
+
+static void
+nm_utils_call_dispatcher_notify_data_free (NMUtilsCallDispatcherNotifyData *data)
+{
+	if (data == NULL)
+		return;
+
+	if (data->dbus_mgr != NULL)
+		g_object_unref (data->dbus_mgr);
+	g_free (data);
 }
 
 void
-nm_utils_call_dispatcher (const char *action,
-                          NMConnection *connection,
-                          NMDevice *device,
-                          const char *vpn_iface,
-                          NMIP4Config *vpn_ip4_config,
-                          NMIP6Config *vpn_ip6_config)
+nm_utils_call_dispatcher_with_notify (const char *action,
+                                      NMConnection *connection,
+                                      NMDevice *device,
+                                      const char *vpn_iface,
+                                      NMIP4Config *vpn_ip4_config,
+                                      NMIP6Config *vpn_ip6_config,
+                                      NMUtilsDispatcherDoneCallback notify,
+                                      gpointer user_data)
 {
+	NMUtilsCallDispatcherNotifyData *notify_data;
 	NMDBusManager *dbus_mgr;
 	DBusGProxy *proxy;
 	DBusGConnection *g_connection;
@@ -503,7 +528,8 @@ nm_utils_call_dispatcher (const char *action,
 	g_return_if_fail (action != NULL);
 
 	/* All actions except 'hostname' require a device */
-	if (strcmp (action, "hostname") != 0)
+	if (strcmp (action, "hostname") != 0 &&
+	    strcmp (action, "pre-sleep") != 0)
 		g_return_if_fail (NM_IS_DEVICE (device));
 	/* VPN actions require at least an IPv4 config (for now) */
 	if (strcmp (action, "vpn-up") == 0)
@@ -544,7 +570,8 @@ nm_utils_call_dispatcher (const char *action,
 	vpn_ip6_props = value_hash_create ();
 
 	/* hostname actions only send the hostname */
-	if (strcmp (action, "hostname") != 0) {
+	if (strcmp (action, "hostname") != 0 &&
+	    strcmp (action, "pre-sleep") != 0) {
 		fill_device_props (device,
 			               device_props,
 			               device_ip4_props,
@@ -555,6 +582,11 @@ nm_utils_call_dispatcher (const char *action,
 			fill_vpn_props (vpn_ip4_config, NULL, vpn_ip4_props, vpn_ip6_props);
 	}
 
+	notify_data = g_new0 (NMUtilsCallDispatcherNotifyData, 1);
+	notify_data->dbus_mgr = dbus_mgr;
+	notify_data->notify = notify;
+	notify_data->user_data = user_data;
+
 	/* Do a non-blocking call, but wait for the reply, because dbus-glib
 	 * sometimes needs time to complete internal housekeeping.  If we use
 	 * dbus_g_proxy_call_no_reply(), that housekeeping (specifically the
@@ -563,8 +595,8 @@ nm_utils_call_dispatcher (const char *action,
 	 */
 	dbus_g_proxy_begin_call_with_timeout (proxy, "Action",
 	                                      dispatcher_done_cb,
-	                                      dbus_mgr,       /* automatically unref the dbus mgr when call is done */
-	                                      g_object_unref,
+	                                      notify_data,       /* automatically unref the dbus mgr when call is done */
+	                                      (GDestroyNotify) nm_utils_call_dispatcher_notify_data_free,
 	                                      5000,
 	                                      G_TYPE_STRING, action,
 	                                      DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, connection_hash,
@@ -589,6 +621,24 @@ nm_utils_call_dispatcher (const char *action,
 	g_hash_table_destroy (vpn_ip6_props);
 }
 
+void
+nm_utils_call_dispatcher (const char *action,
+                          NMConnection *connection,
+                          NMDevice *device,
+                          const char *vpn_iface,
+                          NMIP4Config *vpn_ip4_config,
+                          NMIP6Config *vpn_ip6_config)
+{
+	nm_utils_call_dispatcher_with_notify (action,
+	                                      connection,
+	                                      device,
+	                                      vpn_iface,
+	                                      vpn_ip4_config,
+	                                      vpn_ip6_config,
+	                                      NULL,
+	                                      NULL);
+}
+
 gboolean
 nm_match_spec_hwaddr (const GSList *specs, const char *hwaddr)
 {
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h
index 1bf741e..bdc0fef 100644
--- a/src/NetworkManagerUtils.h
+++ b/src/NetworkManagerUtils.h
@@ -49,6 +49,18 @@ void nm_utils_call_dispatcher (const char *action,
                                NMIP4Config *vpn_ip4_config,
                                NMIP6Config *vpn_ip6_config);
 
+typedef void (*NMUtilsDispatcherDoneCallback) (gpointer user_data);
+
+void
+nm_utils_call_dispatcher_with_notify (const char *action,
+                                      NMConnection *connection,
+                                      NMDevice *device,
+                                      const char *vpn_iface,
+                                      NMIP4Config *vpn_ip4_config,
+                                      NMIP6Config *vpn_ip6_config,
+                                      NMUtilsDispatcherDoneCallback notify,
+                                      gpointer user_data);
+
 gboolean nm_match_spec_hwaddr (const GSList *specs, const char *hwaddr);
 gboolean nm_match_spec_s390_subchannels (const GSList *specs, const char *subchannels);
 
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 7205c7a..9e70071 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2433,6 +2433,23 @@ impl_manager_deactivate_connection (NMManager *self,
 }
 
 static void
+pre_sleep_dispatcher_done (gpointer user_data)
+{
+	NMManager *self = (NMManager *) user_data;
+	NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
+	GSList *iter;
+
+	/* Just deactivate and down all devices from the device list,
+	 * to keep things fast the device list will get resynced when
+	 * the manager wakes up.
+	 */
+	for (iter = priv->devices; iter; iter = iter->next)
+		nm_device_set_managed (NM_DEVICE (iter->data), FALSE, NM_DEVICE_STATE_REASON_SLEEPING);
+
+	nm_manager_update_state (self);
+}
+
+static void
 do_sleep_wake (NMManager *self)
 {
 	NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
@@ -2442,13 +2459,10 @@ do_sleep_wake (NMManager *self)
 	if (manager_sleeping (self)) {
 		nm_log_info (LOGD_SUSPEND, "sleeping or disabling...");
 
-		/* Just deactivate and down all devices from the device list,
-		 * to keep things fast the device list will get resynced when
-		 * the manager wakes up.
-		 */
-		for (iter = priv->devices; iter; iter = iter->next)
-			nm_device_set_managed (NM_DEVICE (iter->data), FALSE, NM_DEVICE_STATE_REASON_SLEEPING);
-
+		nm_utils_call_dispatcher_with_notify ("pre-sleep",
+		                                      NULL, NULL, NULL, NULL, NULL,
+		                                      pre_sleep_dispatcher_done, self);
+		return;
 	} else {
 		nm_log_info (LOGD_SUSPEND, "waking up and re-enabling...");
 
-- 
1.7.8.4




1.1                  net-misc/networkmanager/files/10-openrc-status-r1

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/10-openrc-status-r1?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/10-openrc-status-r1?rev=1.1&content-type=text/plain

Index: 10-openrc-status-r1
===================================================================
#!/bin/sh
# Copyright (c) 2012 Alexandre Rostovtsev
# Released under the 2-clause BSD license.

# Ensures that the NetworkManager OpenRC service is marked as started and
# providing net only when it has a successful connection.

# Ensure rc-service is in PATH
PATH="${PATH}:@EPREFIX@/sbin:@EPREFIX@/usr/sbin"

# Exit if the NetworkManager OpenRC service is not running
rc-service NetworkManager status 2>&1 | grep -Eq "status: (starting|started|inactive|stopping)" || exit 0

# Call rc-service in background mode so that the start/stop functions update
# NetworkManager service status to started or inactive instead of actually
# starting or stopping the daemon
export IN_BACKGROUND=YES

case "$2" in
    up) nm-online -t 0 && exec rc-service NetworkManager start ;;
    down) nm-online -t 0 || exec rc-service NetworkManager stop ;;
    pre-sleep) exec rc-service NetworkManager stop ;;
esac



1.1                  net-misc/networkmanager/files/networkmanager-0.9.2.0-ifnet-password-truncated.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-ifnet-password-truncated.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-ifnet-password-truncated.patch?rev=1.1&content-type=text/plain

Index: networkmanager-0.9.2.0-ifnet-password-truncated.patch
===================================================================
From 03d80950e960031af977c3037b57d41e36701fb2 Mon Sep 17 00:00:00 2001
From: Alexandre Rostovtsev <tetromino@gentoo.org>
Date: Sat, 18 Feb 2012 20:03:33 -0500
Subject: [PATCH] ifnet: do not truncate WPA passwords at '#' character

We need to do the same thing as wpa_supplicant's own config file parser
and ignore '#' characters that occur between the first and last '"'
characters in a config file line.

https://bugzilla.gnome.org/show_bug.cgi?id=670381
---
 src/settings/plugins/ifnet/wpa_parser.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/settings/plugins/ifnet/wpa_parser.c b/src/settings/plugins/ifnet/wpa_parser.c
index da2bc3b..f7a5b32 100644
--- a/src/settings/plugins/ifnet/wpa_parser.c
+++ b/src/settings/plugins/ifnet/wpa_parser.c
@@ -279,16 +279,21 @@ wpa_parser_init (const char *wpa_supplicant_conf)
 			} else {
 				GHashTable *network =
 				    g_hash_table_new (g_str_hash, g_str_equal);
-				gchar *tmp;
 
 				do {
+					gchar *quote_start, *quote_end = NULL, *comment;
+
 					if (line[0] == '#' || line[0] == '\0') {
 						g_free (line);
 						continue;
 					}
-					/* ignore inline comments */
-					if ((tmp = strchr (line, '#')) != NULL)
-						*tmp = '\0';
+					/* ignore inline comments unless inside
+					   a double-quoted string */
+					if ((quote_start = strchr (line, '"')) != NULL)
+						quote_end = strrchr (quote_start + 1, '"');
+					if ((comment = strchr ((quote_end != NULL) ?
+					                       quote_end : line, '#')) != NULL)
+						*comment = '\0';
 					if (strstr (line, "}") != NULL)
 						complete = TRUE;
 					add_key_value (network, line);
-- 
1.7.8.4




1.1                  net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net-r1.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net-r1.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net-r1.patch?rev=1.1&content-type=text/plain

Index: networkmanager-0.9.2.0-init-provide-net-r1.patch
===================================================================
From e99873e7583a3838e0873b1d0b1f9c3dac49f853 Mon Sep 17 00:00:00 2001
From: Alexandre Rostovtsev <tetromino@gentoo.org>
Date: Wed, 1 Feb 2012 05:51:20 -0500
Subject: [PATCH] gentoo: provide net and use inactive status when not
 connected

The status will be reset to started via a dispatcher script on up/down
events. See https://bugs.gentoo.org/show_bug.cgi?id=252137
---
 initscript/Gentoo/NetworkManager.in |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/initscript/Gentoo/NetworkManager.in b/initscript/Gentoo/NetworkManager.in
index 7db410b..34f19b1 100755
--- a/initscript/Gentoo/NetworkManager.in
+++ b/initscript/Gentoo/NetworkManager.in
@@ -3,18 +3,38 @@
 # Distributed under the terms of the GNU General Purpose License v2
 # $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net-r1.patch,v 1.1 2012/02/20 09:24:59 tetromino Exp $
 
+description="NetworkManager daemon. The service is marked as started only \
+when a network connection is established."
+
 depend() {
    need dbus
+   provide net
 }
 
 start() {
+   # If we are re-called by a dispatcher event, we want to mark the service
+   # as started without starting the daemon again
+   yesno "${IN_BACKGROUND}" && return 0
+
    ebegin "Starting NetworkManager"
    start-stop-daemon --start --quiet --pidfile /var/run/NetworkManager.pid \
       --exec /usr/sbin/NetworkManager -- --pid-file /var/run/NetworkManager.pid
-   eend $?
+   local _retval=$?
+   eend "${_retval}"
+   if [ "x${_retval}" = 'x0' ]; then
+      nm-online -t 5 || mark_service_inactive
+   fi
+   return "${_retval}"
 }
 
 stop() {
+   # If we are re-called by a dispatcher event, we want to mark the service
+   # as inactive without stopping the daemon
+   if yesno "${IN_BACKGROUND}"; then
+      mark_service_inactive "${SVCNAME}"
+      return 0
+   fi
+
    ebegin "Stopping NetworkManager"
    start-stop-daemon --stop --quiet --pidfile /var/run/NetworkManager.pid
    eend $?
-- 
1.7.8.4







^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-20  9:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20  9:25 [gentoo-commits] gentoo-x86 commit in net-misc/networkmanager/files: networkmanager-0.9.2.0-pre-sleep.patch 10-openrc-status-r1 networkmanager-0.9.2.0-ifnet-password-truncated.patch networkmanager-0.9.2.0-init-provide-net-r1.patch Alexandre Rostovtsev (tetromino)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox