[packages/NetworkManager] Update to 1.2.2

megabajt megabajt at pld-linux.org
Thu Jun 2 22:34:07 CEST 2016


commit ffec268f5dac5175af23da5f2631b222df51be69
Author: Marcin Banasiak <marcin.banasiak at gmail.com>
Date:   Thu Jun 2 22:32:37 2016 +0200

    Update to 1.2.2
    
    - removed obsolete wimax bcond

 NetworkManager.spec    |  23 +-
 systemd-fallback.patch | 703 ++++++++++---------------------------------------
 2 files changed, 156 insertions(+), 570 deletions(-)
---
diff --git a/NetworkManager.spec b/NetworkManager.spec
index fb4bbc2..6523c99 100644
--- a/NetworkManager.spec
+++ b/NetworkManager.spec
@@ -2,18 +2,17 @@
 # Conditional build
 %bcond_without	systemd # use systemd for session tracking instead of ConsoleKit (fallback to ConsoleKit on runtime)
 %bcond_without	vala	# Vala API
-%bcond_with	wimax	# enable wimax support
 
 Summary:	Network Manager for GNOME
 Summary(pl.UTF-8):	Zarządca sieci dla GNOME
 Name:		NetworkManager
-Version:	1.0.12
+Version:	1.2.2
 Release:	1
 Epoch:		2
 License:	GPL v2+
 Group:		Networking/Admin
-Source0:	http://ftp.gnome.org/pub/GNOME/sources/NetworkManager/1.0/%{name}-%{version}.tar.xz
-# Source0-md5:	ebb273456a81ccf9dfaf2461061b0e96
+Source0:	http://ftp.gnome.org/pub/GNOME/sources/NetworkManager/1.2/%{name}-%{version}.tar.xz
+# Source0-md5:	a922bf20c2243c9014fb14c4427ad035
 Source1:	%{name}.conf
 Source3:	%{name}.tmpfiles
 Source4:	%{name}.init
@@ -21,14 +20,15 @@ Patch0:		ifcfg-path.patch
 Patch1:		systemd-fallback.patch
 URL:		https://wiki.gnome.org/Projects/NetworkManager
 BuildRequires:	ModemManager-devel >= 1.0.0
+BuildRequires:	audit-libs-devel
 BuildRequires:	autoconf >= 2.63
-BuildRequires:	automake >= 1:1.11
+BuildRequires:	automake >= 1:1.12
 BuildRequires:	bluez-libs-devel >= 5.0
 BuildRequires:	dbus-devel >= 1.1.0
 BuildRequires:	dbus-glib-devel >= 0.100
 BuildRequires:	docbook-dtd412-xml
 BuildRequires:	gettext-tools >= 0.17
-BuildRequires:	glib2-devel >= 1:2.37.2
+BuildRequires:	glib2-devel >= 1:2.38.0
 BuildRequires:	gnome-common
 BuildRequires:	gobject-introspection-devel >= 0.10.0
 BuildRequires:	gtk-doc >= 1.0
@@ -37,7 +37,7 @@ BuildRequires:	intltool >= 0.40.0
 BuildRequires:	libndp-devel
 BuildRequires:	libnl-devel >= 3.2.8
 BuildRequires:	libselinux-devel
-BuildRequires:	libsoup-devel >= 2.26.0
+BuildRequires:	libsoup-devel >= 2.40.0
 BuildRequires:	libteam-devel >= 1.9
 BuildRequires:	libtool >= 2:2.2
 BuildRequires:	libuuid-devel
@@ -49,12 +49,11 @@ BuildRequires:	ppp-plugin-devel >= 3:2.4.6
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.673
 BuildRequires:	sed >= 4.0
-%{?with_systemd:BuildRequires:	systemd-devel >= 1:200}
+%{?with_systemd:BuildRequires:	systemd-devel >= 1:209}
 BuildRequires:	tar >= 1:1.22
 BuildRequires:	udev-devel
 BuildRequires:	udev-glib-devel >= 1:165
 %{?with_vala:BuildRequires:	vala >= 2:0.17.1.24}
-%{?with_wimax:BuildRequires:	wimax-devel >= 1.5.1}
 BuildRequires:	xz
 Requires(post,preun):	/sbin/chkconfig
 Requires(post,preun,postun):	systemd-units >= 38
@@ -211,9 +210,9 @@ Bashowe uzupełnianie nazw dla polecenia NetworkManagera (nmcli).
 	--with-pppd-plugin-dir=%{_libdir}/pppd/plugins \
 	--with-pppoe=/usr/sbin/pppoe \
 	--with-resolvconf=/sbin/resolvconf \
+	--with-udev-dir=/lib/udev \
 	--with-dist-version=%{version}-%{release} \
 	--with-docs \
-	%{__enable_disable wimax} \
 	--enable-static \
 	%{!?with_vala:--disable-vala}
 
@@ -301,7 +300,6 @@ exit 0
 %attr(755,root,root) %{_libdir}/NetworkManager/libnm-settings-plugin-ibft.so
 %attr(755,root,root) %{_libdir}/NetworkManager/libnm-settings-plugin-ifcfg-rh.so
 %attr(755,root,root) %{_libdir}/NetworkManager/libnm-wwan.so
-%attr(755,root,root) %{_libexecdir}/nm-avahi-autoipd.action
 %attr(755,root,root) %{_libexecdir}/nm-dhcp-helper
 %attr(755,root,root) %{_libexecdir}/nm-dispatcher
 %attr(755,root,root) %{_libexecdir}/nm-iface-helper
@@ -322,7 +320,6 @@ exit 0
 %dir %{_sysconfdir}/%{name}/VPN
 %dir %{_sysconfdir}/%{name}/system-connections
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/%{name}.conf
-%config(noreplace) %verify(not md5 mtime size) /etc/dbus-1/system.d/nm-avahi-autoipd.conf
 %config(noreplace) %verify(not md5 mtime size) /etc/dbus-1/system.d/nm-dispatcher.conf
 %config(noreplace) %verify(not md5 mtime size) /etc/dbus-1/system.d/nm-ifcfg-rh.conf
 %config(noreplace) %verify(not md5 mtime size) /etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf
@@ -339,7 +336,7 @@ exit 0
 %{_mandir}/man5/nm-settings-keyfile.5*
 %{_mandir}/man5/nm-settings.5*
 %{_mandir}/man5/nm-system-settings.conf.5*
-%{_mandir}/man5/nmcli-examples.5*
+%{_mandir}/man7/nmcli-examples.7*
 %{_mandir}/man8/NetworkManager.8*
 %{_examplesdir}/%{name}-%{version}
 
diff --git a/systemd-fallback.patch b/systemd-fallback.patch
index d4d1886..689b858 100644
--- a/systemd-fallback.patch
+++ b/systemd-fallback.patch
@@ -1,611 +1,200 @@
---- NetworkManager-1.0.0/configure.ac.orig	2014-12-19 23:27:36.133692361 +0100
-+++ NetworkManager-1.0.0/configure.ac	2014-12-19 23:29:57.159595024 +0100
-@@ -348,7 +348,7 @@ AM_CONDITIONAL(SESSION_TRACKING_CK, test
- AM_CONDITIONAL(SESSION_TRACKING_SYSTEMD, test "$with_session_tracking" = "systemd")
- if test "$with_session_tracking" = "systemd"; then
- 	PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd],,
--	                  [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-login])])
-+	                  [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-daemon libsystemd-login])])
- 	AC_SUBST(SYSTEMD_LOGIN_CFLAGS)
- 	AC_SUBST(SYSTEMD_LOGIN_LIBS)
+--- NetworkManager-1.2.2/configure.ac.systemd	2016-05-17 22:29:49.567521947 +0200
++++ NetworkManager-1.2.2/configure.ac	2016-05-17 23:14:31.594510933 +0200
+@@ -435,7 +435,7 @@ AS_IF([test -z "$use_consolekit"], [use_
+ # output
+ session_tracking=
+ if test "$use_systemd_logind" = "yes" -o "$use_systemd_logind" = "auto"; then
+-    PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd], [have_systemd_logind=yes], [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-login], [have_systemd_logind=yes], [have_systemd_logind=no])])
++    PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd], [have_systemd_logind=yes], [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-daemon libsystemd-login], [have_systemd_logind=yes], [have_systemd_logind=no])])
+ else
+     have_systemd_logind=no
  fi
---- NetworkManager-1.0.0/src/nm-session-monitor-systemd.c.orig	2014-12-11 22:28:51.000000000 +0100
-+++ NetworkManager-1.0.0/src/nm-session-monitor-systemd.c	2014-12-21 11:30:09.859311469 +0100
-@@ -29,10 +29,14 @@
- #include <glib/gstdio.h>
- #include <systemd/sd-login.h>
- #include <stdlib.h>
-+#include <systemd/sd-daemon.h>
-+#include <sys/stat.h>
-+#include <gio/gio.h>
- 
- #include "nm-session-utils.h"
- #include "nm-session-monitor.h"
- #include "nm-logging.h"
-+#include "nm-errors.h"
- 
- /********************************************************************/
- 
-@@ -109,10 +113,18 @@ sd_source_new (void)
- 	return source;
- }
+@@ -447,12 +447,13 @@ if test "$have_systemd_logind" = "yes";
+ 	session_tracking="$session_tracking, systemd-logind"
+ fi
+ if test "$use_consolekit" = "yes"; then
+-	AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 1, [Define to 1 if ConsoleKit is available])
+-	AC_DEFINE([CKDB_PATH], "/var/run/ConsoleKit/database", [Path to ConsoleKit database])
++	AC_DEFINE([SESSION_TRACKING_CONSOLEKIT], 1, [Define to 1 if ConsoleKit is available])	
+ 	session_tracking="$session_tracking, consolekit"
+ fi
+ session_tracking="$(printf '%s' "${session_tracking}" | sed 's/^, //')"
  
