fix(alpine): create /usr/local/sbin, and run the PAM sshd so pam_exec fires

Two Alpine-only failures from an irc-1 run.

1. harden-firewall.sh died with

     line 161: /usr/local/sbin/firewall-apply: No such file or directory

   and left INPUT unfiltered. Alpine's baselayout ships /usr/local/{bin,lib,
   share} but no sbin, and nothing created it. Create it before writing the
   engine; same guard in oslib's install_boot_hook / install_daily_job (which
   `install` into /usr/local/sbin, and `install` does not make parent dirs) and
   for /usr/local/bin in harden-jumphost.

2. The ntfy login notifier never fired despite reporting ACTIVE. Alpine keeps
   PAM support in a SEPARATE binary: openssh-server gives /usr/sbin/sshd (no
   PAM), openssh-server-pam gives /usr/sbin/sshd.pam. The OpenRC init only
   picks the PAM one in start_pre (checkconfig -> update_command), and its
   reload/stop match the process with `start-stop-daemon --exec "$command"`.
   So a host already running /usr/sbin/sshd never swaps: reload signals a
   non-matching process, stop matches nothing, a later start hits "address
   already in use". sshd keeps serving without PAM, so /etc/pam.d/sshd -- and
   the pam_exec hook in it -- is never consulted.

   Add oslib sshd_wanted_binary / sshd_running_binary / sshd_apply_config, and
   end the harden scripts with sshd_apply_config instead of svc_reload: reload
   as before, but on Alpine stop by pidfile and start again when the running
   binary isn't the one the config calls for. Established sessions are separate
   processes and survive; only the listener blinks.

   install_login_notifier now checks that PAM can actually be reached on Alpine
   (sshd.pam present, UsePAM yes) and warns with the fix instead of reporting a
   hook that can never run as ACTIVE -- the same "silent notifier" trap the
   Alma run hit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5 committed 2026-09-02 08:18:09 -05:00
1 parent f71f8d615a
commit 7c13e18ca5
4 files changed
+95 -2

No files matched your search

+3 -1
View File
@@ -390,6 +390,8 @@ EOF
fi
log "Reloading ${SSHD_SVC}..."
svc_reload "$SSHD_SVC"
# Reload -- and on Alpine swap in the PAM sshd build if the running one
# predates this config (oslib explains why that can happen).
sshd_apply_config
log "Done. Your session, if any, should remain alive (reload preserves connections)."
log "Test from another machine before closing this session."