mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-29 18:51:43 +02:00
Fix SpoolBuddy update Docker failure — set LOGNAME/USER/HOME in image
Follow-up to the asyncssh migration. asyncssh.connect() internally
calls getpass.getuser() for ~/.ssh/config host matching, regardless
of the explicit `username=` passed for the remote login. Under an
arbitrary Docker PUID with no /etc/passwd entry, getpass.getuser()
raises "No username set in the environment" (OSError in Python 3.13+,
previously a bare KeyError).
Fix: set LOGNAME=bambuddy, USER=bambuddy, HOME=/app in the Dockerfile.
getpass.getuser() tries env vars before pwd.getpwuid(), so the lookup
never touches the passwd database and works for any PUID the operator
picks — no helper code, no image rebuild for different UIDs.
Also pass config=[] to asyncssh.connect() so it does not try to load
~/.ssh/config (whose default path needs a resolvable home directory).
An earlier draft of this fix added a Python helper that caught the
KeyError and injected LOGNAME at module import. That was both more
code than needed and broken on Python 3.13, which wraps the KeyError
in an OSError the helper didn't catch — so the module import itself
crashed, producing a 500 on /spoolbuddy/devices/{id}/update. Reverted
in favour of the one-line ENV fix.
This commit is contained in:
+11
@@ -53,6 +53,17 @@ ENV PYTHONUNBUFFERED=1
|
||||
ENV DATA_DIR=/app/data
|
||||
ENV LOG_DIR=/app/logs
|
||||
ENV PORT=8000
|
||||
# Provide a local username + home for tools that call getpass.getuser() /
|
||||
# os.path.expanduser() under arbitrary PUIDs. With `user: "1001:1001"` the
|
||||
# stock python:3.13-slim image has no /etc/passwd entry for that UID, so
|
||||
# pwd.getpwuid() raises and breaks libraries that do host-level user lookups
|
||||
# (notably asyncssh, which uses the local username for ~/.ssh/config host
|
||||
# matching during the SpoolBuddy remote-update flow). Setting LOGNAME/USER
|
||||
# makes getpass.getuser() resolve via env vars instead of the passwd db;
|
||||
# HOME=/app gives a writable home that is guaranteed to exist.
|
||||
ENV HOME=/app
|
||||
ENV USER=bambuddy
|
||||
ENV LOGNAME=bambuddy
|
||||
|
||||
EXPOSE 322
|
||||
EXPOSE 990
|
||||
|
||||
Reference in New Issue
Block a user