diff mbox series

[v2,22/23] kernel-shark-qt: Workaround for running as Root on Wayland

Message ID 20181016155232.5257-23-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Add Qt-based GUI for KernelShark | expand

Commit Message

Yordan Karadzhov Oct. 16, 2018, 3:53 p.m. UTC
From: Yordan Karadzhov (VMware) <y.karadz@gmail.com>

The Record dialog requires Root privileges in order to be able to collect
tracing data. However graphical applications cannot be run as root on
Wayland. The problem is worked around by wrapping the kshark-record
executable in a shell script which checks the XDG_SESSION_TYPE and in
the case of Wayland, allows the root user to access the running
X server.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark-qt/bin/kshark-su-record | 8 ++++++++
 kernel-shark-qt/src/CMakeLists.txt   | 3 +++
 2 files changed, 11 insertions(+)
 create mode 100755 kernel-shark-qt/bin/kshark-su-record
diff mbox series

Patch

diff --git a/kernel-shark-qt/bin/kshark-su-record b/kernel-shark-qt/bin/kshark-su-record
new file mode 100755
index 0000000..ee839a2
--- /dev/null
+++ b/kernel-shark-qt/bin/kshark-su-record
@@ -0,0 +1,8 @@ 
+#!/bin/bash
+
+if [ $XDG_SESSION_TYPE = "wayland" ]
+then
+    xhost +si:localuser:root &>/dev/null
+fi
+
+pkexec kshark-record -o ${PWD}/trace.dat
diff --git a/kernel-shark-qt/src/CMakeLists.txt b/kernel-shark-qt/src/CMakeLists.txt
index 2592094..ef0aa71 100644
--- a/kernel-shark-qt/src/CMakeLists.txt
+++ b/kernel-shark-qt/src/CMakeLists.txt
@@ -83,6 +83,9 @@  if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
     install(FILES "${KS_DIR}/org.freedesktop.kshark-record.policy"
             DESTINATION /usr/share/polkit-1/actions/)
 
+    install(PROGRAMS "${KS_DIR}/bin/kshark-su-record"
+            DESTINATION /usr/local/bin/)
+
 endif (Qt5Widgets_FOUND AND Qt5Network_FOUND)
 
 add_subdirectory(plugins)