update patches

This commit is contained in:
Matthias Clasen 2010-09-30 13:08:34 -04:00
parent f26e73d9be
commit aca6759145
3 changed files with 1448 additions and 385 deletions

View File

@ -1,52 +1,45 @@
diff -up gnome-system-monitor-2.26.1/configure.in.polkit gnome-system-monitor-2.26.1/configure.in diff -up gnome-system-monitor-2.28.2/configure.in.polkit gnome-system-monitor-2.28.2/configure.in
--- gnome-system-monitor-2.26.1/configure.in.polkit 2009-04-10 18:33:14.000000000 -0400 --- gnome-system-monitor-2.28.2/configure.in.polkit 2010-09-27 19:13:17.000000000 -0400
+++ gnome-system-monitor-2.26.1/configure.in 2009-04-23 15:01:02.779508852 -0400 +++ gnome-system-monitor-2.28.2/configure.in 2010-09-30 13:00:35.606603002 -0400
@@ -35,10 +35,41 @@ GIOMM_REQUIRED=2.16.0 @@ -35,10 +35,35 @@ GIOMM_REQUIRED=2.16.0
GLIBMM_REQUIRED=2.14 GLIBMM_REQUIRED=2.14
LIBXML_REQUIRED=2.0 LIBXML_REQUIRED=2.0
RSVG_REQUIRED=2.12 RSVG_REQUIRED=2.12
-DBUS_REQUIRED=0.7 -DBUS_REQUIRED=0.7
- +POLKIT_REQUIRED=0.92
-PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED dbus-glib-1 >= $DBUS_REQUIRED)
+POLKIT_GNOME_REQUIRED=0.7
+POLKIT_DBUS_REQUIRED=0.7
+DBUS_GLIB_REQUIRED=0.71 +DBUS_GLIB_REQUIRED=0.71
+DBUS_REQUIRED=1.1.2 +DBUS_REQUIRED=1.1.2
+
+ -PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED dbus-glib-1 >= $DBUS_REQUIRED)
+PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED) +PKG_CHECK_MODULES(PROCMAN, glib-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-1.0 >= $LIBWNCK_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gnome-icon-theme >= $GNOME_ICON_THEME_REQUIRED gtkmm-2.4 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED)
+ +
+# PolicyKit detection; defaults to 'auto' (use it if it's available) +# PolicyKit detection; defaults to 'auto' (use it if it's available)
+# +#
+POLKIT_GNOME_CFLAGS= +POLKIT_CFLAGS=
+POLKIT_GNOME_LIBS= +POLKIT_LIBS=
+POLKIT_DBUS_CFLAGS=
+POLKIT_DBUS_LIBS=
+AC_ARG_ENABLE(polkit, AS_HELP_STRING([--enable-polkit],[Enable PolicyKit support (auto)]),enable_polkit=$enableval,enable_polkit=auto) +AC_ARG_ENABLE(polkit, AS_HELP_STRING([--enable-polkit],[Enable PolicyKit support (auto)]),enable_polkit=$enableval,enable_polkit=auto)
+if test "x$enable_polkit" = "xno" ; then +if test "x$enable_polkit" = "xno" ; then
+ HAVE_POLKIT=no + HAVE_POLKIT=no
+else +else
+ HAVE_POLKIT=no + HAVE_POLKIT=no
+ PKG_CHECK_MODULES(POLKIT_GNOME, polkit-gnome >= $POLKIT_GNOME_REQUIRED dbus-1 >= $DBUS_REQUIRED, HAVE_POLKIT=yes, HAVE_POLKIT=no) + PKG_CHECK_MODULES(POLKIT, polkit-gobject-1 >= $POLKIT_REQUIRED dbus-1 >= $DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gobject-2.0, HAVE_POLKIT=yes, HAVE_POLKIT=no)
+
+ if test "x$enable_polkit" = "xyes" -a "x$HAVE_POLKIT" = "xno" ; then + if test "x$enable_polkit" = "xyes" -a "x$HAVE_POLKIT" = "xno" ; then
+ AC_MSG_ERROR(PolicyKit support explicity enabled but not available) + AC_MSG_ERROR(PolicyKit support explicity enabled but not available)
+ fi + fi
+ +
+ if test "x$HAVE_POLKIT" = "xyes" ; then + if test "x$HAVE_POLKIT" = "xyes" ; then
+ AC_DEFINE(HAVE_POLKIT, 1, [Defined if PolicyKit support is enabled]) + AC_DEFINE(HAVE_POLKIT, 1, [Defined if PolicyKit support is enabled])
+ PKG_CHECK_MODULES(POLKIT_DBUS, polkit-dbus >= $POLKIT_DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gobject-2.0)
+ fi + fi
+fi +fi
+AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes") +AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes")
+AC_SUBST(POLKIT_GNOME_CFLAGS) +AC_SUBST(POLKIT_CFLAGS)
+AC_SUBST(POLKIT_GNOME_LIBS) +AC_SUBST(POLKIT_LIBS)
+AC_SUBST(POLKIT_DBUS_CFLAGS)
+AC_SUBST(POLKIT_DBUS_LIBS)
AC_ARG_ENABLE(more-warnings, AC_ARG_ENABLE(more-warnings,
[AC_HELP_STRING([--enable-more-warnings], [Maximum compiler warnings])], [AC_HELP_STRING([--enable-more-warnings], [Maximum compiler warnings])],
@@ -98,6 +129,7 @@ Configuration: @@ -98,6 +123,7 @@ Configuration:
C++ Compiler: ${CXX} C++ Compiler: ${CXX}
CFLAGS: ${CFLAGS} CFLAGS: ${CFLAGS}
CXXFLAGS: ${CXXFLAGS} CXXFLAGS: ${CXXFLAGS}
@ -54,9 +47,9 @@ diff -up gnome-system-monitor-2.26.1/configure.in.polkit gnome-system-monitor-2.
Maintainer mode: ${USER_MAINTAINER_MODE} Maintainer mode: ${USER_MAINTAINER_MODE}
Languages: ${ALL_LINGUAS} Languages: ${ALL_LINGUAS}
" "
diff -up gnome-system-monitor-2.26.1/po/POTFILES.in.polkit gnome-system-monitor-2.26.1/po/POTFILES.in diff -up gnome-system-monitor-2.28.2/po/POTFILES.in.polkit gnome-system-monitor-2.28.2/po/POTFILES.in
--- gnome-system-monitor-2.26.1/po/POTFILES.in.polkit 2009-04-13 15:36:22.000000000 -0400 --- gnome-system-monitor-2.28.2/po/POTFILES.in.polkit 2010-02-09 08:23:26.000000000 -0500
+++ gnome-system-monitor-2.26.1/po/POTFILES.in 2009-04-23 15:01:02.779508852 -0400 +++ gnome-system-monitor-2.28.2/po/POTFILES.in 2010-09-30 13:00:35.584603002 -0400
@@ -8,6 +8,7 @@ src/callbacks.cpp @@ -8,6 +8,7 @@ src/callbacks.cpp
src/defaulttable.h src/defaulttable.h
src/disks.cpp src/disks.cpp
@ -65,35 +58,11 @@ diff -up gnome-system-monitor-2.26.1/po/POTFILES.in.polkit gnome-system-monitor-
src/gnome-system-monitor.schemas.in src/gnome-system-monitor.schemas.in
src/gsm_color_button.c src/gsm_color_button.c
src/interface.cpp src/interface.cpp
diff -up gnome-system-monitor-2.26.1/src/callbacks.cpp.polkit gnome-system-monitor-2.26.1/src/callbacks.cpp diff -up gnome-system-monitor-2.28.2/src/callbacks.cpp.polkit gnome-system-monitor-2.28.2/src/callbacks.cpp
--- gnome-system-monitor-2.26.1/src/callbacks.cpp.polkit 2009-01-20 16:00:27.000000000 -0500 diff -up gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.c.polkit gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.c
+++ gnome-system-monitor-2.26.1/src/callbacks.cpp 2009-04-23 15:01:24.243745907 -0400 --- gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.c.polkit 2010-09-30 13:00:35.587603002 -0400
@@ -210,11 +210,13 @@ cb_app_delete (GtkWidget *window, GdkEve +++ gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.c 2010-09-30 13:00:35.609603002 -0400
@@ -0,0 +1,592 @@
+#ifndef HAVE_POLKIT
void
cb_end_process_button_pressed (GtkButton *button, gpointer data)
{
kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
}
+#endif
static void change_gconf_color(GConfClient *client, const char *key,
@@ -286,6 +288,7 @@ cb_row_selected (GtkTreeSelection *selec
ProcData * const procdata = static_cast<ProcData*>(data);
procdata->selection = selection;
+ procdata->selected_process = NULL;
/* get the most recent selected process and determine if there are
** no selected processes
diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanism.c
--- /dev/null 2009-04-23 10:50:49.279044520 -0400
+++ gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanism.c 2009-04-23 15:01:02.782492856 -0400
@@ -0,0 +1,640 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * + *
+ * Copyright (C) 2007 David Zeuthen <david@fubar.dk> + * Copyright (C) 2007 David Zeuthen <david@fubar.dk>
@ -136,7 +105,7 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+#include <glib-object.h> +#include <glib-object.h>
+#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h> +#include <dbus/dbus-glib-lowlevel.h>
+#include <polkit-dbus/polkit-dbus.h> +#include <polkit/polkit.h>
+ +
+static gboolean no_exit = FALSE; +static gboolean no_exit = FALSE;
+ +
@ -220,7 +189,7 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+{ +{
+ DBusGConnection *system_bus_connection; + DBusGConnection *system_bus_connection;
+ DBusGProxy *system_bus_proxy; + DBusGProxy *system_bus_proxy;
+ PolKitContext *pol_ctx; + PolkitAuthority *pol_ctx;
+}; +};
+ +
+static void gnome_system_monitor_mechanism_class_init (GnomeSystemMonitorMechanismClass *klass); +static void gnome_system_monitor_mechanism_class_init (GnomeSystemMonitorMechanismClass *klass);
@ -328,50 +297,11 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+} +}
+ +
+static gboolean +static gboolean
+pk_io_watch_have_data (GIOChannel *channel, GIOCondition condition, gpointer user_data)
+{
+ int fd;
+ PolKitContext *pk_context = user_data;
+ fd = g_io_channel_unix_get_fd (channel);
+ polkit_context_io_func (pk_context, fd);
+ return TRUE;
+}
+
+static int
+pk_io_add_watch (PolKitContext *pk_context, int fd)
+{
+ guint id = 0;
+ GIOChannel *channel;
+ channel = g_io_channel_unix_new (fd);
+ if (channel == NULL)
+ goto out;
+ id = g_io_add_watch (channel, G_IO_IN, pk_io_watch_have_data, pk_context);
+ if (id == 0) {
+ g_io_channel_unref (channel);
+ goto out;
+ }
+ g_io_channel_unref (channel);
+out:
+ return id;
+}
+
+static void
+pk_io_remove_watch (PolKitContext *pk_context, int watch_id)
+{
+ g_source_remove (watch_id);
+}
+
+static gboolean
+register_mechanism (GnomeSystemMonitorMechanism *mechanism) +register_mechanism (GnomeSystemMonitorMechanism *mechanism)
+{ +{
+ GError *error = NULL; + GError *error = NULL;
+ +
+ mechanism->priv->pol_ctx = polkit_context_new (); + mechanism->priv->pol_ctx = polkit_authority_get ();
+ polkit_context_set_io_watch_functions (mechanism->priv->pol_ctx, pk_io_add_watch, pk_io_remove_watch);
+ if (!polkit_context_init (mechanism->priv->pol_ctx, NULL)) {
+ g_critical ("cannot initialize libpolkit");
+ goto error;
+ }
+ +
+ error = NULL; + error = NULL;
+ mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); + mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@ -417,93 +347,66 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+ return GNOME_SYSTEM_MONITOR_MECHANISM (object); + return GNOME_SYSTEM_MONITOR_MECHANISM (object);
+} +}
+ +
+static PolKitCaller * +static PolkitSubject *
+get_caller_from_context (GnomeSystemMonitorMechanism *mechanism, DBusGMethodInvocation *context) +get_caller_from_context (GnomeSystemMonitorMechanism *mechanism, DBusGMethodInvocation *context)
+{ +{
+ const char *sender; + char *sender;
+ GError *error; + PolkitSubject *pk_caller;
+ DBusError dbus_error;
+ PolKitCaller *pk_caller;
+ +
+ sender = dbus_g_method_get_sender (context); + sender = dbus_g_method_get_sender (context);
+ dbus_error_init (&dbus_error); + pk_caller = polkit_system_bus_name_new (sender);
+ pk_caller = polkit_caller_new_from_dbus_name ( + g_free (sender);
+ dbus_g_connection_get_connection (mechanism->priv->system_bus_connection),
+ sender,
+ &dbus_error);
+ if (pk_caller == NULL) {
+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR,
+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL,
+ "Error getting information about caller: %s: %s",
+ dbus_error.name, dbus_error.message);
+ dbus_error_free (&dbus_error);
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return NULL;
+ }
+ +
+ return pk_caller; + return pk_caller;
+} +}
+ +
+/* note, we take ownership of the passed PolKitCaller object */ +/* note, we take ownership of the passed PolkitSubject object */
+static gboolean +static gboolean
+_check_polkit_for_action_for_caller (GnomeSystemMonitorMechanism *mechanism, +_check_polkit_for_action_for_caller (GnomeSystemMonitorMechanism *mechanism,
+ DBusGMethodInvocation *context, + DBusGMethodInvocation *context,
+ PolKitCaller *pk_caller, + PolkitSubject *subject,
+ const char *action, + const char *action)
+ const char *action_secondary)
+{ +{
+ GError *error; + GError *error;
+ PolKitAction *pk_action; + PolkitAuthorizationResult *result;
+ PolKitResult pk_result;
+ +
+ error = NULL; + error = NULL;
+ +
+ pk_action = polkit_action_new (); + result = polkit_authority_check_authorization_sync (mechanism->priv->pol_ctx,
+ polkit_action_set_action_id (pk_action, action); + subject,
+ pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx, + action,
+ pk_action, + NULL,
+ pk_caller, + POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+ TRUE, + NULL, NULL);
+ NULL); + g_object_unref (subject);
+ if (pk_result != POLKIT_RESULT_YES) {
+ polkit_action_set_action_id (pk_action, action_secondary);
+ pk_result = polkit_context_is_caller_authorized (mechanism->priv->pol_ctx,
+ pk_action,
+ pk_caller,
+ TRUE,
+ NULL);
+ }
+ polkit_action_unref (pk_action);
+ polkit_caller_unref (pk_caller);
+ +
+ if (pk_result != POLKIT_RESULT_YES) { + if (!polkit_authorization_result_get_is_authorized (result)) {
+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, + error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR,
+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED, + GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_NOT_PRIVILEGED,
+ "%s %s <-- (action, result)", + "%s",
+ action, + action);
+ polkit_result_to_string_representation (pk_result));
+ dbus_g_method_return_error (context, error); + dbus_g_method_return_error (context, error);
+ g_error_free (error); + g_error_free (error);
+ g_object_unref (result);
+ return FALSE; + return FALSE;
+ } + }
+ +
+ g_object_unref (result);
+ return TRUE; + return TRUE;
+} +}
+ +
+static gboolean +static gboolean
+_check_polkit_for_action (GnomeSystemMonitorMechanism *mechanism, +_check_polkit_for_action (GnomeSystemMonitorMechanism *mechanism,
+ DBusGMethodInvocation *context, + DBusGMethodInvocation *context,
+ const char *action, + const char *action)
+ const char *action_secondary)
+{ +{
+ PolKitCaller *pk_caller; + PolkitSubject *subject;
+ +
+ /* Check that caller is privileged */ + /* Check that caller is privileged */
+ if ((pk_caller = get_caller_from_context (mechanism, context)) == NULL) + if ((subject = get_caller_from_context (mechanism, context)) == NULL)
+ return FALSE; + return FALSE;
+ +
+ return _check_polkit_for_action_for_caller (mechanism, context, pk_caller, action, action_secondary); + return _check_polkit_for_action_for_caller (mechanism, context, subject, action);
+} +}
+ +
+/*--------------------------------------------------------------------------------------------------------------*/ +/*--------------------------------------------------------------------------------------------------------------*/
@ -517,7 +420,7 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+{ +{
+ reset_killtimer (); + reset_killtimer ();
+ +
+ if (!_check_polkit_for_action (mechanism, context, "org.gnome.system-monitor.kill", NULL)) + if (!_check_polkit_for_action (mechanism, context, "org.gnome.system-monitor.kill"))
+ return FALSE; + return FALSE;
+ +
+ g_debug ("Sending signal %d to pid %d", sig, pid); + g_debug ("Sending signal %d to pid %d", sig, pid);
@ -537,6 +440,28 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+ return TRUE; + return TRUE;
+} +}
+ +
+static gboolean
+get_uid_from_context (GnomeSystemMonitorMechanism *mechanism,
+ DBusGMethodInvocation *context,
+ uid_t *uid)
+{
+ char *sender;
+ DBusConnection *con;
+
+ con = dbus_g_connection_get_connection (dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL));
+ if (con == NULL)
+ return FALSE;
+
+ sender = dbus_g_method_get_sender (context);
+ *uid = dbus_bus_get_unix_user (con, sender, NULL);
+ g_free (sender);
+
+ if (*uid == (unsigned)-1)
+ return FALSE;
+
+ return TRUE;
+}
+
+gboolean +gboolean
+gnome_system_monitor_mechanism_renice (GnomeSystemMonitorMechanism *mechanism, +gnome_system_monitor_mechanism_renice (GnomeSystemMonitorMechanism *mechanism,
+ int pid, + int pid,
@ -545,11 +470,10 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+{ +{
+ uid_t caller_uid; + uid_t caller_uid;
+ uid_t process_uid; + uid_t process_uid;
+ PolKitCaller *pk_caller; + PolkitSubject *subject;
+ char *procpath; + char *procpath;
+ struct stat statbuf; + struct stat statbuf;
+ const char *action_id; + const char *action_id;
+ const char *action_id_secondary;
+ +
+ reset_killtimer (); + reset_killtimer ();
+ +
@ -569,11 +493,11 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+ g_free (procpath); + g_free (procpath);
+ process_uid = statbuf.st_uid; + process_uid = statbuf.st_uid;
+ +
+ pk_caller = get_caller_from_context (mechanism, context); + subject = get_caller_from_context (mechanism, context);
+ if (pk_caller == NULL) + if (subject == NULL)
+ return FALSE; + return FALSE;
+ +
+ if (!polkit_caller_get_uid (pk_caller, &caller_uid)) { + if (!get_uid_from_context (mechanism, context, &caller_uid)) {
+ GError *error; + GError *error;
+ error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR, + error = g_error_new (GNOME_SYSTEM_MONITOR_MECHANISM_ERROR,
+ GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL, + GNOME_SYSTEM_MONITOR_MECHANISM_ERROR_GENERAL,
@ -581,24 +505,21 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+ g_warning ("Error: %s", error->message); + g_warning ("Error: %s", error->message);
+ dbus_g_method_return_error (context, error); + dbus_g_method_return_error (context, error);
+ g_error_free (error); + g_error_free (error);
+ polkit_caller_unref (pk_caller); + g_object_unref (subject);
+ return FALSE; + return FALSE;
+ } + }
+ +
+ if (caller_uid == process_uid) { + if (caller_uid == process_uid) {
+ /* we need either .increase-own-priority or .change-priority */
+ action_id = "org.gnome.system-monitor.increase-own-priority"; + action_id = "org.gnome.system-monitor.increase-own-priority";
+ action_id_secondary = "org.gnome.system-monitor.change-priority";
+ } else { + } else {
+ action_id = "org.gnome.system-monitor.change-priority"; + action_id = "org.gnome.system-monitor.change-priority";
+ action_id_secondary = NULL;
+ } + }
+ +
+ if (!_check_polkit_for_action_for_caller (mechanism, context, pk_caller, action_id, action_id_secondary)) { + if (!_check_polkit_for_action_for_caller (mechanism, context, subject, action_id)) {
+ return FALSE; + return FALSE;
+ } + }
+ +
+ g_debug ("Renicing pid %d (owned by uid %d) to priority %d on behalf of uid %d (action_id=%s)", + g_debug ("Renicing pid %d (owned by uid %d) to priority %d on behalf of uid %d (action_id=%s)",
+ pid, process_uid, nice_value, caller_uid, action_id); + pid, process_uid, nice_value, caller_uid, action_id);
+ +
+ errno = 0; + errno = 0;
@ -734,9 +655,9 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+out: +out:
+ return ret; + return ret;
+} +}
diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanism.xml diff -up gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.xml.polkit gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.xml
--- /dev/null 2009-04-23 10:50:49.279044520 -0400 --- gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.xml.polkit 2010-09-30 13:00:35.588603002 -0400
+++ gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanism.xml 2009-04-23 15:01:02.782492856 -0400 +++ gnome-system-monitor-2.28.2/src/gnome-system-monitor-mechanism.xml 2010-09-30 13:00:35.588603002 -0400
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node name="/"> +<node name="/">
@ -753,15 +674,15 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/gnome-system-monitor-mechanis
+ </method> + </method>
+ </interface> + </interface>
+</node> +</node>
diff -up gnome-system-monitor-2.26.1/src/interface.cpp.polkit gnome-system-monitor-2.26.1/src/interface.cpp diff -up gnome-system-monitor-2.28.2/src/interface.cpp.polkit gnome-system-monitor-2.28.2/src/interface.cpp
--- gnome-system-monitor-2.26.1/src/interface.cpp.polkit 2009-04-10 18:33:14.000000000 -0400 --- gnome-system-monitor-2.28.2/src/interface.cpp.polkit 2010-02-09 08:23:26.000000000 -0500
+++ gnome-system-monitor-2.26.1/src/interface.cpp 2009-04-23 15:02:01.567746154 -0400 +++ gnome-system-monitor-2.28.2/src/interface.cpp 2010-09-30 13:00:35.611603002 -0400
@@ -30,6 +30,10 @@ @@ -30,6 +30,10 @@
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <math.h> #include <math.h>
+#ifdef HAVE_POLKIT +#ifdef HAVE_POLKIT
+# include <polkit-gnome/polkit-gnome.h> +# include <polkit/polkit.h>
+#endif +#endif
+ +
#include "procman.h" #include "procman.h"
@ -783,12 +704,14 @@ diff -up gnome-system-monitor-2.26.1/src/interface.cpp.polkit gnome-system-monit
{ "ChangePriority", NULL, N_("_Change Priority..."), "<control>N", { "ChangePriority", NULL, N_("_Change Priority..."), "<control>N",
N_("Change the order of priority of process"), G_CALLBACK (cb_renice) }, N_("Change the order of priority of process"), G_CALLBACK (cb_renice) },
{ "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL, { "Preferences", GTK_STOCK_PREFERENCES, NULL, NULL,
@@ -186,10 +192,14 @@ create_proc_view (ProcData *procdata) @@ -186,10 +192,16 @@ create_proc_view (ProcData *procdata)
hbox2 = gtk_hbox_new (FALSE, 0); hbox2 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);
+#ifdef HAVE_POLKIT +#ifdef HAVE_POLKIT
+ procdata->endprocessbutton = polkit_gnome_action_create_button (procdata->sigterm_action); + procdata->endprocessbutton = gtk_button_new ();
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (procdata->endprocessbutton),
+ procdata->sigterm_action);
+#else +#else
procdata->endprocessbutton = gtk_button_new_with_mnemonic (_("End _Process")); procdata->endprocessbutton = gtk_button_new_with_mnemonic (_("End _Process"));
- gtk_box_pack_end (GTK_BOX (hbox2), procdata->endprocessbutton, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbox2), procdata->endprocessbutton, FALSE, FALSE, 0);
@ -799,44 +722,40 @@ diff -up gnome-system-monitor-2.26.1/src/interface.cpp.polkit gnome-system-monit
/* create popup_menu */ /* create popup_menu */
@@ -670,6 +680,45 @@ create_main_window (ProcData *procdata) @@ -670,6 +682,41 @@ create_main_window (ProcData *procdata)
G_CALLBACK(cb_radio_processes), G_CALLBACK(cb_radio_processes),
procdata); procdata);
+#ifdef HAVE_POLKIT +#ifdef HAVE_POLKIT
+ procdata->sigstop_action = polkit_gnome_action_new_default ("StopProcess", + procdata->sigstop_action = gtk_action_new ("StopProcess",
+ NULL, + _("_Stop Process"),
+ _("_Stop Process"), + _("Stop process"),
+ _("Stop process")); + NULL);
+ g_object_set (procdata->sigstop_action, "auth-label", _("_Stop Process..."), NULL);
+ g_signal_connect (procdata->sigstop_action, "activate", G_CALLBACK (cb_kill_sigstop), procdata); + g_signal_connect (procdata->sigstop_action, "activate", G_CALLBACK (cb_kill_sigstop), procdata);
+ gtk_action_group_add_action_with_accel (procdata->action_group, + gtk_action_group_add_action_with_accel (procdata->action_group,
+ GTK_ACTION (procdata->sigstop_action), + GTK_ACTION (procdata->sigstop_action),
+ "<control>S"); + "<control>S");
+ +
+ procdata->sigcont_action = polkit_gnome_action_new_default ("ContProcess", + procdata->sigcont_action = gtk_action_new ("ContProcess",
+ NULL, + _("_Continue Process"),
+ _("_Continue Process"), + _("Continue process"),
+ _("Continue process")); + NULL);
+ g_object_set (procdata->sigcont_action, "auth-label", _("_Continue Process..."), NULL);
+ g_signal_connect (procdata->sigcont_action, "activate", G_CALLBACK (cb_kill_sigcont), procdata); + g_signal_connect (procdata->sigcont_action, "activate", G_CALLBACK (cb_kill_sigcont), procdata);
+ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigcont_action), + gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigcont_action),
+ "<control>C"); + "<control>C");
+ +
+ procdata->sigterm_action = polkit_gnome_action_new_default ("EndProcess", + procdata->sigterm_action = gtk_action_new ("EndProcess",
+ NULL, + _("End _Process"),
+ _("End _Process"), + _("Force process to finish normally"),
+ _("Force process to finish normally")); + NULL);
+ g_object_set (procdata->sigterm_action, "auth-label", _("End _Process..."), NULL);
+ g_signal_connect (procdata->sigterm_action, "activate", G_CALLBACK (cb_end_process), procdata); + g_signal_connect (procdata->sigterm_action, "activate", G_CALLBACK (cb_end_process), procdata);
+ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigterm_action), + gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigterm_action),
+ "<control>E"); + "<control>E");
+ +
+ procdata->sigkill_action = polkit_gnome_action_new_default ("KillProcess", + procdata->sigkill_action = gtk_action_new ("KillProcess",
+ NULL, + _("_Kill Process"),
+ _("_Kill Process"), + _("Force process to finish immediately"),
+ _("Force process to finish immediately")); + NULL);
+ g_object_set (procdata->sigkill_action, "auth-label", _("_Kill Process..."), NULL);
+ g_signal_connect (procdata->sigkill_action, "activate", G_CALLBACK (cb_kill_process), procdata); + g_signal_connect (procdata->sigkill_action, "activate", G_CALLBACK (cb_kill_process), procdata);
+ gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigkill_action), + gtk_action_group_add_action_with_accel (procdata->action_group, GTK_ACTION (procdata->sigkill_action),
+ "<control>K"); + "<control>K");
@ -845,7 +764,7 @@ diff -up gnome-system-monitor-2.26.1/src/interface.cpp.polkit gnome-system-monit
gtk_ui_manager_insert_action_group (procdata->uimanager, gtk_ui_manager_insert_action_group (procdata->uimanager,
procdata->action_group, procdata->action_group,
0); 0);
@@ -677,7 +726,6 @@ create_main_window (ProcData *procdata) @@ -677,7 +724,6 @@ create_main_window (ProcData *procdata)
menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar"); menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
@ -853,7 +772,7 @@ diff -up gnome-system-monitor-2.26.1/src/interface.cpp.polkit gnome-system-monit
/* create the main notebook */ /* create the main notebook */
procdata->notebook = notebook = gtk_notebook_new (); procdata->notebook = notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (main_box), gtk_box_pack_start (GTK_BOX (main_box),
@@ -774,23 +822,53 @@ update_sensitivity(ProcData *data) @@ -774,23 +820,26 @@ update_sensitivity(ProcData *data)
processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES); processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
selected_sensitivity = (processes_sensitivity && data->selected_process != NULL); selected_sensitivity = (processes_sensitivity && data->selected_process != NULL);
@ -875,50 +794,24 @@ diff -up gnome-system-monitor-2.26.1/src/interface.cpp.polkit gnome-system-monit
for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) { for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
action = gtk_action_group_get_action(data->action_group, action = gtk_action_group_get_action(data->action_group,
selected_actions[i]); selected_actions[i]);
+#ifdef HAVE_POLKIT - gtk_action_set_sensitive(action, selected_sensitivity);
+ if (POLKIT_GNOME_IS_ACTION (action)) { + gtk_action_set_sensitive(action, processes_sensitivity);
+ polkit_gnome_action_set_sensitive (POLKIT_GNOME_ACTION (action), selected_sensitivity);
+ } else {
+ gtk_action_set_sensitive(action, selected_sensitivity);
+ }
+#else
gtk_action_set_sensitive(action, selected_sensitivity);
+#endif
} }
+ +
+#ifdef HAVE_POLKIT
+ /* update the PolicyKit actions */
+ if (data->selected_process != NULL) {
+ ProcInfo *pi = data->selected_process;
+ PolKitAction *pk_action;
+
+ /* TODO: multiple processes may be selected; consider all of them */
+
+ if (pi->uid == getuid ()) {
+ pk_action = NULL;
+ } else {
+ pk_action = data->pk_action_kill;
+ }
+ g_object_set (data->sigstop_action, "polkit-action", pk_action, NULL);
+ g_object_set (data->sigcont_action, "polkit-action", pk_action, NULL);
+ g_object_set (data->sigterm_action, "polkit-action", pk_action, NULL);
+ g_object_set (data->sigkill_action, "polkit-action", pk_action, NULL);
+ }
+#endif
} }
static void static void
diff -up gnome-system-monitor-2.26.1/src/Makefile.am.polkit gnome-system-monitor-2.26.1/src/Makefile.am diff -up gnome-system-monitor-2.28.2/src/Makefile.am.polkit gnome-system-monitor-2.28.2/src/Makefile.am
--- gnome-system-monitor-2.26.1/src/Makefile.am.polkit 2008-08-08 15:55:59.000000000 -0400 --- gnome-system-monitor-2.28.2/src/Makefile.am.polkit 2010-02-09 08:23:26.000000000 -0500
+++ gnome-system-monitor-2.26.1/src/Makefile.am 2009-04-23 15:01:02.784504169 -0400 +++ gnome-system-monitor-2.28.2/src/Makefile.am 2010-09-30 13:00:35.613603002 -0400
@@ -4,7 +4,9 @@ INCLUDES = \ @@ -4,7 +4,9 @@ INCLUDES = \
-DPROCMAN_DATADIR=\""$(datadir)/procman/"\" \ -DPROCMAN_DATADIR=\""$(datadir)/procman/"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\""$(datadir)"\" \ -DDATADIR=\""$(datadir)"\" \
- @PROCMAN_CFLAGS@ - @PROCMAN_CFLAGS@
+ @PROCMAN_CFLAGS@ \ + @PROCMAN_CFLAGS@ \
+ @POLKIT_DBUS_CFLAGS@ \ + @POLKIT_CFLAGS@ \
+ @POLKIT_GNOME_CFLAGS@ + @POLKIT_CFLAGS@
bin_PROGRAMS = gnome-system-monitor bin_PROGRAMS = gnome-system-monitor
@ -931,7 +824,7 @@ diff -up gnome-system-monitor-2.26.1/src/Makefile.am.polkit gnome-system-monitor
+endif +endif
-gnome_system_monitor_LDADD = @PROCMAN_LIBS@ libbacon.la -gnome_system_monitor_LDADD = @PROCMAN_LIBS@ libbacon.la
+gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @POLKIT_GNOME_LIBS@ libbacon.la +gnome_system_monitor_LDADD = @PROCMAN_LIBS@ @POLKIT_LIBS@ libbacon.la
noinst_LTLIBRARIES = libbacon.la noinst_LTLIBRARIES = libbacon.la
@ -942,7 +835,7 @@ diff -up gnome-system-monitor-2.26.1/src/Makefile.am.polkit gnome-system-monitor
+###################################################################### +######################################################################
+if HAVE_POLKIT +if HAVE_POLKIT
+ +
+polkit_policydir = $(datadir)/PolicyKit/policy +polkit_policydir = $(datadir)/polkit-1/actions
+dist_polkit_policy_DATA = org.gnome.system-monitor.policy +dist_polkit_policy_DATA = org.gnome.system-monitor.policy
+# You will need a recent intltool or the patch from this bug http://bugzilla.gnome.org/show_bug.cgi?id=462312 +# You will need a recent intltool or the patch from this bug http://bugzilla.gnome.org/show_bug.cgi?id=462312
+@INTLTOOL_POLICY_RULE@ +@INTLTOOL_POLICY_RULE@
@ -967,8 +860,8 @@ diff -up gnome-system-monitor-2.26.1/src/Makefile.am.polkit gnome-system-monitor
+ gnome-system-monitor-mechanism-glue.h \ + gnome-system-monitor-mechanism-glue.h \
+ gnome-system-monitor-mechanism.c + gnome-system-monitor-mechanism.c
+ +
+gnome_system_monitor_mechanism_CFLAGS = $(POLKIT_DBUS_CFLAGS) +gnome_system_monitor_mechanism_CFLAGS = $(POLKIT_CFLAGS)
+gnome_system_monitor_mechanism_LDADD = $(POLKIT_DBUS_LIBS) +gnome_system_monitor_mechanism_LDADD = $(POLKIT_LIBS)
+endif +endif
+###################################################################### +######################################################################
+ +
@ -981,10 +874,10 @@ diff -up gnome-system-monitor-2.26.1/src/Makefile.am.polkit gnome-system-monitor
CLEANFILES = \ CLEANFILES = \
$(schema_DATA) $(schema_DATA)
diff -up /dev/null gnome-system-monitor-2.26.1/src/org.gnome.SystemMonitor.Mechanism.conf diff -up gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.conf.polkit gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.conf
--- /dev/null 2009-04-23 10:50:49.279044520 -0400 --- gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.conf.polkit 2010-09-30 13:00:35.593603002 -0400
+++ gnome-system-monitor-2.26.1/src/org.gnome.SystemMonitor.Mechanism.conf 2009-04-23 15:01:02.786494180 -0400 +++ gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.conf 2010-09-30 13:00:35.614603002 -0400
@@ -0,0 +1,11 @@ @@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- --> +<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
+ +
+<!DOCTYPE busconfig PUBLIC +<!DOCTYPE busconfig PUBLIC
@ -995,18 +888,22 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/org.gnome.SystemMonitor.Mecha
+ <policy user="root"> + <policy user="root">
+ <allow own="org.gnome.SystemMonitor.Mechanism"/> + <allow own="org.gnome.SystemMonitor.Mechanism"/>
+ </policy> + </policy>
+
+ <policy context="default">
+ <allow send_destination="org.gnome.SystemMonitor.Mechanism"/>
+ </policy>
+</busconfig> +</busconfig>
diff -up /dev/null gnome-system-monitor-2.26.1/src/org.gnome.SystemMonitor.Mechanism.service.in diff -up gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.service.in.polkit gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.service.in
--- /dev/null 2009-04-23 10:50:49.279044520 -0400 --- gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.service.in.polkit 2010-09-30 13:00:35.594603002 -0400
+++ gnome-system-monitor-2.26.1/src/org.gnome.SystemMonitor.Mechanism.service.in 2009-04-23 15:01:02.786494180 -0400 +++ gnome-system-monitor-2.28.2/src/org.gnome.SystemMonitor.Mechanism.service.in 2010-09-30 13:00:35.594603002 -0400
@@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
+[D-BUS Service] +[D-BUS Service]
+Name=org.gnome.SystemMonitor.Mechanism +Name=org.gnome.SystemMonitor.Mechanism
+Exec=libexecdir/gnome-system-monitor-mechanism +Exec=libexecdir/gnome-system-monitor-mechanism
+User=root +User=root
diff -up /dev/null gnome-system-monitor-2.26.1/src/org.gnome.system-monitor.policy.in diff -up gnome-system-monitor-2.28.2/src/org.gnome.system-monitor.policy.in.polkit gnome-system-monitor-2.28.2/src/org.gnome.system-monitor.policy.in
--- /dev/null 2009-04-23 10:50:49.279044520 -0400 --- gnome-system-monitor-2.28.2/src/org.gnome.system-monitor.policy.in.polkit 2010-09-30 13:00:35.595603002 -0400
+++ gnome-system-monitor-2.26.1/src/org.gnome.system-monitor.policy.in 2009-04-23 15:01:02.787520999 -0400 +++ gnome-system-monitor-2.28.2/src/org.gnome.system-monitor.policy.in 2010-09-30 13:00:35.615603002 -0400
@@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?>
+ +
@ -1044,7 +941,7 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/org.gnome.system-monitor.poli
+ <_message>Increasing the priority of one of your own processes requires privileges</_message> + <_message>Increasing the priority of one of your own processes requires privileges</_message>
+ <defaults> + <defaults>
+ <allow_inactive>no</allow_inactive> + <allow_inactive>no</allow_inactive>
+ <allow_active>auth_self_keep_always</allow_active> + <allow_active>auth_self_keep</allow_active>
+ </defaults> + </defaults>
+ </action> + </action>
+ +
@ -1058,16 +955,16 @@ diff -up /dev/null gnome-system-monitor-2.26.1/src/org.gnome.system-monitor.poli
+ </action> + </action>
+ +
+</policyconfig> +</policyconfig>
diff -up gnome-system-monitor-2.26.1/src/procactions.cpp.polkit gnome-system-monitor-2.26.1/src/procactions.cpp diff -up gnome-system-monitor-2.28.2/src/procactions.cpp.polkit gnome-system-monitor-2.28.2/src/procactions.cpp
--- gnome-system-monitor-2.26.1/src/procactions.cpp.polkit 2007-01-02 17:15:36.000000000 -0500 --- gnome-system-monitor-2.28.2/src/procactions.cpp.polkit 2010-02-09 08:23:26.000000000 -0500
+++ gnome-system-monitor-2.26.1/src/procactions.cpp 2009-04-23 15:01:02.788493760 -0400 +++ gnome-system-monitor-2.28.2/src/procactions.cpp 2010-09-30 13:00:35.616603002 -0400
@@ -31,6 +31,10 @@ @@ -31,6 +31,10 @@
#include "procdialogs.h" #include "procdialogs.h"
#include "callbacks.h" #include "callbacks.h"
+#ifdef HAVE_POLKIT +#ifdef HAVE_POLKIT
+# include "gnome-system-monitor-mechanism-client-glue.h" +# include "gnome-system-monitor-mechanism-client-glue.h"
+# include <polkit-gnome/polkit-gnome.h> +# include <polkit/polkit.h>
+#endif +#endif
static void static void
@ -1173,77 +1070,17 @@ diff -up gnome-system-monitor-2.26.1/src/procactions.cpp.polkit gnome-system-mon
proctable_update_all (procdata); proctable_update_all (procdata);
} }
+ +
diff -up gnome-system-monitor-2.26.1/src/procdialogs.cpp.polkit gnome-system-monitor-2.26.1/src/procdialogs.cpp diff -up gnome-system-monitor-2.28.2/src/procdialogs.cpp.polkit gnome-system-monitor-2.28.2/src/procdialogs.cpp
--- gnome-system-monitor-2.26.1/src/procdialogs.cpp.polkit 2008-05-23 17:44:00.000000000 -0400 --- gnome-system-monitor-2.28.2/src/procdialogs.cpp.polkit 2010-09-27 19:13:17.000000000 -0400
+++ gnome-system-monitor-2.26.1/src/procdialogs.cpp 2009-04-23 15:01:02.789493899 -0400 +++ gnome-system-monitor-2.28.2/src/procdialogs.cpp 2010-09-30 13:01:39.444603008 -0400
@@ -35,6 +35,11 @@ @@ -123,29 +123,34 @@ get_nice_level (gint nice)
#include "procman_gnomesu.h"
#include "procman_gksu.h"
+#ifdef HAVE_POLKIT
+# include "gnome-system-monitor-mechanism-client-glue.h"
+# include <polkit-gnome/polkit-gnome.h>
+#endif
+
static GtkWidget *renice_dialog = NULL;
static GtkWidget *prefs_dialog = NULL;
static gint new_nice_value = 0;
@@ -121,29 +126,89 @@ get_nice_level (gint nice)
return _("(Very Low Priority)"); return _("(Very Low Priority)");
} }
+typedef struct { +typedef struct {
+ GtkWidget *priority_label; + GtkWidget *priority_label;
+ ProcData *procdata; + ProcData *procdata;
+#ifdef HAVE_POLKIT
+ PolKitGnomeAction *renice_action;
+#endif
+} ReniceClosure; +} ReniceClosure;
+
+#ifdef HAVE_POLKIT
+static void
+_renice_compute_polkit_action (ReniceClosure *rc)
+{
+ if (rc->procdata->selected_process != NULL) {
+ ProcInfo *pi = rc->procdata->selected_process;
+
+ if (pi->uid == getuid ()) {
+ if (new_nice_value < pi->nice) {
+ GValue v;
+ GValueArray *va;
+
+ g_warning ("foo");
+
+ memset (&v, 0, sizeof (GValue));
+ g_value_init (&v, G_TYPE_POINTER);
+ g_value_set_pointer (&v, rc->procdata->pk_action_change_priority);
+ va = g_value_array_new (1);
+ g_value_array_prepend (va, &v);
+
+ g_object_set (rc->renice_action,
+ "polkit-action",
+ rc->procdata->pk_action_increase_own_priority,
+ "polkit-action-sufficient",
+ va,
+ NULL);
+
+ g_value_array_free (va);
+ goto out;
+ }
+ } else {
+ g_object_set (rc->renice_action,
+ "polkit-action",
+ rc->procdata->pk_action_change_priority, NULL);
+ goto out;
+ }
+ }
+
+ g_object_set (rc->renice_action, "polkit-action", NULL, NULL);
+
+out:
+ ;
+}
+#endif
+ +
static void static void
renice_scale_changed (GtkAdjustment *adj, gpointer data) renice_scale_changed (GtkAdjustment *adj, gpointer data)
@ -1252,13 +1089,10 @@ diff -up gnome-system-monitor-2.26.1/src/procdialogs.cpp.polkit gnome-system-mon
- -
+ ReniceClosure *rc = (ReniceClosure *) data; + ReniceClosure *rc = (ReniceClosure *) data;
+ +
new_nice_value = int(adj->value); new_nice_value = int(gtk_adjustment_get_value (adj));
- gtk_label_set_text (GTK_LABEL (label), get_nice_level (new_nice_value)); - gtk_label_set_text (GTK_LABEL (label), get_nice_level (new_nice_value));
- -
+ gtk_label_set_text (GTK_LABEL (rc->priority_label), get_nice_level (new_nice_value)); +‣‧‧‧‧‧‧gtk_label_set_text (GTK_LABEL (rc->priority_label), get_nice_level (new_nice_value));‣‧‧‣‧‧‧‧‧‧‧
+#ifdef HAVE_POLKIT
+ _renice_compute_polkit_action (rc);
+#endif
} }
static void static void
@ -1272,20 +1106,16 @@ diff -up gnome-system-monitor-2.26.1/src/procdialogs.cpp.polkit gnome-system-mon
if (new_nice_value == -100) if (new_nice_value == -100)
return; return;
- renice(procdata, new_nice_value); - renice(procdata, new_nice_value);
+ renice (rc->procdata, new_nice_value); + renice(rc->procdata, new_nice_value);
} }
gtk_widget_destroy (GTK_WIDGET (dialog)); gtk_widget_destroy (GTK_WIDGET (dialog));
renice_dialog = NULL; renice_dialog = NULL;
+
+#ifdef HAVE_POLKIT
+ g_object_unref (G_OBJECT (rc->renice_action));
+#endif
+ g_free (rc); + g_free (rc);
} }
void void
@@ -153,22 +218,28 @@ procdialog_create_renice_dialog (ProcDat @@ -155,7 +160,6 @@ procdialog_create_renice_dialog (ProcDat
GtkWidget *dialog = NULL; GtkWidget *dialog = NULL;
GtkWidget *dialog_vbox; GtkWidget *dialog_vbox;
GtkWidget *vbox; GtkWidget *vbox;
@ -1293,14 +1123,12 @@ diff -up gnome-system-monitor-2.26.1/src/procdialogs.cpp.polkit gnome-system-mon
GtkWidget *label; GtkWidget *label;
GtkWidget *priority_label; GtkWidget *priority_label;
GtkWidget *table; GtkWidget *table;
GtkObject *renice_adj; @@ -163,14 +167,19 @@ procdialog_create_renice_dialog (ProcDat
GtkWidget *hscale; GtkWidget *hscale;
GtkWidget *button; GtkWidget *button;
+#ifndef HAVE_POLKIT
+ GtkWidget *hbox;
GtkWidget *align; GtkWidget *align;
+ GtkWidget *hbox;
GtkWidget *icon; GtkWidget *icon;
+#endif
gchar *text; gchar *text;
+ ReniceClosure *rc; + ReniceClosure *rc;
@ -1315,46 +1143,30 @@ diff -up gnome-system-monitor-2.26.1/src/procdialogs.cpp.polkit gnome-system-mon
dialog = gtk_dialog_new_with_buttons (_("Change Priority"), NULL, dialog = gtk_dialog_new_with_buttons (_("Change Priority"), NULL,
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -178,7 +249,20 @@ procdialog_create_renice_dialog (ProcDat @@ -180,7 +189,7 @@ procdialog_create_renice_dialog (ProcDat
gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE); gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
gtk_dialog_set_has_separator (GTK_DIALOG (renice_dialog), FALSE); gtk_dialog_set_has_separator (GTK_DIALOG (renice_dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5); gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
- -
+ +
+#ifdef HAVE_POLKIT
+ rc->renice_action = polkit_gnome_action_new_default ("ReniceProcessButton",
+ NULL,
+ _("Change _Priority"),
+ NULL);
+ g_object_set (rc->renice_action,
+ "auth-label", _("Change _Priority..."),
+ "yes-icon-name", GTK_STOCK_OK,
+ NULL);
+
+ button = polkit_gnome_action_create_button (rc->renice_action);
+ GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+#else
button = gtk_button_new (); button = gtk_button_new ();
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_widget_set_can_default (button, TRUE);
@@ -195,7 +279,9 @@ procdialog_create_renice_dialog (ProcDat @@ -198,6 +207,7 @@ procdialog_create_renice_dialog (ProcDat
gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+#endif
gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100); gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+ +
gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100); gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
new_nice_value = -100; new_nice_value = -100;
@@ -236,15 +322,17 @@ procdialog_create_renice_dialog (ProcDat @@ -238,15 +248,16 @@ procdialog_create_renice_dialog (ProcDat
gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
g_free (text); g_free (text);
+ +
+ rc->priority_label = priority_label; + rc->priority_label = priority_label;
+ new_nice_value = info->nice; + new_nice_value = info->nice;
+ _renice_compute_polkit_action (rc);
g_signal_connect (G_OBJECT (dialog), "response", g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (renice_dialog_button_pressed), procdata); - G_CALLBACK (renice_dialog_button_pressed), procdata);
@ -1369,9 +1181,9 @@ diff -up gnome-system-monitor-2.26.1/src/procdialogs.cpp.polkit gnome-system-mon
} }
static void static void
diff -up gnome-system-monitor-2.26.1/src/procman.cpp.polkit gnome-system-monitor-2.26.1/src/procman.cpp diff -up gnome-system-monitor-2.28.2/src/procman.cpp.polkit gnome-system-monitor-2.28.2/src/procman.cpp
--- gnome-system-monitor-2.26.1/src/procman.cpp.polkit 2009-03-31 17:57:18.000000000 -0400 --- gnome-system-monitor-2.28.2/src/procman.cpp.polkit 2010-09-27 19:13:17.000000000 -0400
+++ gnome-system-monitor-2.26.1/src/procman.cpp 2009-04-23 15:01:02.790494038 -0400 +++ gnome-system-monitor-2.28.2/src/procman.cpp 2010-09-30 13:00:35.620603002 -0400
@@ -36,6 +36,10 @@ @@ -36,6 +36,10 @@
#include <glibtop/close.h> #include <glibtop/close.h>
#include <glibtop/loadavg.h> #include <glibtop/loadavg.h>
@ -1383,7 +1195,7 @@ diff -up gnome-system-monitor-2.26.1/src/procman.cpp.polkit gnome-system-monitor
#include "load-graph.h" #include "load-graph.h"
#include "procman.h" #include "procman.h"
#include "interface.h" #include "interface.h"
@@ -58,7 +62,34 @@ ProcData::ProcData() @@ -58,7 +62,25 @@ ProcData::ProcData()
disk_timeout(0), disk_timeout(0),
cpu_total_time(1), cpu_total_time(1),
cpu_total_time_last(1) cpu_total_time_last(1)
@ -1405,56 +1217,42 @@ diff -up gnome-system-monitor-2.26.1/src/procman.cpp.polkit gnome-system-monitor
+ "/", + "/",
+ "org.gnome.SystemMonitor.Mechanism"); + "org.gnome.SystemMonitor.Mechanism");
+ } + }
+
+ this->pk_action_kill = polkit_action_new ();
+ polkit_action_set_action_id (this->pk_action_kill, "org.gnome.system-monitor.kill");
+
+ this->pk_action_change_priority = polkit_action_new ();
+ polkit_action_set_action_id (this->pk_action_change_priority, "org.gnome.system-monitor.change-priority");
+
+ this->pk_action_increase_own_priority = polkit_action_new ();
+ polkit_action_set_action_id (this->pk_action_increase_own_priority, "org.gnome.system-monitor.increase-own-priority");
+#endif +#endif
+} +}
ProcData* ProcData::get_instance() ProcData* ProcData::get_instance()
diff -up gnome-system-monitor-2.26.1/src/procman.h.polkit gnome-system-monitor-2.26.1/src/procman.h diff -up gnome-system-monitor-2.28.2/src/procman.h.polkit gnome-system-monitor-2.28.2/src/procman.h
--- gnome-system-monitor-2.26.1/src/procman.h.polkit 2009-01-20 15:53:35.000000000 -0500 --- gnome-system-monitor-2.28.2/src/procman.h.polkit 2010-02-09 08:23:26.000000000 -0500
+++ gnome-system-monitor-2.26.1/src/procman.h 2009-04-23 15:01:02.791493688 -0400 +++ gnome-system-monitor-2.28.2/src/procman.h 2010-09-30 13:00:35.622603002 -0400
@@ -33,6 +33,11 @@ @@ -33,6 +33,10 @@
#include <map> #include <map>
#include <string> #include <string>
+#ifdef HAVE_POLKIT +#ifdef HAVE_POLKIT
+# include <dbus/dbus-glib.h> +# include <dbus/dbus-glib.h>
+# include <polkit-gnome/polkit-gnome.h>
+#endif +#endif
+ +
struct ProcInfo; struct ProcInfo;
struct ProcData; struct ProcData;
struct LoadGraph; struct LoadGraph;
@@ -211,6 +216,19 @@ struct ProcData @@ -210,6 +214,15 @@ struct ProcData
GtkWidget *app; GtkWidget *app;
GtkUIManager *menu; GtkUIManager *menu;
+#ifdef HAVE_POLKIT +#ifdef HAVE_POLKIT
+ DBusGProxy *mechanism_proxy; + DBusGProxy *mechanism_proxy;
+ +
+ PolKitAction *pk_action_kill; + GtkAction *sigstop_action;
+ PolKitAction *pk_action_change_priority; + GtkAction *sigcont_action;
+ PolKitAction *pk_action_increase_own_priority; + GtkAction *sigterm_action;
+ + GtkAction *sigkill_action;
+ PolKitGnomeAction *sigstop_action;
+ PolKitGnomeAction *sigcont_action;
+ PolKitGnomeAction *sigterm_action;
+ PolKitGnomeAction *sigkill_action;
+#endif +#endif
+ +
unsigned frequency; unsigned frequency;
SmoothRefresh *smooth_refresh; SmoothRefresh *smooth_refresh;
@@ -231,7 +249,6 @@ gboolean procman_get_tree_state (GConfCl @@ -230,7 +243,6 @@ gboolean procman_get_tree_state (GConfCl

View File

@ -41,19 +41,13 @@ BuildRequires: polkit-devel >= %{polkit_version}
BuildRequires: autoconf, automake, libtool BuildRequires: autoconf, automake, libtool
# sent upstream: http://bugzilla.gnome.org/show_bug.cgi?id=491462 # sent upstream: http://bugzilla.gnome.org/show_bug.cgi?id=491462
Patch0: gnome-system-monitor-2.25.91-polkit.patch Patch0: polkit.patch
# sent upstream: http://bugzilla.gnome.org/show_bug.cgi?id=421912 # sent upstream: http://bugzilla.gnome.org/show_bug.cgi?id=421912
Patch1: session.patch Patch1: session.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=495730
Patch2: polkit1.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=592747
Patch3: buttons.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=592758 # http://bugzilla.gnome.org/show_bug.cgi?id=592758
Patch4: memmapsdialog.patch Patch2: memmapsdialog.patch
Requires(pre): GConf2 >= %{gconf_version} Requires(pre): GConf2 >= %{gconf_version}
Requires(post): GConf2 >= %{gconf_version} Requires(post): GConf2 >= %{gconf_version}
@ -68,9 +62,7 @@ such as CPU and memory.
%setup -q %setup -q
%patch0 -p1 -b .polkit %patch0 -p1 -b .polkit
%patch1 -p1 -b .session %patch1 -p1 -b .session
%patch2 -p1 -b .polkit1 %patch2 -p1 -b .memmapsdialog
%patch3 -p1 -b .buttons
%patch4 -p1 -b .memmapsdialog
autoreconf -i -f autoreconf -i -f

1273
polkit.patch Normal file

File diff suppressed because it is too large Load Diff