Running Qt Applications as Non-Root Users in Embedded Linux with Wayland

2025-08-17
Running Qt Applications as Non-Root Users in Embedded Linux with Wayland

Embedded Linux systems often run Qt applications as root, posing a security risk. This article details a solution to run Qt applications as a non-root user (weston) within a Yocto-built system using Wayland. By modifying the Weston and Qt application service units and configuring the `XDG_RUNTIME_DIR` and `WAYLAND_DISPLAY` environment variables, the article ensures both the Wayland server and clients use the same socket file, enhancing security and complying with the EU Cyber Resilience Act. Key steps include altering the user and group in weston.service and weston.socket, and generating the weston-client environment file within weston-init.bbappend. This effectively allows Qt applications to run without root privileges.

Development