feat(passwd): self-service password reset across git, mail & chat (#59)

Add a key-gated `ssh passwd@host` route (alias `password@`) that sets ONE
member-chosen password across every service with its own credential:

  - git  (Forgejo)        new forgejo.SetPassword (PATCH /admin/users, clears
                          must_change; EnsureUser first so the account exists)
  - mail (Mailu webmail)  existing mailu.SetPassword
  - chat (IRC/Ergo + The Lounge)  new internal/ircpass package

Because the route authenticates by the member's registered SSH key, it also
serves as the forgot-password path — no old password required.

The BBS runs as a non-root service user, but the Ergo password store and The
Lounge user files are root-owned. internal/ircpass bridges this by shelling out
to scripts/set-irc-password.sh through a narrow sudoers rule (installed by
setup.sh). The new password travels on stdin (a new `set-irc-password.sh
<member> -` form), so it never appears in the process table or sudo's log.

UX: masked entry typed twice (readSecret); no-PTY reads stdin; empty input
generates a strong password and shows it once. Each service leg is independent
and best-effort with a per-service ✓/✗ summary, plus a confirmation email that
never contains the password.

Tests: ircpass (stdin contract + member/password rejection), forgejo.SetPassword,
auth IsPasswdName + reservation. Docs: credentials.md (passwd@ section) + irc.md.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-06-27 03:46:23 -07:00 committed by GitHub
parent f2bcb7e063
commit 54da317f4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 625 additions and 3 deletions

View file

@ -965,8 +965,28 @@ UNIT
sleep 1
systemctl is-active --quiet ergo \
|| warn "ergo failed to start — check: journalctl -u ergo -n50"
# ---- chat password bridge for the BBS passwd@ flow ----------------------
# The Ergo password store + The Lounge user files are root-owned, but the BBS
# runs as ${SVC_USER}. Install set-irc-password.sh to a stable path and grant
# ${SVC_USER} a narrow NOPASSWD sudo rule for exactly that command, so a member
# running `ssh passwd@` can set their chat password alongside git + mail. The
# password travels on stdin (the "-" form), so it never appears in sudo's log.
install -m 0755 -o root -g root \
"${SRC_DIR}/scripts/set-irc-password.sh" /usr/local/sbin/agentbbs-set-irc-password
cat > /etc/sudoers.d/agentbbs-ircpass <<SUDO
${SVC_USER} ALL=(root) NOPASSWD: /usr/local/sbin/agentbbs-set-irc-password
SUDO
chmod 0440 /etc/sudoers.d/agentbbs-ircpass
if visudo -cf /etc/sudoers.d/agentbbs-ircpass >/dev/null 2>&1; then
upsert_env AGENTBBS_SET_IRC_PASSWD /usr/local/sbin/agentbbs-set-irc-password
else
warn "sudoers rule for the chat password bridge is invalid — removing it (passwd@ will skip chat)"
rm -f /etc/sudoers.d/agentbbs-ircpass
fi
else
systemctl disable --now ergo ergo-certs.timer ergo-motd.timer >/dev/null 2>&1 || true
rm -f /etc/sudoers.d/agentbbs-ircpass /usr/local/sbin/agentbbs-set-irc-password
fi
# ---- 9c. News (Usenet/NNTP) server (co-located news.${DOMAIN}) --------------