Skip to content

[BUGFIX] Keep the setgid bit for deploy users outside the group - #59

Merged
ochorocho merged 1 commit into
mainfrom
bugfix/keep-setgid-for-deploy-user-outside-group
Nov 13, 2026
Merged

ochorocho merged 1 commit into
mainfrom
bugfix/keep-setgid-for-deploy-user-outside-group

Conversation

@ochorocho

Copy link
Copy Markdown
Owner

A deploy user who is not a member of the siteroot's group (e.g. www-data) got release directories without the setgid flag, so every deeper level ended up in the user's own group. Linux drops the setgid bit when a non-member changes a directory's mode, and rsync --perms --chmod always did: on the release root (created at the remote umask, 2755) and on every subdirectory (rsync creates them with temporary modes and fixes them up).

Create the release root and its directory tree with mkdir under a umask derived from dir_mode instead. Directories inherit setgid and group from their parent and already have the final mode, so rsync leaves them alone.

The integration tests deployed as root, which never loses the bit. Add a non-root deploy user to the test image and cover this case.

A deploy user who is not a member of the siteroot's group (e.g. www-data)
got release directories without the setgid flag, so every deeper level
ended up in the user's own group. Linux drops the setgid bit when a
non-member changes a directory's mode, and rsync --perms --chmod always
did: on the release root (created at the remote umask, 2755) and on every
subdirectory (rsync creates them with temporary modes and fixes them up).

Create the release root and its directory tree with mkdir under a umask
derived from dir_mode instead. Directories inherit setgid and group from
their parent and already have the final mode, so rsync leaves them alone.

The integration tests deployed as root, which never loses the bit. Add a
non-root deploy user to the test image and cover this case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ochorocho

Copy link
Copy Markdown
Owner Author

@liayn do you mind having a quick look before i merge this?

@liayn liayn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without studying every test in detail, this sounds very reasonable.

@ochorocho
ochorocho merged commit 0275a2c into main Nov 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants