- Rewrite patch another time leverage better api and be more terse
This commit is contained in:
parent
03acb97cd6
commit
e910da3bbd
@ -1,59 +1,7 @@
|
|||||||
diff -up gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-api gnome-session-2.24.0/gnome-session/gsm-consolekit.c
|
diff -up gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-api gnome-session-2.24.0/gnome-session/gsm-consolekit.c
|
||||||
--- gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
--- gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
||||||
+++ gnome-session-2.24.0/gnome-session/gsm-consolekit.c 2008-10-10 16:39:55.000000000 -0400
|
+++ gnome-session-2.24.0/gnome-session/gsm-consolekit.c 2008-10-10 17:43:35.000000000 -0400
|
||||||
@@ -54,6 +54,9 @@ struct _GsmConsolekitPrivate
|
@@ -825,20 +826,78 @@ gsm_consolekit_can_switch_user (GsmConso
|
||||||
DBusGConnection *dbus_connection;
|
|
||||||
DBusGProxy *bus_proxy;
|
|
||||||
DBusGProxy *ck_proxy;
|
|
||||||
+#ifdef HAVE_POLKIT_GNOME
|
|
||||||
+ PolKitSession *pk_session;
|
|
||||||
+#endif
|
|
||||||
guint32 is_connected : 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -140,11 +143,14 @@ static gboolean
|
|
||||||
gsm_consolekit_ensure_ck_connection (GsmConsolekit *manager,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
+ DBusConnection *connection;
|
|
||||||
GError *connection_error;
|
|
||||||
gboolean is_connected;
|
|
||||||
+ const char *cookie;
|
|
||||||
|
|
||||||
connection_error = NULL;
|
|
||||||
|
|
||||||
+ connection = NULL;
|
|
||||||
if (manager->priv->dbus_connection == NULL) {
|
|
||||||
manager->priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM,
|
|
||||||
&connection_error);
|
|
||||||
@@ -154,6 +160,8 @@ gsm_consolekit_ensure_ck_connection (Gsm
|
|
||||||
is_connected = FALSE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ connection = dbus_g_connection_get_connection (manager->priv->dbus_connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manager->priv->bus_proxy == NULL) {
|
|
||||||
@@ -198,6 +206,17 @@ gsm_consolekit_ensure_ck_connection (Gsm
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+#ifdef HAVE_POLKIT_GNOME
|
|
||||||
+ cookie = g_getenv ("XDG_SESSION_COOKIE");
|
|
||||||
+ if (manager->priv->pk_session == NULL && connection != NULL && cookie != NULL) {
|
|
||||||
+ DBusError error;
|
|
||||||
+
|
|
||||||
+ dbus_error_init (&error);
|
|
||||||
+ manager->priv->pk_session = polkit_session_new_from_cookie (connection, cookie, &error);
|
|
||||||
+ dbus_error_free (&error);
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
is_connected = TRUE;
|
|
||||||
|
|
||||||
out:
|
|
||||||
@@ -825,20 +844,62 @@ gsm_consolekit_can_switch_user (GsmConso
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,10 +11,10 @@ diff -up gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-ap
|
|||||||
+ const char *action_id)
|
+ const char *action_id)
|
||||||
+{
|
+{
|
||||||
+ PolKitGnomeContext *gnome_context;
|
+ PolKitGnomeContext *gnome_context;
|
||||||
+ PolKitPolicyCache *policy_cache;
|
|
||||||
+ PolKitPolicyFileEntry *file_entry;
|
|
||||||
+ PolKitPolicyDefault *policy;
|
|
||||||
+ PolKitAction *action;
|
+ PolKitAction *action;
|
||||||
|
+ PolKitCaller *caller;
|
||||||
|
+ DBusError dbus_error;
|
||||||
|
+ PolKitError *error;
|
||||||
+ PolKitResult result;
|
+ PolKitResult result;
|
||||||
+
|
+
|
||||||
+ gnome_context = polkit_gnome_context_get (NULL);
|
+ gnome_context = polkit_gnome_context_get (NULL);
|
||||||
@ -75,21 +23,38 @@ diff -up gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-ap
|
|||||||
+ return FALSE;
|
+ return FALSE;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ policy_cache = polkit_context_get_policy_cache (gnome_context->pk_context);
|
+ if (gnome_context->pk_tracker == NULL) {
|
||||||
+ file_entry = polkit_policy_cache_get_entry_by_id (policy_cache, action_id);
|
+ return FALSE;
|
||||||
+ policy = polkit_policy_file_entry_get_default (file_entry);
|
+ }
|
||||||
|
+
|
||||||
|
+ dbus_error_init (&dbus_error);
|
||||||
|
+ caller = polkit_tracker_get_caller_from_pid (gnome_context->pk_tracker,
|
||||||
|
+ getpid (),
|
||||||
|
+ &dbus_error);
|
||||||
|
+ dbus_error_free (&dbus_error);
|
||||||
|
+
|
||||||
|
+ if (caller == NULL) {
|
||||||
|
+ return FALSE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ action = polkit_action_new ();
|
+ action = polkit_action_new ();
|
||||||
|
+
|
||||||
+ if (!polkit_action_set_action_id (action, action_id)) {
|
+ if (!polkit_action_set_action_id (action, action_id)) {
|
||||||
+ polkit_action_unref (action);
|
+ polkit_action_unref (action);
|
||||||
|
+ polkit_caller_unref (caller);
|
||||||
+ return FALSE;
|
+ return FALSE;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ result = POLKIT_RESULT_UNKNOWN;
|
+ result = POLKIT_RESULT_UNKNOWN;
|
||||||
+ if (manager->priv->pk_session != NULL) {
|
+ error = NULL;
|
||||||
+ result = polkit_policy_default_can_session_do_action (policy,
|
+ result = polkit_context_is_caller_authorized (gnome_context->pk_context,
|
||||||
+ action,
|
+ action, caller, FALSE,
|
||||||
+ manager->priv->pk_session);
|
+ &error);
|
||||||
|
+ if (polkit_error_is_set (error)) {
|
||||||
|
+ polkit_error_free (error);
|
||||||
+ }
|
+ }
|
||||||
|
+ polkit_action_unref (action);
|
||||||
|
+ polkit_caller_unref (caller);
|
||||||
+
|
+
|
||||||
+ return result != POLKIT_RESULT_NO && result != POLKIT_RESULT_UNKNOWN;
|
+ return result != POLKIT_RESULT_NO && result != POLKIT_RESULT_UNKNOWN;
|
||||||
+}
|
+}
|
||||||
@ -101,7 +66,6 @@ diff -up gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-ap
|
|||||||
#ifdef HAVE_POLKIT_GNOME
|
#ifdef HAVE_POLKIT_GNOME
|
||||||
gboolean res;
|
gboolean res;
|
||||||
GError *error;
|
GError *error;
|
||||||
+
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
res = gsm_consolekit_ensure_ck_connection (manager, &error);
|
res = gsm_consolekit_ensure_ck_connection (manager, &error);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
@ -117,7 +81,7 @@ diff -up gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-ap
|
|||||||
#else
|
#else
|
||||||
g_debug ("GsmConsolekit: built without PolicyKit-gnome support - cannot restart system");
|
g_debug ("GsmConsolekit: built without PolicyKit-gnome support - cannot restart system");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -857,8 +918,11 @@ gsm_consolekit_can_stop (GsmConsolekit *
|
@@ -857,8 +916,11 @@ gsm_consolekit_can_stop (GsmConsolekit *
|
||||||
g_warning ("Could not connect to ConsoleKit: %s",
|
g_warning ("Could not connect to ConsoleKit: %s",
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
@ -132,7 +96,7 @@ diff -up gnome-session-2.24.0/gnome-session/gsm-consolekit.c.add-can-shutdown-ap
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
diff -up gnome-session-2.24.0/gnome-session/gsm-manager.c.add-can-shutdown-api gnome-session-2.24.0/gnome-session/gsm-manager.c
|
diff -up gnome-session-2.24.0/gnome-session/gsm-manager.c.add-can-shutdown-api gnome-session-2.24.0/gnome-session/gsm-manager.c
|
||||||
--- gnome-session-2.24.0/gnome-session/gsm-manager.c.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
--- gnome-session-2.24.0/gnome-session/gsm-manager.c.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
||||||
+++ gnome-session-2.24.0/gnome-session/gsm-manager.c 2008-10-10 16:16:17.000000000 -0400
|
+++ gnome-session-2.24.0/gnome-session/gsm-manager.c 2008-10-10 16:41:14.000000000 -0400
|
||||||
@@ -2313,6 +2313,35 @@ gsm_manager_shutdown (GsmManager *manage
|
@@ -2313,6 +2313,35 @@ gsm_manager_shutdown (GsmManager *manage
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +135,7 @@ diff -up gnome-session-2.24.0/gnome-session/gsm-manager.c.add-can-shutdown-api g
|
|||||||
GError **error)
|
GError **error)
|
||||||
diff -up gnome-session-2.24.0/gnome-session/gsm-manager.h.add-can-shutdown-api gnome-session-2.24.0/gnome-session/gsm-manager.h
|
diff -up gnome-session-2.24.0/gnome-session/gsm-manager.h.add-can-shutdown-api gnome-session-2.24.0/gnome-session/gsm-manager.h
|
||||||
--- gnome-session-2.24.0/gnome-session/gsm-manager.h.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
--- gnome-session-2.24.0/gnome-session/gsm-manager.h.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
||||||
+++ gnome-session-2.24.0/gnome-session/gsm-manager.h 2008-10-10 16:16:17.000000000 -0400
|
+++ gnome-session-2.24.0/gnome-session/gsm-manager.h 2008-10-10 16:41:14.000000000 -0400
|
||||||
@@ -151,6 +151,10 @@ gboolean gsm_manager_is_inhib
|
@@ -151,6 +151,10 @@ gboolean gsm_manager_is_inhib
|
||||||
|
|
||||||
gboolean gsm_manager_shutdown (GsmManager *manager,
|
gboolean gsm_manager_shutdown (GsmManager *manager,
|
||||||
@ -185,7 +149,7 @@ diff -up gnome-session-2.24.0/gnome-session/gsm-manager.h.add-can-shutdown-api g
|
|||||||
GError **error);
|
GError **error);
|
||||||
diff -up gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml.add-can-shutdown-api gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml
|
diff -up gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml.add-can-shutdown-api gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml
|
||||||
--- gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
--- gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml.add-can-shutdown-api 2008-09-22 17:21:08.000000000 -0400
|
||||||
+++ gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml 2008-10-10 16:16:17.000000000 -0400
|
+++ gnome-session-2.24.0/gnome-session/org.gnome.SessionManager.xml 2008-10-10 16:41:14.000000000 -0400
|
||||||
@@ -252,6 +252,20 @@
|
@@ -252,6 +252,20 @@
|
||||||
</doc:doc>
|
</doc:doc>
|
||||||
</method>
|
</method>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
Summary: GNOME session manager
|
Summary: GNOME session manager
|
||||||
Name: gnome-session
|
Name: gnome-session
|
||||||
Version: 2.24.0
|
Version: 2.24.0
|
||||||
Release: 9%{?dist}
|
Release: 10%{?dist}
|
||||||
URL: http://www.gnome.org
|
URL: http://www.gnome.org
|
||||||
Source0: http://download.gnome.org/sources/gnome-session/2.24/%{name}-%{version}.tar.bz2
|
Source0: http://download.gnome.org/sources/gnome-session/2.24/%{name}-%{version}.tar.bz2
|
||||||
Source1: redhat-default-session
|
Source1: redhat-default-session
|
||||||
@ -196,6 +196,10 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Oct 10 2008 Ray Strode <rstrode@redhat.com> - 2.24.0-10
|
||||||
|
- Rewrite patch another time leverage better api and be more
|
||||||
|
terse
|
||||||
|
|
||||||
* Fri Oct 10 2008 Ray Strode <rstrode@redhat.com> - 2.24.0-9
|
* Fri Oct 10 2008 Ray Strode <rstrode@redhat.com> - 2.24.0-9
|
||||||
- Bring shutdown menu item back. More fallout from my buggy
|
- Bring shutdown menu item back. More fallout from my buggy
|
||||||
patch introduced in -7
|
patch introduced in -7
|
||||||
|
Loading…
Reference in New Issue
Block a user