Repository navigation
Hand panel-written server files to the game container's user - #343
Merged
Merged
Conversation
The panel runs as root and the game container runs unprivileged, but they share a bind-mounted data directory. Anything the panel wrote there was root-owned mode 0644, so the game could not rewrite it. A modpack whose server pack was extracted through the panel then crash-looped on Failed to update server.properties, which reads as a mod bug. files.AdoptOwnership copies the data directory's uid/gid onto what was just written. Applied after extraction, upload, file update and a restore's tree swap; a no-op when ownership already matches and on Windows, which has no uid/gid model.
Owner
Author
|
End-to-end evidence on a live instance (panel container runs as root, game container as uid 1000): The panel write now lands with the data directory's owner instead of root's, which is the exact file the game needs to rewrite on boot. |
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.
Problem
A modpack server could not start. The live console showed it exiting at boot:
server.properties,ops.json,whitelist.jsonanduser_jvm_args.txtin the server's data directory were owned byrootand mode0644, while the game container runs as uid 1000. The itzg image rewritesserver.propertieson every boot, so the server crash-looped. It reads as a mod or modpack failure; it is an ownership failure.The files came from a server pack unzipped through the panel. The panel runs as root, the game does not, and both use the same bind mount, so every file the panel writes into a server's data directory was root-owned: extraction, uploads, file edits and restore.
Fix
files.AdoptOwnership(reference, target, recursive)copies the reference's uid/gid onto what was just written, skipping paths that already match. Applied at the seams where the panel mutates a server's data directory:It is a no-op when the platform has no uid/gid model, which keeps the Windows build and the Windows-native development path unchanged (
ownership_windows.go).Verification
go build ./...on Windows andGOOS=linux;go vet ./pkg/filesgo test ./pkg/files ./internal/rpc/servicesgreenserver.propertiescrash-looped; after handing the directory to uid 1000 it started and reached "Done (5.898s)!" with the world intactRefs OSS-238, OSS-247