Commit 5fa9d1c
authored
Fix XFCE execution for non-root local users via xfce-start (#3)
* Fix XFCE execution and DBus panics for non-root local users via xfce-start
### Description
**The Problem:**
Setting XFCE_USER to a non-root user fails to initialize the desktop session due to a cascade of three conflicts:
1. **Socket Access Denial:** startxfce4 triggers a Permission denied error because the X11 and PulseAudio sockets are strictly root-owned.
2. **VirGL Crash (Signal 134):** Dropping privileges via su -l strips essential container environment variables. This severs the VirGL/Termux-X11 bridge and immediately aborts the process.
3. **DBus Panics:** Using su -p to preserve graphics variables inadvertently retains HOME=/root and XDG_RUNTIME_DIR=/run/user/0. Lacking write access to /root/, the standard user triggers severe GLib-CRITICAL DBus errors and fails to build the desktop.
**The Solution:**
This patch refactors /usr/local/bin/xfce-start to securely transition the execution environment without breaking hardware acceleration bridges:
* **Targeted Socket Handoff:** Explicitly assigns ownership (chown) of the X11, PulseAudio, VirGL sockets, and .X5-lock file to the target user.
* **Environment Preservation:** Transitions from su -l to su -p to retain vital container graphics and audio variables.
* **Dynamic Path Override:** Intercepts and dynamically rewrites $HOME and $XDG_RUNTIME_DIR based on the target UID, ensuring a clean DBus initialization isolated from /root.
* **Code Cleanup (Whitelist Deprecation):** Because su -p natively preserves the required container environment, explicitly building and passing a $WHITELIST string via the -w flag is no longer necessary. The obsolete sed parsing logic for /run/droidspaces.env has been safely removed to streamline the script.
* **Zero Regressions:** Fully preserves the default root fallback path for deployments not utilizing XFCE_USER.
### Tested Environments
**Android Target:**
* **Device:** Samsung Galaxy S21+
* **SoC:** Exynos 2100
* **Android Version:** 16
* **Kernel Version:** 5.4.302-Floppy-v1.1.2-KN-g9719914d4da2
**Linux Target (Container):**
* **Distribution:** Debian 13 (Trixie)
* **Architecture:** ARM64
* **Init System:** systemd
### Regression Check
* [X] Default root execution path functions without modification.
* [X] XFCE launches successfully as root when XFCE_USER is empty or unset.
* [X] No modern/restricted kernel syscalls are utilized (fully 3.10 compliant).
* Clean up comment in xfce-start script
Removed unnecessary comment about whitelist in environment variable parsing.
* Using su -l with dynamic whitelist
* XDG_RUNTIME_DIR initialization
- Creates and chmods `/run/user/$(id -u)` (mode `0700`) inside the `su` subshell for non-root users, and `/run/user/0` for the root fallback, satisfying the XDG Base Directory Specification and preventing DBus/XFCE session errors.
* ## Improve XDG_RUNTIME_DIR handling in xfce-start
USER_UID and TARGET_XDG resolved before su
chown "$XFCE_USER" (owner only, no group assumption)
TARGET_XDG interpolated into the subshell command string rather than relying on id -u inside it
mkdir/chmod moved before socket handoff for logical ordering1 parent 0d2b65d commit 5fa9d1c
1 file changed
Lines changed: 36 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
19 | 16 | | |
20 | 17 | | |
21 | 18 | | |
22 | | - | |
23 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
24 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
25 | 55 | | |
26 | 56 | | |
0 commit comments