[gnome-system-monitor] Also try pkexec as a fallback if neither gksu nor gnomesu works https://bugzilla.gnome.org/show_bu
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Also try pkexec as a fallback if neither gksu nor gnomesu works https://bugzilla.gnome.org/show_bu
- Date: Mon, 1 Oct 2012 00:09:59 +0000 (UTC)
commit ccbff2a4293e43d6ea24fbf13477b10f58cd5212
Author: Robert Roth <robert roth off gmail com>
Date: Mon Oct 1 03:08:50 2012 +0300
Also try pkexec as a fallback if neither gksu nor gnomesu
works https://bugzilla.gnome.org/show_bug.cgi?id=491462
https://bugzilla.gnome.org/show_bug.cgi?id=681585
.gitignore | 1 +
Makefile.am | 9 +++++++-
org.gnome.gnome-system-monitor.policy.in | 34 ++++++++++++++++++++++++++++++
src/Makefile.am | 1 +
src/procdialogs.cpp | 3 ++
src/procman_pkexec.cpp | 29 +++++++++++++++++++++++++
src/procman_pkexec.h | 12 ++++++++++
7 files changed, 88 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 9429944..4e61ba6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ ltmain.sh
m4/
missing
omf.make
+org.gnome.gnome-system-monitor.policy
pixmaps/Makefile
pixmaps/Makefile.in
po/.intltool-merge-cache
diff --git a/Makefile.am b/Makefile.am
index 375aee0..999341f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,12 +13,18 @@ ui_DATA = data/preferences.ui \
EXTRA_DIST = \
$(ui_DATA) \
+ org.gnome.gnome-system-monitor.policy.in \
gnome-system-monitor.desktop.in \
gnome-system-monitor.doap \
intltool-extract.in \
intltool-merge.in \
intltool-update.in
+ INTLTOOL_POLICY_RULE@
+polkit_policydir = $(datadir)/polkit-1/actions
+polkit_policy_in_files = org.gnome.gnome-system-monitor.policy.in
+polkit_policy_DATA = $(polkit_policy_in_files:.policy.in=.policy)
+
Applicationsdir = $(datadir)/applications
Applications_in_files = gnome-system-monitor.desktop.in
Applications_DATA = $(Applications_in_files:.desktop.in=.desktop)
@@ -51,6 +57,7 @@ DISTCLEANFILES = \
intltool-extract \
intltool-merge \
intltool-update \
- gnome-system-monitor.desktop
+ gnome-system-monitor.desktop \
+ org.gnome.gnome-system-monitor.policy
DISTCHECK_CONFIGURE_FLAGS = --disable-scrollkeeper
diff --git a/org.gnome.gnome-system-monitor.policy.in b/org.gnome.gnome-system-monitor.policy.in
new file mode 100644
index 0000000..35db3cc
--- /dev/null
+++ b/org.gnome.gnome-system-monitor.policy.in
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+ "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
+<policyconfig>
+ <vendor>The GNOME Project</vendor>
+ <vendor_url>http://www.gnome.org/</vendor_url>
+ <icon_name>utilities-system-monitor</icon_name>
+
+ <action id="org.gnome.gnome-system-monitor.kill">
+ <_description>Kill process</_description>
+ <_message>Privileges are required to kill process</_message>
+ <defaults>
+ <allow_any>no</allow_any>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin</allow_active>
+ </defaults>
+ <annotate key="org.freedesktop.policykit.exec.path">/bin/kill</annotate>
+ <annotate key="org.freedesktop.policykit.exec.allow_gui">FALSE</annotate>
+ </action>
+
+ <action id="org.gnome.gnome-system-monitor.renice">
+ <_description>Renice process</_description>
+ <_message>Privileges are required to renice process</_message>
+ <defaults>
+ <allow_any>no</allow_any>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin</allow_active>
+ </defaults>
+ <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/renice</annotate>
+ <annotate key="org.freedesktop.policykit.exec.allow_gui">FALSE</annotate>
+ </action>
+
+</policyconfig>
diff --git a/src/Makefile.am b/src/Makefile.am
index 94183da..277ecbd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,6 +29,7 @@ gnome_system_monitor_cpp_files = \
cgroups.cpp \
procman_gnomesu.cpp \
procman_gksu.cpp \
+ procman_pkexec.cpp \
sysinfo.cpp \
lsof.cpp \
selection.cpp \
diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp
index 61927dc..7e9b1b7 100644
--- a/src/procdialogs.cpp
+++ b/src/procdialogs.cpp
@@ -40,6 +40,7 @@
#include "settings-keys.h"
#include "procman_gnomesu.h"
#include "procman_gksu.h"
+#include "procman_pkexec.h"
#include "cgroups.h"
static GtkWidget *renice_dialog = NULL;
@@ -603,6 +604,8 @@ procdialog_create_root_password_dialog(ProcmanActionType type,
ret = procman_gksu_create_root_password_dialog(command);
else if (procman_has_gnomesu())
ret = procman_gnomesu_create_root_password_dialog(command);
+ else if (procman_has_pkexec())
+ ret = procman_pkexec_create_root_password_dialog(command);
g_free(command);
return ret;
diff --git a/src/procman_pkexec.cpp b/src/procman_pkexec.cpp
new file mode 100644
index 0000000..70c3090
--- /dev/null
+++ b/src/procman_pkexec.cpp
@@ -0,0 +1,29 @@
+#include <config.h>
+
+#include "procman.h"
+#include "procman_pkexec.h"
+#include "util.h"
+
+gboolean procman_pkexec_create_root_password_dialog(const char *command)
+{
+ gint *exit_status = NULL;
+ GError *error = NULL;
+ if (!g_spawn_command_line_sync( g_strdup_printf("pkexec %s", command), NULL, NULL, exit_status, &error)) {
+ g_critical("Could not run pkexec(\"%s\") : %s\n",
+ command, error->message);
+ g_error_free(error);
+ return FALSE;
+ }
+
+ g_message("pkexec did fine\n");
+ return TRUE;
+}
+
+
+
+gboolean
+procman_has_pkexec(void)
+{
+ return g_file_test("/usr/bin/pkexec", G_FILE_TEST_EXISTS);
+}
+
diff --git a/src/procman_pkexec.h b/src/procman_pkexec.h
new file mode 100644
index 0000000..8cd7135
--- /dev/null
+++ b/src/procman_pkexec.h
@@ -0,0 +1,12 @@
+#ifndef H_GNOME_SYSTEM_MONITOR_PKEXEC_H_
+#define H_GNOME_SYSTEM_MONITOR_PKEXEC_H_
+
+#include <glib.h>
+
+gboolean
+procman_pkexec_create_root_password_dialog(const char *command);
+
+gboolean
+procman_has_pkexec(void) G_GNUC_CONST;
+
+#endif /* H_GNOME_SYSTEM_MONITOR_PKEXEC_H_ */
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]