summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/procdialogs.cpp5
-rw-r--r--src/procman_pkexec.cpp33
-rw-r--r--src/procman_pkexec.h12
4 files changed, 51 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 38588e9..2140770 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,6 +4,7 @@ AM_CPPFLAGS = \
-DPROCMAN_DATADIR=\""$(datadir)/procman/"\" \
-DMATELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\""$(datadir)"\" \
+ -DLIBEXEC_DIR=\""$(pkglibexecdir)"\" \
@PROCMAN_CFLAGS@ \
@SYSTEMD_CFLAGS@
@@ -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 \
diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp
index 96cf39c..0a4be65 100644
--- a/src/procdialogs.cpp
+++ b/src/procdialogs.cpp
@@ -34,6 +34,7 @@
#include "load-graph.h"
#include "settings-keys.h"
#include "procman_gksu.h"
+#include "procman_pkexec.h"
#include "cgroups.h"
@@ -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);
diff --git a/src/procman_pkexec.cpp b/src/procman_pkexec.cpp
new file mode 100644
index 0000000..f67be6a
--- /dev/null
+++ b/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);
+}
+
diff --git a/src/procman_pkexec.h b/src/procman_pkexec.h
new file mode 100644
index 0000000..d453f69
--- /dev/null
+++ b/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_ */