Repository navigation
feat(docker): run the server as an unprivileged user - #513
Conversation
The image ran the server as root. It now runs as 65532:65532, which owns the two directories the server writes to: - /var: the SQLite database (var/etherpad.db) and the update state, as before; - /data: settings.json (ETHERPAD_SETTINGS_PATH=/data), also as saved in the admin UI. / is not writable for the user any more. settings.json is read from ETHERPAD_SETTINGS_PATH when that holds one, otherwise from the working directory as before, so a file mounted at /settings.json keeps working. The admin UI reads the same file the server read and saves into ETHERPAD_SETTINGS_PATH (before, it could read and write another file than the one the server started with). `config get` loads the settings like `config show`, instead of showing defaults only. A /var volume from an older image belongs to root; the README shows the one-time chown. The kubernetes job runs the pods with runAsNonRoot and checks the user and the writable directories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012RMvvMtnCwj6ycD9fwLYVu
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoRun Docker images as a non-root user with writable data directories
AI Description
Diagram
High-Level Assessment
Files changed (11)
|
Code Review by Qodo
1.
|
Review fixes for the unprivileged image: - ETHERPAD_SETTINGS_FILE names settings.json (the image: /data/settings.json); ETHERPAD_SETTINGS_PATH stays the root (/ in the image), so /APIKEY.txt and relative favicon paths resolve as before. - The read and save locations are settled once at start (Settings. SettingsFile/SettingsSaveFile) and used by the start and the admin UI alike: the UI no longer shows one file and saves another, e.g. next to the executable, that the next start does not read. - Only a missing settings.json counts as missing. A file that is there but cannot be reached (no permission) stops the start, instead of starting on defaults without the configured requireAuthentication; so does a settings.json that does not parse (before, the server went on with empty settings). - config get/show read the settings without the server's setup, so a query creates no database directory. - README: a host directory bind-mounted at /var or /data keeps its owner and must be writable for 65532. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012RMvvMtnCwj6ycD9fwLYVu
Builds on #512 (base
fix/docker-binary-name). Once #512 is merged, this PR moves tomain.The image ran the server as root. It now runs as the unprivileged user
65532:65532.Where the server writes
/varvar/etherpad.db, the default) and the update state, as before/datasettings.json(ETHERPAD_SETTINGS_PATH=/data), also as saved in the admin UI/is no longer writable for the server.Settings
settings.jsonis read fromETHERPAD_SETTINGS_PATHwhen a file exists there. Otherwise it is read from the working directory, as before, so a file mounted at/settings.jsonkeeps working.ETHERPAD_SETTINGS_PATH. Before, it could read and write a different file from the one the server started with.config getnow loads the settings likeconfig show. Before, it only showed defaults and environment variables, although the README offers it for looking up a value (Terminal #413).Breaking for SQLite with a
/varvolumeAn existing volume belongs to root, and the server stops with
attempt to write a readonly database. The README shows the one-time fix:With Postgres or MySQL and no volume, nothing changes. Please mention this in the release notes.
Tests
runAsNonRoot: true,allowPrivilegeEscalation: falseand all capabilities dropped;/varand/dataare writable and/is not.lib/settings/settingsfile_test.goandTestReadConfigReadsTheSettingsPath./var(HTTP 200);/settings.jsonis read;/data/settings.jsontakes precedence over it;/dataworks as the user;/varvolume fails with the error above and runs after thechown.Generated by Claude Code