Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Makefile.am
Expand Up @@ -2,7 +2,7 @@

ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}

SUBDIRS = pixmaps po src help
SUBDIRS = pixmaps po src tools help

man_MANS = mate-system-monitor.1

Expand All @@ -11,17 +11,26 @@ appdatadir = $(datadir)/appdata
appdata_in_files = mate-system-monitor.appdata.xml.in
appdata_DATA = $(appdata_in_files:.xml.in=.xml)

org.mate.mate-system-monitor.policy.in: org.mate.mate-system-monitor.policy.in.in Makefile
$(AM_V_GEN) sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@

EXTRA_DIST = \
autogen.sh \
$(man_MANS) \
$(appdata_in_files) \
org.mate.mate-system-monitor.policy.in.in \
mate-system-monitor.desktop.in \
intltool-extract.in \
intltool-merge.in \
intltool-update.in \
omf.make \
xmldocs.make

@INTLTOOL_POLICY_RULE@
polkit_policydir = $(datadir)/polkit-1/actions
polkit_policy_in_files = org.mate.mate-system-monitor.policy.in
polkit_policy_DATA = $(polkit_policy_in_files:.policy.in=.policy)

Applicationsdir = $(datadir)/applications
Applications_in_files = mate-system-monitor.desktop.in
Applications_DATA = $(Applications_in_files:.desktop.in=.desktop)
Expand All @@ -35,7 +44,9 @@ DISTCLEANFILES = \
intltool-extract \
intltool-merge \
intltool-update \
mate-system-monitor.desktop
mate-system-monitor.desktop \
org.mate.mate-system-monitor.policy \
org.mate.mate-system-monitor.policy.in

# Build ChangeLog from GIT history
ChangeLog:
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Expand Up @@ -46,6 +46,8 @@ AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_36],
PKG_CHECK_MODULES(GMODULE,gmodule-2.0,[GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""])
PKG_CHECK_MODULES(PROCMAN,$GMODULE_ADD glib-2.0 >= $GLIB_REQUIRED libgtop-2.0 >= $LIBGTOP_REQUIRED libwnck-3.0 >= $LIBWNCK_REQUIRED gtk+-3.0 >= $GTK_REQUIRED gtkmm-3.0 >= $GTKMM_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED librsvg-2.0 >= $RSVG_REQUIRED glibmm-2.4 >= $GLIBMM_REQUIRED giomm-2.4 >= $GIOMM_REQUIRED)

PKG_CHECK_MODULES(TOOLS, glib-2.0 >= $GLIB_REQUIRED)

have_systemd=no
AC_ARG_ENABLE(systemd, AS_HELP_STRING([--disable-systemd], [disable systemd support]),,enable_systemd=no)
if test "x$enable_systemd" != "xno"; then
Expand Down Expand Up @@ -107,6 +109,7 @@ src/org.mate.system-monitor.gschema.xml
pixmaps/Makefile
po/Makefile.in
help/Makefile
tools/Makefile
mate-system-monitor.desktop.in
])

Expand Down
32 changes: 32 additions & 0 deletions org.mate.mate-system-monitor.policy.in.in
@@ -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>
1 change: 1 addition & 0 deletions po/POTFILES.in
Expand Up @@ -3,6 +3,7 @@
# Please keep this file sorted alphabetically.
mate-system-monitor.appdata.xml.in
mate-system-monitor.desktop.in.in
org.mate.mate-system-monitor.policy.in.in
src/argv.cpp
src/argv.h
src/callbacks.cpp
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES.skip
@@ -1 +1,2 @@
mate-system-monitor.desktop.in
org.mate.mate-system-monitor.policy.in
2 changes: 2 additions & 0 deletions src/Makefile.am
Expand Up @@ -4,6 +4,7 @@ AM_CPPFLAGS = \
-DPROCMAN_DATADIR=\""$(datadir)/procman/"\" \
-DMATELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\""$(datadir)"\" \
-DLIBEXEC_DIR=\""$(pkglibexecdir)"\" \
@PROCMAN_CFLAGS@ \
@SYSTEMD_CFLAGS@

Expand All @@ -28,6 +29,7 @@ mate_system_monitor_cpp_files = \
selinux.cpp \
cgroups.cpp \
procman_gksu.cpp \
procman_pkexec.cpp \
sysinfo.cpp \
lsof.cpp \
selection.cpp \
Expand Down
5 changes: 4 additions & 1 deletion src/procdialogs.cpp
Expand Up @@ -34,6 +34,7 @@
#include "load-graph.h"
#include "settings-keys.h"
#include "procman_gksu.h"
#include "procman_pkexec.h"
#include "cgroups.h"


Expand Down Expand Up @@ -894,7 +895,9 @@ procdialog_create_root_password_dialog(ProcmanActionType type,

procman_debug("Trying to run '%s' as root", command);

if (procman_has_gksu())
if (procman_has_pkexec())
ret = procman_pkexec_create_root_password_dialog(command);
else if (procman_has_gksu())
ret = procman_gksu_create_root_password_dialog(command);

g_free(command);
Expand Down
33 changes: 33 additions & 0 deletions src/procman_pkexec.cpp
@@ -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);
}

12 changes: 12 additions & 0 deletions src/procman_pkexec.h
@@ -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_ */
12 changes: 12 additions & 0 deletions tools/Makefile.am
@@ -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\"

17 changes: 17 additions & 0 deletions tools/msm_execute_helper.c
@@ -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;
}

0 comments on commit ed81e79

Please sign in to comment.