From 0dffb9470991e497025a50347f1719461e6398f3 Mon Sep 17 00:00:00 2001 From: Kevin Hao Date: Sat, 8 Feb 2020 20:36:42 +0800 Subject: xserver-nodm-init: Fix the start failure for non-root user In order to start the xserver, a non-root user should have the cap_sys_admin capability to set the drm master. We try to get the cap_sys_admin capability by setting it in both the thread and file inheritable set. The side effect of this is that we would have to add the "pam" to the distro features if we want use the xserver-nodm-init for a non-root user. [Yocto #11526] (From OE-Core rev: fec05cd1eaaad41fd72a29d7792f1c37d2a82f3e) Signed-off-by: Kevin Hao Signed-off-by: Richard Purdie (cherry picked from commit cfd71a68a4931c8bda15357ebb1e9ebcf0e302dc) Signed-off-by: Armin Kuster Signed-off-by: Richard Purdie --- .../recipes-graphics/x11-common/xserver-nodm-init/capability.conf | 2 ++ meta/recipes-graphics/x11-common/xserver-nodm-init/xserver-nodm | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 meta/recipes-graphics/x11-common/xserver-nodm-init/capability.conf (limited to 'meta/recipes-graphics/x11-common/xserver-nodm-init') diff --git a/meta/recipes-graphics/x11-common/xserver-nodm-init/capability.conf b/meta/recipes-graphics/x11-common/xserver-nodm-init/capability.conf new file mode 100644 index 0000000000..7ab7460816 --- /dev/null +++ b/meta/recipes-graphics/x11-common/xserver-nodm-init/capability.conf @@ -0,0 +1,2 @@ +cap_sys_admin @USER@ +none * diff --git a/meta/recipes-graphics/x11-common/xserver-nodm-init/xserver-nodm b/meta/recipes-graphics/x11-common/xserver-nodm-init/xserver-nodm index 6c548551b8..116bb278bc 100755 --- a/meta/recipes-graphics/x11-common/xserver-nodm-init/xserver-nodm +++ b/meta/recipes-graphics/x11-common/xserver-nodm-init/xserver-nodm @@ -38,6 +38,14 @@ case "$1" in if [ -e /dev/hidraw0 ]; then chmod o+rw /dev/hidraw* fi + # Make sure that the Xorg has the cap_sys_admin capability which is + # needed for setting the drm master + if ! grep -q "^auth.*pam_cap\.so" /etc/pam.d/su; then + echo "auth optional pam_cap.so" >>/etc/pam.d/su + fi + if ! /usr/sbin/getcap $XSERVER | grep -q cap_sys_admin; then + /usr/sbin/setcap cap_sys_admin+eip $XSERVER + fi fi # Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211] -- cgit v1.2.3-54-g00ecf