Skip to content
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

Add e2e permissions test #45

Merged
merged 2 commits into from
Nov 15, 2023
Merged

Add e2e permissions test #45

merged 2 commits into from
Nov 15, 2023

Conversation

vladem
Copy link
Contributor

@vladem vladem commented Nov 10, 2023

Description of changes:

  • test creates a non-root pod and verifies that it can access a volume

TODO: What we do not support is setting volume's group owner according to fsGroup option from pod security context:


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

jjkr
jjkr previously approved these changes Nov 10, 2023
Copy link
Contributor

@jjkr jjkr left a comment

Choose a reason for hiding this comment

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

Lgtm. Just had a couple questions for my own understanding.

pDriver, _ := config.Driver.(storageframework.PreprovisionedPVTestDriver)
r.Volume = pDriver.CreateVolume(ctx, config, storageframework.PreprovisionedPV)
pvSource, volumeNodeAffinity := pDriver.GetPersistentVolumeSource(false, "", r.Volume)
pv := &v1.PersistentVolume{
Copy link
Contributor

Choose a reason for hiding this comment

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

We talked about this a bit in standup, but is this (mounting a pv with options) significantly easier using the k8s library if we have more standard mount options? Do you know if many customers will do this programmatically?

Copy link
Contributor Author

@vladem vladem Nov 13, 2023

Choose a reason for hiding this comment

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

l.config = driver.PrepareTest(ctx, f)
ginkgo.DeferCleanup(cleanup)
})
ginkgo.It("should access volume as a non-root user", func(ctx context.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A negative test (non-root can't access without the allow-other flag) would be great as well. Fairly low priority though- we're more testing mountpoint functionality at that point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, added

ginkgo.DeferCleanup(cleanup)
})
ginkgo.It("should access volume as a non-root user", func(ctx context.Context) {
resource := createVolumeResourceWithMountOptions(ctx, l.config, pattern, []string{"uid=1000", "gid=2000", "allow-other"})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you actually need the uid/gid options? I think that will set ownership on the files right? But non-root should be still be able to access root owned files as long as you have allow-other (assuming file permissions are set appropriately. Not suggesting a change here, just trying to make sure I understand how all this works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haven't tested that yet, but interesting point; according to fuse and mountpoint documentation customer can use --file-mode and --dir-mode flags instead of --uid and --gid to keep files owned by the root, but make them accessible by other

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MP uses default_permissions mount flag, which delegates permissions checking to the kernel; it can be the case that some additional permission checking is done on top of that in MPs code

@@ -0,0 +1,50 @@
apiVersion: v1
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add documentation about this in our examples README?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

@dlakhaws dlakhaws merged commit ddd0753 into main Nov 15, 2023
@dlakhaws dlakhaws deleted the permissions-e2e branch November 15, 2023 18:12
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.

None yet

3 participants