-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for common permissions issues with scratch area #765
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6adfc2f
Check that SGID bit is enabled for scratch area
callumforrester 0afde5a
qwAdd option to configure GID for scratch area
callumforrester 7846c68
Always run blueapi with a umask of 002
callumforrester c529b2b
Fix config tests
callumforrester 91f7618
Add docs to config fields
callumforrester 6fa4bf3
Add reference in docs
callumforrester b3f9a7b
Rename sgid check util function
callumforrester c114dbf
Use path.stat() instead of os.stat(path)
callumforrester d53079f
Make test IDs clearer for file permissions checks
callumforrester 6fa9b0e
Mock umasking from CLI tests
callumforrester 928c7b0
Suggest different command for transfer of file ownership
callumforrester d4250b8
Fix fixture names in scratch tests
callumforrester 9f0ede8
Fix test permissions issue
callumforrester 8b7dc04
Catch more enables
callumforrester a9d6b74
Skip flaky test
callumforrester File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import stat | ||
from pathlib import Path | ||
|
||
|
||
def is_sgid_set(path: Path) -> bool: | ||
"""Check if the SGID bit is set so that new files created | ||
under a directory owned by a group are owned by that same group. | ||
|
||
See https://www.redhat.com/en/blog/suid-sgid-sticky-bit | ||
|
||
Args: | ||
path: Path to the file to check | ||
|
||
Returns: | ||
bool: True if the SGID bit is set | ||
""" | ||
|
||
mask = path.stat().st_mode | ||
return bool(mask & stat.S_ISGID) | ||
|
||
|
||
def get_owner_gid(path: Path) -> int: | ||
"""Get the GID of the owner of a file | ||
|
||
Args: | ||
path: Path to the file to check | ||
|
||
Returns: | ||
bool: The GID of the file owner | ||
""" | ||
|
||
return path.stat().st_gid |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed from
ensure_repo
as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, there's another test which clones to a tempdir that only passes because of this line (because the test calls
ensure_repo
directly rather than invoking the CLI. Maybe the test should use mocks instead, although I do worry that sticking the umask set in the CLI isn't as robust as I thought. Might be better to pepper the code with someensure_correct_umask
function in strategic places...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...I now think we'll have to mock out all the directories in these tests anyway because of a separate issue that is breaking the CI with
test_setup_scratch_succeeds_on_required_gid
. I'll make an issue for that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#770