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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>

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@xxxxxxxxx>
---
 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 --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)
-- 
2.17.1





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux