Skip to content
Snippets Groups Projects
Commit 43d358b7 authored by Tobias Kahlki's avatar Tobias Kahlki
Browse files

qt:compositor: Run service as qt user

It is best practice to don't run services as root. The qt-compositor
service now runs under the qt username.
The commit also contains a draft of the systemd socket-based activation
mechanism. Unfortunately, the qt-compositor daemon doesn't handle the transfer
of the socket from the socket unit to the service unit properly.
Until the daemon is fixed, the service still needs to be started manually.
parent 9c1ae36c
No related branches found
No related tags found
2 merge requests!418Integrate gitlab-ci/fix-gitlab-ci-integration and 6 more,!410qt:compositor: Fixed qt-compositor to run under Yocto Kirkstone
...@@ -3,21 +3,28 @@ Description=Qt multi-screen Compositor ...@@ -3,21 +3,28 @@ Description=Qt multi-screen Compositor
RequiresMountsFor=/run RequiresMountsFor=/run
Conflicts=plymouth-quit.service Conflicts=plymouth-quit.service
After=systemd-user-sessions.service plymouth-quit-wait.service systemd-logind.service After=systemd-user-sessions.service plymouth-quit-wait.service systemd-logind.service
# Starting via socket unit doesn't work at the moment
# See comment in qt-multi-screen-compositor.bb
#Requires=qt-multi-screen-compositor.socket
[Service] [Service]
User=qt User=qt
Group=qt Group=qt
WorkingDirectory=/home/qt WorkingDirectory=/home/qt
PAMName=qt-autologin PAMName=qt-autologin
#Environment=XDG_RUNTIME_DIR=/var/run/user/0
# TODO: Replace the UID with a more stable folder/value
Environment=XDG_RUNTIME_DIR=/run/user/1001
Environment=QT_QPA_FONTDIR=/usr/share/fonts/truetype Environment=QT_QPA_FONTDIR=/usr/share/fonts/truetype
Environment=QT_QPA_PLATFORM=linuxfb Environment=QT_QPA_PLATFORM=linuxfb
Environment=QT_QUICK_BACKEND=software Environment=QT_QUICK_BACKEND=software
# Use this if the touch entry is rotated compared to the screen # The following parameter rotates the touchscreen input
# as the normal libinput calibration is not yet implemented # by 180 degrees. As the normal libinput calibration isn't
# this is the only way of touch calibration available # implemented yet, this is the only way to enable touch
# Environment=QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=rotate=180 # calibration at the moment.
#Environment=QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=rotate=180
StandardError=journal StandardError=journal
PermissionsStartOnly=true PermissionsStartOnly=true
IgnoreSIGPIPE=no IgnoreSIGPIPE=no
......
...@@ -3,13 +3,18 @@ Description=Qt multi-screen Compositor ...@@ -3,13 +3,18 @@ Description=Qt multi-screen Compositor
RequiresMountsFor=/run RequiresMountsFor=/run
Conflicts=plymouth-quit.service Conflicts=plymouth-quit.service
After=systemd-user-sessions.service plymouth-quit-wait.service systemd-logind.service After=systemd-user-sessions.service plymouth-quit-wait.service systemd-logind.service
# Starting via socket unit doesn't work at the moment
# See comment in qt-multi-screen-compositor.bb
#Requires=qt-multi-screen-compositor.socket
[Service] [Service]
User=qt User=qt
Group=qt Group=qt
WorkingDirectory=/home/qt WorkingDirectory=/home/qt
PAMName=qt-autologin PAMName=qt-autologin
#Environment=XDG_RUNTIME_DIR=/var/run/user/0
# TODO: Replace the UID with a more stable folder/value
Environment=XDG_RUNTIME_DIR=/run/user/1001
Environment=QT_QPA_FONTDIR=/usr/share/fonts/truetype Environment=QT_QPA_FONTDIR=/usr/share/fonts/truetype
Environment=QT_QPA_PLATFORM=eglfs Environment=QT_QPA_PLATFORM=eglfs
...@@ -17,10 +22,12 @@ Environment=QT_QPA_EGLFS_KMS_CONFIG=/etc/kms.conf ...@@ -17,10 +22,12 @@ Environment=QT_QPA_EGLFS_KMS_CONFIG=/etc/kms.conf
Environment=QT_QPA_EGLFS_INTEGRATION=eglfs_kms Environment=QT_QPA_EGLFS_INTEGRATION=eglfs_kms
Environment=QT_QPA_EGLFS_KMS_ATOMIC=1 Environment=QT_QPA_EGLFS_KMS_ATOMIC=1
# Use this if the touch entry is rotated compared to the screen # The following parameter rotates the touchscreen input
# as the normal libinput calibration is not yet implemented # by 180 degrees. As the normal libinput calibration isn't
# this is the only way of touch calibration available # implemented yet, this is the only way to enable touch
# Environment=QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=rotate=180 # calibration at the moment.
#Environment=QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=rotate=180
StandardError=journal StandardError=journal
PermissionsStartOnly=true PermissionsStartOnly=true
IgnoreSIGPIPE=no IgnoreSIGPIPE=no
......
auth required pam_nologin.so
auth required pam_unix.so try_first_pass nullok
account required pam_nologin.so
account required pam_unix.so
session required pam_env.so
session required pam_unix.so
-session optional pam_systemd.so type=wayland class=user desktop=qt
-session optional pam_loginuid.so
...@@ -3,23 +3,30 @@ Description=Qt multi-screen Compositor ...@@ -3,23 +3,30 @@ Description=Qt multi-screen Compositor
RequiresMountsFor=/run RequiresMountsFor=/run
Conflicts=plymouth-quit.service Conflicts=plymouth-quit.service
After=systemd-user-sessions.service plymouth-quit-wait.service systemd-logind.service After=systemd-user-sessions.service plymouth-quit-wait.service systemd-logind.service
# Starting via socket unit doesn't work at the moment
# See comment in qt-multi-screen-compositor.bb
#Requires=qt-multi-screen-compositor.socket
[Service] [Service]
User=qt User=qt
Group=qt Group=qt
WorkingDirectory=/home/qt WorkingDirectory=/home/qt
PAMName=qt-autologin PAMName=qt-autologin
#Environment=XDG_RUNTIME_DIR=/var/run/user/0
# TODO: Replace the UID with a more stable folder/value
Environment=XDG_RUNTIME_DIR=/run/user/1001
Environment=QT_QPA_FONTDIR=/usr/share/fonts/truetype Environment=QT_QPA_FONTDIR=/usr/share/fonts/truetype
Environment=QT_QPA_PLATFORM=eglfs Environment=QT_QPA_PLATFORM=eglfs
Environment=QT_QPA_EGLFS_INTEGRATION=eglfs_kms Environment=QT_QPA_EGLFS_INTEGRATION=eglfs_kms
Environment=QT_QPA_EGLFS_KMS_ATOMIC=1 Environment=QT_QPA_EGLFS_KMS_ATOMIC=1
# Use this if the touch entry is rotated compared to the screen # The following parameter rotates the touchscreen input
# as the normal libinput calibration is not yet implemented # by 180 degrees. As the normal libinput calibration isn't
# this is the only way of touch calibration available # implemented yet, this is the only way to enable touch
# Environment=QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=rotate=180 # calibration at the moment.
#Environment=QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=rotate=180
StandardError=journal StandardError=journal
PermissionsStartOnly=true PermissionsStartOnly=true
IgnoreSIGPIPE=no IgnoreSIGPIPE=no
......
[Unit]
Description=Qt multi-screen Compositor socket
RequiresMountsFor=/run
[Socket]
ListenStream=/run/wayland-0
SocketMode=0775
SocketUser=qt
SocketGroup=wayland
RemoveOnStop=yes
[Install]
WantedBy=sockets.target
...@@ -11,9 +11,28 @@ SRCREV = "${AUTOREV}" ...@@ -11,9 +11,28 @@ SRCREV = "${AUTOREV}"
SRC_URI = " \ SRC_URI = " \
git://git.seco.com/seco-ne/tools/qt-multi-screen-compositor.git;protocol=https;branch=master;nobranch=1 \ git://git.seco.com/seco-ne/tools/qt-multi-screen-compositor.git;protocol=https;branch=master;nobranch=1 \
file://qt-autologin \
file://qt-multi-screen-compositor.service \ file://qt-multi-screen-compositor.service \
" "
# Starting the qt-compositor via a systemd socket doesn't work out of the box.
# The systemd socket unit opens the socket and waits for requests from applications
# on this socket. When an application connects, the unit starts the service itself.
# The daemon (in this case the qt-compositor), then needs to re-use the socket from
# the socket unit. Right now, our qt-multi-screen-compositor implementation can't
# re-use the socket and opens a new socket instead. This behavior blocks the starting
# Wayland application (e.g. fingerpaint).
# Until our compositor implementation handles the requests properly,
# we stick to the old way of manually starting the service unit.
#SRC_URI += " \
# file://qt-multi-screen-compositor.socket \
#"
SRC_URI:append:mx8m = " \
file://kms.conf \
"
inherit gitpkgv inherit gitpkgv
PKGV = "${GITPKGVTAG}" PKGV = "${GITPKGVTAG}"
...@@ -40,12 +59,14 @@ do_install () { ...@@ -40,12 +59,14 @@ do_install () {
# Systemd Unit # Systemd Unit
install -d ${D}${systemd_system_unitdir}/ install -d ${D}${systemd_system_unitdir}/
install -D -p -m 0644 ${WORKDIR}/qt-multi-screen-compositor.service ${D}${systemd_system_unitdir}/qt-multi-screen-compositor.service install -D -p -m 0644 ${WORKDIR}/qt-multi-screen-compositor.service ${D}${systemd_system_unitdir}/qt-multi-screen-compositor.service
#install -D -p -m 0644 ${WORKDIR}/qt-multi-screen-compositor.socket ${D}${systemd_system_unitdir}/qt-multi-screen-compositor.socket
fi fi
}
SRC_URI:append:mx8m = " \ if ${@bb.utils.contains('DISTRO_FEATURES','pam','true','false',d)}; then
file://kms.conf \ # Autologin for Service Unit
" install -D -p -m 0644 ${WORKDIR}/qt-autologin ${D}${sysconfdir}/pam.d/qt-autologin
fi
}
do_install:append:mx8m () { do_install:append:mx8m () {
install -d ${D}${sysconfdir}/ install -d ${D}${sysconfdir}/
...@@ -53,12 +74,24 @@ do_install:append:mx8m () { ...@@ -53,12 +74,24 @@ do_install:append:mx8m () {
} }
FILES:${PN} += " \ FILES:${PN} += " \
${sysconfdir}/pam.d/ \
${systemd_system_unitdir}/qt-multi-screen-compositor.service \ ${systemd_system_unitdir}/qt-multi-screen-compositor.service \
" "
SYSTEMD_SERVICE:${PN} = "qt-multi-screen-compositor.service" #FILES:${PN} += " \
# ${systemd_system_unitdir}/qt-multi-screen-compositor.socket \
#"
SYSTEMD_SERVICE:${PN} = " \
qt-multi-screen-compositor.service \
"
#SYSTEMD_SERVICE:${PN} += " \
# qt-multi-screen-compositor.socket \
#"
inherit useradd inherit useradd
USERADD_PACKAGES = "${PN}" USERADD_PACKAGES = "${PN}"
USERADD_PARAM:${PN} = "--home /home/qt --shell /bin/sh --user-group -G video,input qt" USERADD_PARAM:${PN} = "--home /home/qt --shell /bin/sh --user-group -G video,input qt"
GROUPADD_PARAM:${PN} = "--system wayland"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment