Skip to content

baijia-suo — A Secure Wayland Screen Locker

A Wayland screen locker in Rust. Authentication runs out of process and the thing fails closed.

ROLE
Solo — design and engineering
PERIOD
2025 – Present
SYSTEMS-LEVEL, FAIL-CLOSED
Rust
STACK
Rust, Wayland, PAM, ext-session-lock-v1
THE PROBLEM

A screen locker has one job, and nobody thinks about it until it fails open. The old X11 lockers don't carry over to Wayland, and a locker that crashes, leaks the password out of memory, or lets you attach a debugger to it has failed at that job. 百家锁 means the lock of a hundred families. This one tries to take the boundary seriously.

WHAT I BUILT
  • PAM runs in a separate child process, not in the one talking to the compositor. A memory disclosure in the UI half doesn't give up the password.
  • Password buffers are page-aligned and mlocked so they never hit swap, and get zeroized after use. The auth child is pinned in RAM with mlockall.
  • PR_SET_DUMPABLE turns off core dumps and refuses non-root ptrace. You can't attach to the running locker or dump it.
  • Built on ext-session-lock-v1. If the locker process dies the session stays locked. The failure mode is being locked out, which is the right one.
  • Ported 66 animations from xlockmore and xscreensaver, each file keeping its original author's permissive licence. That is the part this started as: those screensavers are decades of well-loved work that only ran under X11, and Wayland was quietly going to strand them. Carrying them forward needed a locker worth trusting to run them.
  • Backgrounds are RGBA and the typing indicator has several styles, oscilloscope among them. Configure by TOML or CLI flag.
OUTCOME
  • A locker that works, with a man page, shell completions and distro packaging.
  • Fail-closed by construction. What keeps the session locked is the protocol, not the process staying up.
  • Public, with a SECURITY.md that says plainly it hasn't been independently audited.
  • 66 animations that would otherwise have died with X11 now run on a modern compositor, with their authorship and licences intact.
SCREENSHOTS
The baijia-suo lock screen showing the 'coral' animation: a dense branching fractal in magenta, blue and teal filling the screen, with a round mauve typing indicator at the centre drawing a live oscilloscope trace.
The 'coral' animation, with the oscilloscope typing indicator lit. It traces a waveform as you type rather than counting dots.
The baijia-suo lock screen showing the 'spiral' animation: two sweeping fans of fine dotted arcs in green and magenta against a near-black background, with the mauve typing indicator at the centre.
'spiral', one of 66 backgrounds ported over from xlockmore and xscreensaver.
The baijia-suo lock screen showing the 'vines' animation: dozens of small brightly coloured branching growths scattered across a black background, with the mauve typing indicator at the centre.
'vines'. Background, indicator style, opacity and colour are all configurable by TOML or CLI flag.