nevaforget 64f08d7e8b Harden greeter against threading issues, path traversal, and edge cases
Security:
- Fix path traversal in _save/_load_last_session by rejecting usernames
  starting with dot (blocks '..' and hidden file creation)
- Add avatar file size limit (10 MB) to prevent DoS via large ~/.face
- Add session_name length validation on write (symmetric with read)
- Add payload size check to send_message (symmetric with recv_message)
- Set log level to INFO in production (was DEBUG)

Quality:
- Eliminate main-thread blocking on user switch: _cancel_pending_session
  now sets a cancellation event and closes the socket instead of doing
  blocking IPC. The login worker checks the event after each step.
- Move power actions (reboot/shutdown) to background threads
- Catch TimeoutExpired in addition to CalledProcessError for power actions
- Consolidate socket cleanup in _login_worker via finally block, remove
  redundant _close_greetd_sock calls from error callbacks
- Fix _select_initial_user to return False for GLib.idle_add deregistration
- Fix context manager leak in resolve_wallpaper_path on exception
- Pass Config object to GreeterWindow instead of loading it twice
2026-03-26 16:25:13 +01:00

Moongreet

A greetd greeter for Wayland, built with Python + GTK4 + gtk4-layer-shell. Part of the Moonarch ecosystem.

Features

  • greetd IPC — Communicates via $GREETD_SOCK (length-prefixed JSON)
  • User list — Parsed from /etc/passwd (UID 100065533)
  • Avatars — AccountsService icons, ~/.face fallback, default SVG
  • Sessions — Discovered from /usr/share/wayland-sessions/ and /usr/share/xsessions/
  • Last user — Remembered in /var/cache/moongreet/last-user
  • Power actions — Reboot / Shutdown via loginctl
  • Layer Shell — Fullscreen via gtk4-layer-shell

Requirements

  • Python 3.11+
  • GTK 4, PyGObject
  • gtk4-layer-shell (for Wayland fullscreen)
  • greetd

Installation

uv pip install .

System Setup

  1. Copy configuration:

    sudo mkdir -p /etc/moongreet
    sudo cp config/moongreet.toml /etc/moongreet/moongreet.toml
    
  2. Edit /etc/moongreet/moongreet.toml — set an absolute path for the wallpaper.

  3. Create cache directory:

    sudo mkdir -p /var/cache/moongreet
    sudo chown greeter:greeter /var/cache/moongreet
    
  4. Configure greetd (/etc/greetd/config.toml):

    [default_session]
    command = "moongreet"
    user = "greeter"
    

Development

# Run tests
uv run pytest tests/ -v

# Type checking
uv run pyright src/

# Run locally (without greetd)
uv run moongreet

License

MIT

Description
No description provided
Readme 5.9 MiB
Languages
Rust 97.8%
CSS 1.4%
Shell 0.8%