-+#define CKDB_PATH "/var/run/ConsoleKit/database"
++AC_DEFINE([CKDB_PATH], "/var/run/ConsoleKit/database", [Path to ConsoleKit database])
 +
- struct _NMSessionMonitor {
- 	GObject parent_instance;
+ AC_ARG_WITH(suspend-resume, AS_HELP_STRING([--with-suspend-resume=upower|systemd|consolekit], [Build NetworkManager with specific suspend/resume support]))
+ if test "z$with_suspend_resume" = "z"; then
+     PKG_CHECK_EXISTS([libsystemd >= 209], [have_systemd_inhibit=yes],
+--- NetworkManager-1.2.2/src/nm-session-monitor.c.systemd	2016-04-25 16:46:58.000000000 +0200
++++ NetworkManager-1.2.2/src/nm-session-monitor.c	2016-05-28 23:23:37.337347753 +0200
+@@ -30,6 +30,7 @@
+ #include "NetworkManagerUtils.h"
  
- 	GSource *sd_source;
-+
-+	GKeyFile *database;
-+	GFileMonitor *database_monitor;
-+	time_t database_mtime;
-+	GHashTable *sessions_by_uid;
-+	GHashTable *sessions_by_user;
+ #ifdef SESSION_TRACKING_SYSTEMD
++#include <systemd/sd-daemon.h>
+ #include <systemd/sd-login.h>
+ #endif
+ 
+@@ -52,13 +53,11 @@ struct _NMSessionMonitor {
+ 	} sd;
+ #endif
+ 
+-#ifdef SESSION_TRACKING_CONSOLEKIT
+ 	struct {
+ 		GFileMonitor *monitor;
+ 		GHashTable *cache;
+ 		time_t timestamp;
+ 	} ck;
+-#endif
  };
  
  struct _NMSessionMonitorClass {
-@@ -132,6 +144,215 @@ G_DEFINE_TYPE (NMSessionMonitor, nm_sess
+@@ -138,7 +137,6 @@ st_sd_finalize (NMSessionMonitor *monito
  
- /* ---------------------------------------------------------------------------------------------------- */
+ /********************************************************************/
  
-+typedef struct {
-+	char *user;
-+	uid_t uid;
-+	gboolean local;
-+	gboolean active;
-+} Session;
-+
-+static void
-+session_free (Session *s)
-+{
-+	g_free (s->user);
-+	memset (s, 0, sizeof (Session));
-+	g_free (s);
-+}
-+
-+static gboolean
-+check_key (GKeyFile *keyfile, const char *group, const char *key, GError **error)
-+{
-+	if (g_key_file_has_key (keyfile, group, key, error))
-+		return TRUE;
-+
-+	if (!error) {
-+		g_set_error (error,
-+			         NM_MANAGER_ERROR,
-+			         NM_MANAGER_ERROR_FAILED,
-+			         "ConsoleKit database " CKDB_PATH " group '%s' had no '%s' key",
-+			         group, key);
-+	}
-+	return FALSE;
-+}
-+
-+static Session *
-+session_new (GKeyFile *keyfile, const char *group, GError **error)
-+{
-+	GError *local = NULL;
-+	Session *s;
-+	const char *uname = NULL;
-+
-+	s = g_new0 (Session, 1);
-+	g_assert (s);
-+
-+	s->uid = G_MAXUINT; /* paranoia */
-+	if (!check_key (keyfile, group, "uid", &local))
-+		goto error;
-+	s->uid = (uid_t) g_key_file_get_integer (keyfile, group, "uid", &local);
-+	if (local)
-+		goto error;
-+
-+	if (!check_key (keyfile, group, "is_active", &local))
-+		goto error;
-+	s->active = g_key_file_get_boolean (keyfile, group, "is_active", &local);
-+	if (local)
-+		goto error;
-+
-+	if (!check_key (keyfile, group, "is_local", &local))
-+		goto error;
-+	s->local = g_key_file_get_boolean (keyfile, group, "is_local", &local);
-+	if (local)
-+		goto error;
-+
-+	if (!nm_session_uid_to_user (s->uid, &uname, error))
-+		return FALSE;
-+	s->user = g_strdup (uname);
-+
-+	return s;
-+
-+error:
-+	session_free (s);
-+	g_propagate_error (error, local);
-+	return NULL;
-+}
-+
-+static void
-+session_merge (Session *src, Session *dest)
-+{
-+	g_return_if_fail (src != NULL);
-+	g_return_if_fail (dest != NULL);
-+
-+	g_warn_if_fail (g_strcmp0 (src->user, dest->user) == 0);
-+	g_warn_if_fail (src->uid == dest->uid);
-+
-+	dest->local = (dest->local || src->local);
-+	dest->active = (dest->active || src->active);
-+}
-+
-+/********************************************************************/
-+
-+static void
-+free_database (NMSessionMonitor *self)
-+{
-+	if (self->database != NULL) {
-+		g_key_file_free (self->database);
-+		self->database = NULL;
-+	}
-+
-+	g_hash_table_remove_all (self->sessions_by_uid);
-+	g_hash_table_remove_all (self->sessions_by_user);
-+}
-+
-+static gboolean
-+reload_database (NMSessionMonitor *self, GError **error)
-+{
-+	struct stat statbuf;
-+	char **groups = NULL;
-+	gsize len = 0, i;
-+	Session *s;
-+
-+	free_database (self);
-+
-+	errno = 0;
-+	if (stat (CKDB_PATH, &statbuf) != 0) {
-+		g_set_error (error,
-+		             NM_MANAGER_ERROR,
-+		             NM_MANAGER_ERROR_FAILED,
-+		             "Error statting file " CKDB_PATH ": %s",
-+		             strerror (errno));
-+		goto error;
-+	}
-+	self->database_mtime = statbuf.st_mtime;
-+
-+	self->database = g_key_file_new ();
-+	if (!g_key_file_load_from_file (self->database, CKDB_PATH, G_KEY_FILE_NONE, error))
-+		goto error;
-+
-+	groups = g_key_file_get_groups (self->database, &len);
-+	if (!groups) {
-+		g_set_error_literal (error,
-+		                     NM_MANAGER_ERROR,
-+		                     NM_MANAGER_ERROR_FAILED,
-+		                     "Could not load groups from " CKDB_PATH "");
-+		goto error;
-+	}
-+
-+	for (i = 0; i < len; i++) {
-+		Session *found;
-+
-+		if (!g_str_has_prefix (groups[i], "Session "))
-+			continue;
-+
-+		s = session_new (self->database, groups[i], error);
-+		if (!s)
-+			goto error;
-+
-+		found = g_hash_table_lookup (self->sessions_by_user, (gpointer) s->user);
-+		if (found) {
-+			session_merge (s, found);
-+			session_free (s);
-+		} else {
-+			/* Entirely new user */
-+			g_hash_table_insert (self->sessions_by_user, (gpointer) s->user, s);
-+			g_hash_table_insert (self->sessions_by_uid, GUINT_TO_POINTER (s->uid), s);
-+		}
-+	}
-+
-+	g_strfreev (groups);
-+	return TRUE;
-+
-+error:
-+	if (groups)
-+		g_strfreev (groups);
-+	free_database (self);
-+	return FALSE;
-+}
-+
-+static gboolean
-+ensure_database (NMSessionMonitor *self, GError **error)
-+{
-+	gboolean ret = FALSE;
-+
-+	if (self->database != NULL) {
-+		struct stat statbuf;
-+
-+		errno = 0;
-+		if (stat (CKDB_PATH, &statbuf) != 0) {
-+			g_set_error (error,
-+			             NM_MANAGER_ERROR,
-+			             NM_MANAGER_ERROR_FAILED,
-+			             "Error statting file " CKDB_PATH " to check timestamp: %s",
-+			             strerror (errno));
-+			goto out;
-+		}
-+
-+		if (statbuf.st_mtime == self->database_mtime) {
-+			ret = TRUE;
-+			goto out;
-+		}
-+	}
-+
-+	ret = reload_database (self, error);
-+
-+out:
-+	return ret;
-+}
-+
-+static void
-+on_file_monitor_changed (GFileMonitor *    file_monitor,
-+                         GFile *           file,
-+                         GFile *           other_file,
-+                         GFileMonitorEvent event_type,
-+                         gpointer          user_data)
-+{
-+	NMSessionMonitor *self = NM_SESSION_MONITOR (user_data);
-+
-+	/* throw away cache */
-+	free_database (self);
-+
-+	g_signal_emit (self, signals[CHANGED_SIGNAL], 0);
-+}
-+
- static gboolean
- sessions_changed (gpointer user_data)
- {
-@@ -145,9 +366,46 @@ sessions_changed (gpointer user_data)
- static void
- nm_session_monitor_init (NMSessionMonitor *monitor)
- {
--	monitor->sd_source = sd_source_new ();
--	g_source_set_callback (monitor->sd_source, sessions_changed, monitor, NULL);
--	g_source_attach (monitor->sd_source, NULL);
-+	if (sd_booted () > 0) {
-+		monitor->sd_source = sd_source_new ();
-+		g_source_set_callback (monitor->sd_source, sessions_changed, monitor, NULL);
-+		g_source_attach (monitor->sd_source, NULL);
-+
-+		monitor->database_monitor = NULL;
-+		monitor->database = NULL;
-+	} else {
-+		GError *error = NULL;
-+		GFile *file;
-+
-+		monitor->sd_source = NULL;
-+
-+		/* Sessions-by-user is responsible for destroying the Session objects */
-+		monitor->sessions_by_user = g_hash_table_new_full (g_str_hash, g_str_equal,
-+			                                            NULL, (GDestroyNotify) session_free);
-+		monitor->sessions_by_uid = g_hash_table_new (g_direct_hash, g_direct_equal);
-+
-+
-+		if (!ensure_database (monitor, &error)) {
-+			nm_log_dbg (LOGD_CORE, "Error loading " CKDB_PATH ": %s", error->message);
-+
-+			/* Ignore the first error, the CK database might not exist yet */
-+			g_error_free (error);
-+			error = NULL;
-+		}
-+
-+		file = g_file_new_for_path (CKDB_PATH);
-+		monitor->database_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, &error);
-+		g_object_unref (file);
-+		if (monitor->database_monitor == NULL) {
-+			nm_log_err (LOGD_CORE, "Error monitoring " CKDB_PATH ": %s", error->message);
-+			g_error_free (error);
-+		} else {
-+			g_signal_connect (monitor->database_monitor,
-+				              "changed",
-+				              G_CALLBACK (on_file_monitor_changed),
-+				              monitor);
-+		}
-+	}
+-#ifdef SESSION_TRACKING_CONSOLEKIT
+ typedef struct {
+ 	gboolean active;
+ } CkSession;
+@@ -272,7 +270,6 @@ ck_finalize (NMSessionMonitor *monitor)
+ 	g_clear_pointer (&monitor->ck.cache, g_hash_table_unref);
+ 	g_clear_object (&monitor->ck.monitor);
  }
+-#endif /* SESSION_TRACKING_CONSOLEKIT */
  
- static void
-@@ -155,11 +413,19 @@ nm_session_monitor_finalize (GObject *ob
- {
- 	NMSessionMonitor *monitor = NM_SESSION_MONITOR (object);
+ /********************************************************************/
  
--	if (monitor->sd_source != NULL) {
--		g_source_destroy (monitor->sd_source);
--		g_source_unref (monitor->sd_source);
-+	if (sd_booted () > 0) {
-+		if (monitor->sd_source != NULL) {
-+			g_source_destroy (monitor->sd_source);
-+			g_source_unref (monitor->sd_source);
-+		}
-+	} else {
-+		if (monitor->database_monitor != NULL)
-+			g_object_unref (monitor->database_monitor);
-+
-+		free_database (monitor);
- 	}
+@@ -383,13 +380,16 @@ nm_session_monitor_session_exists (NMSes
+ 	g_return_val_if_fail (NM_IS_SESSION_MONITOR (self), FALSE);
  
-+
- 	if (G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize != NULL)
- 		G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize (object);
- }
-@@ -205,15 +471,36 @@ nm_session_monitor_user_has_session (NMS
-                                      uid_t *out_uid,
-                                      GError **error)
- {
--	uid_t uid;
+ #ifdef SESSION_TRACKING_SYSTEMD
+-	if (st_sd_session_exists (self, uid, active))
+-		return TRUE;
 +	if (sd_booted () > 0) {
-+		uid_t uid;
- 
--	if (!nm_session_user_to_uid (username, &uid, error))
--		return FALSE;
-+		if (!nm_session_user_to_uid (username, &uid, error))
-+			return FALSE;
- 
--	if (out_uid)
--		*out_uid = uid;
-+		if (out_uid)
-+			*out_uid = uid;
- 
--	return nm_session_monitor_uid_has_session (monitor, uid, NULL, error);
-+		return nm_session_monitor_uid_has_session (monitor, uid, NULL, error);
++		if (st_sd_session_exists (self, uid, active))
++			return TRUE;
 +	} else {
-+		Session *s;
+ #endif
+-
+-#ifdef SESSION_TRACKING_CONSOLEKIT
+ 	if (ck_session_exists (self, uid, active))
+ 		return TRUE;
 +
-+		if (!ensure_database (monitor, error))
-+			return FALSE;
-+
-+		s = g_hash_table_lookup (monitor->sessions_by_user, (gpointer) username);
-+		if (!s) {
-+			g_set_error (error,
-+				         NM_MANAGER_ERROR,
-+				         NM_MANAGER_ERROR_FAILED,
-+				         "No session found for user '%s'",
-+				         username);
-+			return FALSE;
-+		}
-+
-+		if (out_uid)
-+			*out_uid = s->uid;
-+		return TRUE;
++#ifdef SESSION_TRACKING_SYSTEMD
 +	}
- }
+ #endif
  
- gboolean
-@@ -221,12 +508,31 @@ nm_session_monitor_user_active (NMSessio
-                                 const char *username,
-                                 GError **error)
+ 	return FALSE;
+@@ -401,11 +401,15 @@ static void
+ nm_session_monitor_init (NMSessionMonitor *monitor)
  {
--	uid_t uid;
+ #ifdef SESSION_TRACKING_SYSTEMD
+-	st_sd_init (monitor);
 +	if (sd_booted () > 0) {
-+		uid_t uid;
- 
--	if (!nm_session_user_to_uid (username, &uid, error))
--		return FALSE;
-+		if (!nm_session_user_to_uid (username, &uid, error))
-+			return FALSE;
-+
-+		return nm_session_monitor_uid_active (monitor, uid, error);
++		st_sd_init (monitor);
 +	} else {
-+		Session *s;
-+
-+		if (!ensure_database (monitor, error))
-+			return FALSE;
-+
-+		s = g_hash_table_lookup (monitor->sessions_by_user, (gpointer) username);
-+		if (!s) {
-+			g_set_error (error,
-+				         NM_MANAGER_ERROR,
-+				         NM_MANAGER_ERROR_FAILED,
-+				         "No session found for user '%s'",
-+				         username);
-+			return FALSE;
-+		}
+ #endif
  
--	return nm_session_monitor_uid_active (monitor, uid, error);
-+		return s->active;
+-#ifdef SESSION_TRACKING_CONSOLEKIT
+ 	ck_init (monitor);
++
++#ifdef SESSION_TRACKING_SYSTEMD
 +	}
+ #endif
  }
  
- gboolean
-@@ -235,19 +541,40 @@ nm_session_monitor_uid_has_session (NMSe
-                                     const char **out_user,
-                                     GError **error)
+@@ -413,11 +417,15 @@ static void
+ nm_session_monitor_finalize (GObject *object)
  {
--	int num_sessions;
+ #ifdef SESSION_TRACKING_SYSTEMD
+-	st_sd_finalize (NM_SESSION_MONITOR (object));
 +	if (sd_booted () > 0) {
-+		int num_sessions;
- 
--	if (!nm_session_uid_to_user (uid, out_user, error))
--		return FALSE;
-+		if (!nm_session_uid_to_user (uid, out_user, error))
-+			return FALSE;
- 
--	/* Get all sessions (including inactive ones) for the user */
--	num_sessions = sd_uid_get_sessions (uid, 0, NULL);
--	if (num_sessions < 0) {
--		nm_log_warn (LOGD_CORE, "Failed to get systemd sessions for uid %d: %d",
--		             uid, num_sessions);
--		return FALSE;
-+		/* Get all sessions (including inactive ones) for the user */
-+		num_sessions = sd_uid_get_sessions (uid, 0, NULL);
-+		if (num_sessions < 0) {
-+			nm_log_warn (LOGD_CORE, "Failed to get systemd sessions for uid %d: %d",
-+				         uid, num_sessions);
-+			return FALSE;
-+		}
-+		return num_sessions > 0;
++		st_sd_finalize (NM_SESSION_MONITOR (object));
 +	} else {
-+		Session *s;
-+
-+		if (!ensure_database (monitor, error))
-+			return FALSE;
-+
-+		s = g_hash_table_lookup (monitor->sessions_by_uid, GUINT_TO_POINTER (uid));
-+		if (!s) {
-+			g_set_error (error,
-+				         NM_MANAGER_ERROR,
-+				         NM_MANAGER_ERROR_FAILED,
-+				         "No session found for uid %d",
-+				         uid);
-+			return FALSE;
-+		}
-+
-+		if (out_user)
-+			*out_user = s->user;
-+		return TRUE;
- 	}
--	return num_sessions > 0;
- }
+ #endif
  
- gboolean
-@@ -255,14 +582,33 @@ nm_session_monitor_uid_active (NMSession
-                                uid_t uid,
-                                GError **error)
- {
--	int num_sessions;
-+	if (sd_booted () > 0) {
-+		int num_sessions;
- 
--	/* Get active sessions for the user */
--	num_sessions = sd_uid_get_sessions (uid, 1, NULL);
--	if (num_sessions < 0) {
--		nm_log_warn (LOGD_CORE, "Failed to get active systemd sessions for uid %d: %d",
--		             uid, num_sessions);
--		return FALSE;
-+		/* Get active sessions for the user */
-+		num_sessions = sd_uid_get_sessions (uid, 1, NULL);
-+		if (num_sessions < 0) {
-+			nm_log_warn (LOGD_CORE, "Failed to get active systemd sessions for uid %d: %d",
-+				         uid, num_sessions);
-+			return FALSE;
-+		}
-+		return num_sessions > 0;
-+	} else {
-+		Session *s;
-+
-+		if (!ensure_database (monitor, error))
-+			return FALSE;
+-#ifdef SESSION_TRACKING_CONSOLEKIT
+ 	ck_finalize (NM_SESSION_MONITOR (object));
 +
-+		s = g_hash_table_lookup (monitor->sessions_by_uid, GUINT_TO_POINTER (uid));
-+		if (!s) {
-+			g_set_error (error,
-+				         NM_MANAGER_ERROR,
-+				         NM_MANAGER_ERROR_FAILED,
-+				         "No session found for uid '%d'",
-+				         uid);
-+			return FALSE;
-+		}
-+
-+		return s->active;
- 	}
--	return num_sessions > 0;
- }
---- NetworkManager-1.0.0/src/nm-sleep-monitor-systemd.c.orig	2014-12-19 23:32:53.481973137 +0100
-+++ NetworkManager-1.0.0/src/nm-sleep-monitor-systemd.c	2014-12-20 00:12:04.572281013 +0100
-@@ -35,12 +35,15 @@
- #define SD_PATH              "/org/freedesktop/login1"
- #define SD_INTERFACE         "org.freedesktop.login1.Manager"
++#ifdef SESSION_TRACKING_SYSTEMD
++	}
+ #endif
  
-+#define UPOWER_DBUS_SERVICE "org.freedesktop.UPower"
+ 	if (G_OBJECT_CLASS (nm_session_monitor_parent_class)->finalize != NULL)
+--- NetworkManager-1.2.2/src/nm-sleep-monitor-systemd.c.systemd	2016-05-17 23:14:52.878336245 +0200
++++ NetworkManager-1.2.2/src/nm-sleep-monitor-systemd.c	2016-05-17 23:19:33.924628324 +0200
+@@ -24,6 +24,10 @@
+ #include <sys/stat.h>
+ #include <gio/gunixfdlist.h>
+ 
++#ifdef SUSPEND_RESUME_SYSTEMD
++# include <systemd/sd-daemon.h>
++#endif
++
+ #include "nm-core-internal.h"
+ #include "NetworkManagerUtils.h"
+ 
+@@ -33,23 +37,18 @@
+ #error either define SUSPEND_RESUME_SYSTEMD or SUSPEND_RESUME_CONSOLEKIT
+ #endif
+ 
+-#ifdef SUSPEND_RESUME_SYSTEMD
+-
+ #define SUSPEND_DBUS_NAME               "org.freedesktop.login1"
+ #define SUSPEND_DBUS_PATH               "/org/freedesktop/login1"
+ #define SUSPEND_DBUS_INTERFACE          "org.freedesktop.login1.Manager"
+ 
+-#else
+ 
+ /* ConsoleKit2 has added the same suspend/resume DBUS API that Systemd
+  * uses. http://consolekit2.github.io/ConsoleKit2/#Manager.Inhibit
+  */
+ 
+-#define SUSPEND_DBUS_NAME               "org.freedesktop.ConsoleKit"
+-#define SUSPEND_DBUS_PATH               "/org/freedesktop/ConsoleKit/Manager"
+-#define SUSPEND_DBUS_INTERFACE          "org.freedesktop.ConsoleKit.Manager"
+-
+-#endif
++#define CK_SUSPEND_DBUS_NAME               "org.freedesktop.ConsoleKit"
++#define CK_SUSPEND_DBUS_PATH               "/org/freedesktop/ConsoleKit/Manager"
++#define CK_SUSPEND_DBUS_INTERFACE          "org.freedesktop.ConsoleKit.Manager"
  
  struct _NMSleepMonitor {
  	GObject parent_instance;
- 
- 	GDBusProxy *sd_proxy;
- 	gint inhibit_fd;
-+
-+	DBusGProxy *upower_proxy;
- };
- 
- struct _NMSleepMonitorClass {
-@@ -62,6 +65,20 @@ G_DEFINE_TYPE (NMSleepMonitor, nm_sleep_
- 
- /********************************************************************/
- 
-+static void
-+upower_sleeping_cb (DBusGProxy *proxy, gpointer user_data)
-+{
-+        nm_log_dbg (LOGD_SUSPEND, "Received UPower sleeping signal");
-+        g_signal_emit (user_data, signals[SLEEPING], 0);
-+}
-+
-+static void
-+upower_resuming_cb (DBusGProxy *proxy, gpointer user_data)
-+{
-+        nm_log_dbg (LOGD_SUSPEND, "Received UPower resuming signal");
-+        g_signal_emit (user_data, signals[RESUMING], 0);
-+}
-+
- static gboolean
- drop_inhibitor (NMSleepMonitor *self)
- {
-@@ -193,14 +210,37 @@ on_proxy_acquired (GObject *object,
- static void
+@@ -204,13 +203,28 @@ static void
  nm_sleep_monitor_init (NMSleepMonitor *self)
  {
--	self->inhibit_fd = -1;
+ 	self->inhibit_fd = -1;
 -	g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
 -	                          G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
 -	                          G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
 -	                          NULL,
--	                          SD_NAME, SD_PATH, SD_INTERFACE,
+-	                          SUSPEND_DBUS_NAME, SUSPEND_DBUS_PATH, SUSPEND_DBUS_INTERFACE,
 -	                          NULL,
 -	                          (GAsyncReadyCallback) on_proxy_acquired, self);
++
++#ifdef SUSPEND_RESUME_SYSTEMD
 +	if (sd_booted () > 0) {
-+		self->inhibit_fd = -1;
 +		g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
 +			                      G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
 +			                      G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
 +			                      NULL,
-+			                      SD_NAME, SD_PATH, SD_INTERFACE,
++			                      SUSPEND_DBUS_NAME, SUSPEND_DBUS_PATH, SUSPEND_DBUS_INTERFACE,
 +			                      NULL,
 +			                      (GAsyncReadyCallback) on_proxy_acquired, self);
 +	} else {
-+		DBusGConnection *bus;
-+
-+        bus = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
-+        self->upower_proxy = dbus_g_proxy_new_for_name (bus,
-+                                                        UPOWER_DBUS_SERVICE,
-+                                                        "/org/freedesktop/UPower",
-+                                                        "org.freedesktop.UPower");
-+        if (self->upower_proxy) {
-+            dbus_g_proxy_add_signal (self->upower_proxy, "Sleeping", G_TYPE_INVALID);
-+            dbus_g_proxy_connect_signal (self->upower_proxy, "Sleeping",
-+                                         G_CALLBACK (upower_sleeping_cb),
-+                                         self, NULL);
-+
-+            dbus_g_proxy_add_signal (self->upower_proxy, "Resuming", G_TYPE_INVALID);
-+            dbus_g_proxy_connect_signal (self->upower_proxy, "Resuming",
-+                                         G_CALLBACK (upower_resuming_cb),
-+                                         self, NULL);
-+        } else {
-+    		nm_log_warn (LOGD_SUSPEND, "could not initialize UPower D-Bus proxy");
-+		}
++#endif
++		g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
++			                      G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
++			                      G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
++			                      NULL,
++			                      CK_SUSPEND_DBUS_NAME, CK_SUSPEND_DBUS_PATH, CK_SUSPEND_DBUS_INTERFACE,
++			                      NULL,
++			                      (GAsyncReadyCallback) on_proxy_acquired, self);
++#ifdef SUSPEND_RESUME_SYSTEMD
 +	}
++#endif
  }
  
  static void
-@@ -208,9 +248,14 @@ finalize (GObject *object)
- {
- 	NMSleepMonitor *self = NM_SLEEP_MONITOR (object);
- 
--	drop_inhibitor (self);
--	if (self->sd_proxy)
--		g_object_unref (self->sd_proxy);
-+	if (sd_booted () > 0) {
-+		drop_inhibitor (self);
-+		if (self->sd_proxy)
-+			g_object_unref (self->sd_proxy);
-+	} else {
-+		if (self->upower_proxy)
-+    		g_object_unref (self->upower_proxy);
-+	}
- 
- 	if (G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize != NULL)
- 		G_OBJECT_CLASS (nm_sleep_monitor_parent_class)->finalize (object);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/NetworkManager.git/commitdiff/ffec268f5dac5175af23da5f2631b222df51be69



More information about the pld-cvs-commit mailing list