Files
RedBear-OS/local/recipes/system/redbear-session-launch
vasilito 7b8a1b2838 release: open 0.3.2 and sync Cat 1/Cat 2 version labels
New release branch per the release-branch model (operator decision;
local/AGENTS.md reserves branch creation to the operator).

sync-versions.sh, driven by bump-release.sh, rewrites:
  - Cat 1 in-house crates  -> version = 0.3.2
  - Cat 2 upstream forks   -> <upstream-tag>+rb0.3.2

Labels only; no fork source was rebased in this commit. bump-release.sh
reports these forks as having newer upstream tags, to be taken next:
  relibc   0.2.5  -> 0.6.0
  syscall  0.9.0  -> 0.9.1
  libredox 0.1.18 -> 0.1.19
redoxfs and redox-scheme are already current. kernel, bootloader and
installer are 'diverged' in the fork map and stay report-only (manual
rebase); bootloader additionally has no merge-base with upstream.
2026-08-03 11:04:40 +03:00
..

redbear-session-launch

Session bootstrap helper — uid/gid/env/runtime-dir handoff

Status: FEATURE-INCOMPLETE Category: system Build: cargo build --release --manifest-path source/Cargo.toml

Purpose

redbear-session-launch is the Red Bear session bootstrap binary. It loads a user account from /etc/passwd, resolves supplementary group memberships from /etc/group, creates an XDG-compliant runtime directory with correct ownership, builds a full desktop environment variable set, and then exec()s into the target session command (KDE on Wayland) or an arbitrary program with the correct uid/gid/supplementary groups. It is invoked by redbear-authd after successful authentication and by redbear-greeterd to launch the compositor and greeter UI as the greeter user.

Command Line

redbear-session-launch --username USER [--mode session|command] [--session kde-wayland]
    [--vt N] [--runtime-dir PATH] [--wayland-display NAME]
    [--command PROGRAM [ARGS...]]
Flag Description
--username USER Required. User to launch as.
`--mode session command`
--session NAME Session type (currently only kde-wayland is supported). Sets XDG_CURRENT_DESKTOP=KDE.
--vt N Virtual terminal number (default: 3).
--runtime-dir PATH Override the XDG runtime directory (default: /run/user/<uid> or /tmp/run/user/<uid>).
--wayland-display NAME Wayland display socket name (default: wayland-0).
--command PROGRAM [ARGS...] In command mode, the program and arguments to execute.

Architecture

Single-file Rust binary (src/main.rs, ~609 lines). No async runtime — synchronous execution model culminating in exec().

Key types:

  • Account — username, uid, gid, home directory, shell
  • GroupEntry — gid + member usernames
  • LaunchModeSession or Command { program, args }
  • Args — parsed CLI arguments

Flow:

  1. Parse CLI arguments
  2. Load account from /etc/passwd (dual-format: Redox ; + Unix :)
  3. Load supplementary groups from /etc/group (intersection of primary gid and group memberships)
  4. Create XDG runtime directory with mkdir + chown + chmod 700
  5. Build environment map:
    • Standard: HOME, USER, LOGNAME, SHELL, PATH
    • XDG: XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_STATE_HOME, XDG_RUNTIME_DIR, XDG_CURRENT_DESKTOP, XDG_SESSION_TYPE, XDG_SESSION_ID
    • Wayland: WAYLAND_DISPLAY
    • KDE: KDE_FULL_SESSION=true
    • Seat: LIBSEAT_BACKEND=seatd, SEATD_SOCK=/run/seatd.sock
    • Propagated: KWIN_DRM_DEVICES, XCURSOR_THEME, XKB_CONFIG_ROOT, QT_PLUGIN_PATH, REDBEAR_DRM_WAIT_SECONDS
  6. Build command: for session mode → /usr/bin/dbus-run-session -- /usr/bin/redbear-kde-session (or direct if dbus-run-session missing)
  7. exec() with uid()/gid() setters + pre_exec for setgroups() (Linux host only; Redox target omits setgroups since the syscall is not yet implemented)

Dependencies: libc only.

Status Notes

  • Core functionality: Account loading, supplementary group resolution, runtime directory creation, environment setup, command selection, and exec() handoff all implemented.
  • Session types: Only kde-wayland is supported. Other session names return an error.
  • Dual-format parsing: Supports both Redox (;) and Unix (:) account file formats.
  • setgroups: Applied on Linux host only. Redox target omits the call (redox_syscall SYS_SETGROUPS not yet implemented).
  • Tests: 11 unit tests covering CLI parsing (session mode, command mode, error cases), passwd parsing (Unix + Redox formats), group parsing, environment construction (session + command modes), KWIN_DRM_DEVICES propagation, and unsupported session names.

Consumers

  • redbear-authd — launches user desktop sessions after successful authentication
  • redbear-greeterd — launches greeter compositor and UI as the greeter user

Cross-reference: local/docs/GREETER-LOGIN-IMPLEMENTATION-PLAN.md