-
Notifications
You must be signed in to change notification settings - Fork 163
add setgid option to projects #4872
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
Merged
Merged
Changes from all commits
Commits
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 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,7 +113,7 @@ def importable_directories | |
| end | ||
| end | ||
|
|
||
| attr_reader :id, :name, :description, :icon, :directory, :template, :files, :group_owner | ||
| attr_reader :id, :name, :description, :icon, :directory, :template, :files, :group_owner, :setgid | ||
|
|
||
| validates :name, presence: { message: :required }, on: [:create, :update] | ||
| validates :id, :directory, :icon, presence: { message: :required }, on: [:update] | ||
|
|
@@ -131,6 +131,7 @@ def initialize(attributes = {}) | |
| @directory = File.expand_path(@directory) unless @directory.blank? | ||
| @template = attributes[:template] | ||
| @group_owner = attributes[:group_owner] || directory_group_owner | ||
| @setgid = attributes[:setgid].to_s == '1' | ||
|
|
||
| return if new_record? | ||
|
|
||
|
|
@@ -351,8 +352,14 @@ def make_dir | |
| end | ||
|
|
||
| def update_permission | ||
| project_dataroot.chmod(0750) | ||
| chgrp_directory | ||
| return false unless chgrp_directory | ||
|
|
||
| root_mode = 0o750 | ||
| unless private? # allow group to edit shared projects | ||
| root_mode += (setgid ? 0o2020 : 0o020) | ||
| end | ||
| project_dataroot.chmod(root_mode) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the calls to |
||
| true | ||
| rescue StandardError => e | ||
| errors.add(:save, "Failed to update permissions of the directory: #{e.message}") | ||
| false | ||
|
|
||
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
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
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.
Instead of this addition can we just have a ternary like
mode = setgid ? 0o2750 : 0o750or similar?is 0o750 + 0o020 = 770? I think we want to keep 750 so collaborators can't just wipe the entire directory.
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.
My thinking was that it was necessary for collaborators to edit files by default. Now that I look into it I may have been mistaken
I am a bit confused on this. If we want people to have full write access to directory contents, how could we stop them from deleting things? And likewise if we make sure they don't have write access to
manifest.ymlfor example, then wouldn't that prevent anyrm -rdirectory wipe? I am happy though to lean on your intuition as I am a bit fresh to the mode system.My intention was to make new files inherit 770 by default, but I think that this has to be done by
umaskor some other approach. Open to guidance there as wellThere 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.
Sorry, seems like it was me who was confused. We do need 770 for shared projects. I thought that 750 would protect the directory itself, but it applies to children as well.
In any case, OK - 770 is what we want at least for shared projects. Can we account for shared projects here too and set private projects to 750?
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.
That is what the
unless private?conditional is for. If a project is privateroot_modeis unchanged from 750, otherwise it changes into 2770 or 0770There 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.
🤦♂️