Repository navigation
fix(packaging): let root own what the root scripts execute - #23
Merged
Merged
Conversation
The installation hands the application tree to the unprivileged ds user: the deb postinst ends its configure step with a chown of everything under /var/www/<product> to ds, and the rpm files section says the same with %attr(550, ds, ds). Among those files are programs the helpers in /usr/bin run as root: allfontsgen, allthemesgen and pluginsmanager in server/tools, and the converter x2t together with the libraries it loads through LD_LIBRARY_PATH. Whoever owns a file can chmod it and write it, so ds can put its own code into one of them and have the next font regeneration, or the next plugin install, run it as root. The sudoers grant lets ds start the font script as root itself. What root executes is now owned by root. The rpm already said so for the shared libraries in FileConverter/bin; it says it for the tools and for x2t too, and the blanket chown in the postinst gets the matching exception. The directories holding them belong to root for the same reason: chmod a-w does not hold against the owner of a directory, who can make it writable again, and in a writable directory ds can replace x2t whoever owns the file. That holds for every directory on the way down, so the application root, server/, server/FileConverter/ and npm/ become root's too: in a ds owned server/, ds can rename the root owned tools/ aside and put its own in its place. Only the directories change owner; what is in them keeps its owner. The json helper the root scripts parse configuration with moves to root as well. The font script stops handing the whole converter directory back to ds after each run and names the three files it generated instead, otherwise it would undo the fix on the next regeneration. It uses chown -h, so a symlink in place of one of those names is changed itself, as chown -R did before, rather than the file it points at. The generators keep running as root in the packaged install: the tree is write protected for ds on purpose. The orchestrated image is different. It installs this rpm with --noscripts, carries the ownership over with COPY --from, and runs its font init as ds, which chmods and writes server/FileConverter/bin. That directory is now root's there as well, so the image needs a matching chown ds:ds of it in its docs stage, where nothing runs as root. Checked: the chown sequence taken from the rendered postinst and font script, replayed on a model tree, leaves the programs, their two directories and the json helper root owned and the generated font files with ds, for the plain install and the container variant that skips the chowns, while the templates before this change leave them with ds. As root in a container, ds replaced a root owned x2t inside a ds owned directory, including one left at a-w, and could not inside a root owned one, nor by renaming a directory on the way down aside; and the font script's chown no longer gives ds the target of a symlinked fonts.log. rpmbuild of the files section shows the directories and the programs as root 755 and docservice and docbuilder still with ds. The sudoers file is untouched: the three commands in it are what the application legitimately asks for, and it was the writable programs behind them that made the escalation possible. An existing installation is repaired by the next package upgrade, which runs the configure step again. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com> (cherry picked from commit b85c4f1) Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
Contributor
Author
|
/backport to stable-9.3.8 |
47 of 49 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This brings
b85c4f17frommastertomain. It was merged intomasteron 2026-11-02 by mistake:mainis the branch the releases are built from, so the change is missing from 9.3.8-rc.1.The commit is a plain cherry-pick (
-x) with no changes. It applies cleanly to currentmain: 3 files, +38/−5 (deb/template/postinst.m4,rpm/common.spec,documentserver-generate-allfonts.sh.m4). The change was already reviewed and approved on its original PR.One note on the commit message: it mentions a
chown ds:dscompanion for the orchestrated image. The companion that was actually merged instead is DocumentServer#502, which drops thechmodonFileConverter/binfrom the orchestrated font init. #502 is already onmainand in rc.1, so this PR has no other dependency.After merging, this needs
/backport to stable-9.3.8so it lands in rc.2.🤖 Generated with Claude Code