-
Notifications
You must be signed in to change notification settings - Fork 35
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
PodMounter: Add group read access to credentials if Pod is not root #388
base: main
Are you sure you want to change the base?
Conversation
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.
Left some small comments, but overall it looks good to me. Thanks @yerzhan7!
@@ -36,24 +36,28 @@ const targetDirPerm = fs.FileMode(0755) | |||
// This is mainly exposed for testing, in production platform-native function (`mountSyscallDefault`) will be used. | |||
type mountSyscall func(target string, args mountpoint.Args) (fd int, err error) | |||
|
|||
type fileGroupID func(path string) (gid uint32, err error) |
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.
Seems like this is only exposed for testing, and I feel like it would be cleaner if we just change the gid
of the parent directory in our tests to test different cases via os.Chown.
@@ -37,3 +45,18 @@ func ReplaceFile(destPath string, sourcePath string, perm fs.FileMode) error { | |||
|
|||
return nil | |||
} | |||
|
|||
// FileGroupID returns gid of the file or directory. | |||
func FileGroupID(path string) (gid uint32, err error) { |
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.
Since this is a public function, it would be nice to add some tests for this function in file_test.go
.
FileMode600 = fs.FileMode(0600) // User: read/write, Group: none, Others: none | ||
FileMode640 = fs.FileMode(0640) // User: read/write, Group: read-only, Others: none | ||
FileMode700 = fs.FileMode(0700) // User: full access, Group: none, Others: none | ||
FileMode750 = fs.FileMode(0750) // User: full access, Group: read/execute only, Others: none |
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 feel like it'd be nicer if we name these constants after their permissions, something like:
FileMode600 = fs.FileMode(0600) // User: read/write, Group: none, Others: none | |
FileMode640 = fs.FileMode(0640) // User: read/write, Group: read-only, Others: none | |
FileMode700 = fs.FileMode(0700) // User: full access, Group: none, Others: none | |
FileMode750 = fs.FileMode(0750) // User: full access, Group: read/execute only, Others: none | |
FileModeUserReadWrite = fs.FileMode(0600) // User: read/write, Group: none, Others: none | |
FileModeUserGroupReadWrite = fs.FileMode(0640) // User: read/write, Group: read-only, Others: none | |
FileModeUserFull = fs.FileMode(0700) // User: full access, Group: none, Others: none | |
FileModeUserFullGroupRead = fs.FileMode(0750) // User: full access, Group: read/execute only, Others: none |
Though, feel free to change them if you can come up with better names :)
Issue: #108
Description
fsGroup
security context is applied on Mountpoint Pod and it's not run as default root user (0
), then currently Mountpoint Pod fails to read credentials that are provided by CSI Driver Node Pod.CredentialDirPerm
andCredentialFilePerm
fields to credential'sProvideContext
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.