Difficulty: ★★☆☆☆
Rootless Graphical Sessions
In many cases the display server may be launched with root privileges.
To verify how Xorg is started you may use:
ps -o user= -C Xorg
This of course can be a security concern.
A somewhat contemporary, albeit far from exhaustive, example would be:
Launching xorg or wayland rootless will require different steps for different display managers.
GDM
GDM will automatically launch X or Wayland rootless if kernel mode setting is configured.
SDDM
Beginning with version 0.20.0 SDDM can launch the display server rootless.
SDDM requires configuration files for xorg and wayland respectively.
-
X11
Edit
/etc/sddm.conf.d/rootless-x11.conf
[General] DisplayServer=x11-user
-
Wayland
Edit
/etc/sddm.conf.d/rootless-wayland.conf
[General] DisplayServer=wayland GreeterEnvironment=QT_WAYLAND_SHELL_INTEGRATION=layer-shell [Wayland] CompositorCommand="weston --shell=fullscreen-shell.so"
NOTE: The default compositor string is contained here.
In the case a different Wayland compositor to render SDDM is desired replace theCompositorCommand
string with the relevant command and arguments.
For KWin you may use:
kwin_wayland --no-lockscreen --no-global-shortcuts
Additional Steps for Everyone
These configurations are for everyone.
They can be considered optional for users of Display Managers, and required for those without one.
-
xserverrc
You may edit
/etc/X11/xinit/xserverrc
directly.
But it is advisable to copy it to~/.xserverrc
.-
Remove
exec
from the line if it exists to ensure startx is a subprocess of the login shell.
Example:
exec /usr/bin/X -nolisten tcp "$@"
becomes
/usr/bin/X -nolisten tcp "$@"
-
Use
-keeptty
to keep log redirection.
When X is run rootless logs are directed to~/.local/share/xorg/Xorg.log
, but the stdout and stderr output from the Xorg session is not redirected there.
Example:
/usr/bin/X -nolisten tcp "$@"
becomes
/usr/bin/X -nolisten tcp "$@" -keeptty
-
Make sure that Xorg uses the correct virtual terminal for permissions, such as by
vt$XDG_VTNR
Example:
/usr/bin/X -nolisten tcp "$@" -keeptty
becomes
/usr/bin/X -nolisten tcp "$@" -keeptty vt$XDG_VTNR
-
-
Proprietary graphics (nvidia)
Kernel Mode Setting will fail unless the following is set in
/etc/X11/Xwrapper.config
:
needs_root_rights=no
NOTE: The following was previously reported to sometimes be required. Retained for posterity.
allowed_users=anybody
LightDM
Sorry lightdm users, there is currently no way to launch your display server rootless from lightdm.
A bug thread can be found here: Support non-root X · Issue #18 · canonical/lightdm · GitHub
Final Notes
-
I use KDE,SDDM,X11 - all else is provided only for testing.
There may be dragons. There may not. -
In the case of SDDM (possibly others) there existed a sometimes-bug resulting in the display handoff not always working as expected. In these cases the user must simply manually switch seats, such as by using Ctrl+Alt+F#
-
This will be marked a wiki post.
So consider it an evolving work in progress as things change and feel free to correct or fill it out.