Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #85 try pkexec before trying gksu for killing other users' processes or renicing a process. actual kill and renice commands are launched via helper tool (see discussion at https://bugzilla.gnome.org/491462). code is ported from gnome-system-monitor with some changes (e.g. helper tool code is in tools/ dir instead of scripts/ - it's not a script). for reference - relevant upstream commits: https://git.gnome.org/browse/gnome-system-monitor/commit/?id=ccbff2a4293e43d6ea24fbf13477b10f58cd5212 https://git.gnome.org/browse/gnome-system-monitor/commit/?id=2b4308d9fc2b2e367030629e79b531c4f9ae3d0a https://git.gnome.org/browse/gnome-system-monitor/commit/?id=971b3c704dea49b22c1038f200933c5b3b35ece1 https://git.gnome.org/browse/gnome-system-monitor/commit/?id=c234b2a75dac454b818f1f40d302cf12f1a33aa2 https://git.gnome.org/browse/gnome-system-monitor/commit/?id=4cda3529e418098b35f7444d79ba421eb5403afc https://git.gnome.org/browse/gnome-system-monitor/commit/?id=ab7bd8aef7300eeb3835fdef9a2a1eefe7281631 https://git.gnome.org/browse/gnome-system-monitor/commit/?id=79eccf0cecbca237f4f911681438c33932da63e2 https://git.gnome.org/browse/gnome-system-monitor/commit/?id=a3bf3a7f56cf02c6a127aa168c570230e9fad356
- Loading branch information
Showing
11 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?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>MATE Desktop</vendor> | ||
<vendor_url>http://www.mate-desktop.org/</vendor_url> | ||
<icon_name>utilities-system-monitor</icon_name> | ||
|
||
<action id="org.mate.mate-system-monitor.kill"> | ||
<_description>Kill process</_description> | ||
<_message>Privileges are required to control other users' processes</_message> | ||
<defaults> | ||
<allow_any>no</allow_any> | ||
<allow_inactive>no</allow_inactive> | ||
<allow_active>auth_admin_keep</allow_active> | ||
</defaults> | ||
<annotate key="org.freedesktop.policykit.exec.path">@pkglibexecdir@/msm-kill</annotate> | ||
</action> | ||
|
||
<action id="org.mate.mate-system-monitor.renice"> | ||
<_description>Renice process</_description> | ||
<_message>Privileges are required to change the priority of processes</_message> | ||
<defaults> | ||
<allow_any>no</allow_any> | ||
<allow_inactive>no</allow_inactive> | ||
<allow_active>auth_admin_keep</allow_active> | ||
</defaults> | ||
<annotate key="org.freedesktop.policykit.exec.path">@pkglibexecdir@/msm-renice</annotate> | ||
</action> | ||
|
||
</policyconfig> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mate-system-monitor.desktop.in | ||
org.mate.mate-system-monitor.policy.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <config.h> | ||
|
||
#include "procman_pkexec.h" | ||
|
||
gboolean | ||
procman_pkexec_create_root_password_dialog (const char *command) | ||
{ | ||
gchar *command_line; | ||
gboolean success; | ||
GError *error = NULL; | ||
|
||
command_line = g_strdup_printf ("pkexec --disable-internal-agent %s/msm-%s", | ||
LIBEXEC_DIR, command); | ||
success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error); | ||
g_free (command_line); | ||
|
||
if (!success) { | ||
g_critical ("Could not run pkexec (\"%s\") : %s\n", | ||
command, error->message); | ||
g_error_free (error); | ||
return FALSE; | ||
} | ||
|
||
g_debug ("pkexec did fine\n"); | ||
return TRUE; | ||
} | ||
|
||
gboolean | ||
procman_has_pkexec (void) | ||
{ | ||
return g_file_test("/usr/bin/pkexec", G_FILE_TEST_EXISTS); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _PROCMAN_PKEXEC_H_ | ||
#define _PROCMAN_PKEXEC_H_ | ||
|
||
#include <glib.h> | ||
|
||
gboolean | ||
procman_pkexec_create_root_password_dialog(const char *command); | ||
|
||
gboolean | ||
procman_has_pkexec(void) G_GNUC_CONST; | ||
|
||
#endif /* _PROCMAN_PKEXEC_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pkglibexec_PROGRAMS = msm-renice msm-kill | ||
|
||
AM_CPPFLAGS = $(TOOLS_CFLAGS) | ||
|
||
msm_renice_SOURCES = msm_execute_helper.c | ||
msm_renice_LDADD = $(TOOLS_LIBS) | ||
msm_renice_CFLAGS = -DCOMMAND=\"renice\" | ||
|
||
msm_kill_SOURCES = msm_execute_helper.c | ||
msm_kill_LDADD = $(TOOLS_LIBS) | ||
msm_kill_CFLAGS = -DCOMMAND=\"kill\" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <unistd.h> | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <glib.h> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
gchar **argv_modified = g_new0 (gchar *, argc + 1); | ||
memcpy (argv_modified, argv, argc * sizeof (char*)); | ||
argv_modified[0] = COMMAND; | ||
|
||
if (execvp (COMMAND, argv_modified) == -1) { | ||
return errno; | ||
} | ||
|
||
return 0; | ||
} |