-
Notifications
You must be signed in to change notification settings - Fork 785
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 U volume flag to chown source volumes #2805
Add U volume flag to chown source volumes #2805
Conversation
@EduardoVega thanks for the PR. The tests don't look happy and it looks like you need to rebase. |
Need man page changes. |
7f43937
to
57e02d2
Compare
I have updated docs. |
@giuseppe PTAL |
LGTM once the comment with |
6b5dad7
to
99b1bef
Compare
A few doc nits and a rebase is needed. Otherwise LGTM |
6c8d217
to
f87e4cb
Compare
@EduardoVega thanks for the updates. Hover it looks like you need to rebase and beyond that, it looks like one of the tests flaked and the rebase will hopefully clear that too. |
f87e4cb
to
d28c98c
Compare
docs/buildah-bud.md
Outdated
@@ -622,7 +631,7 @@ Only the current container can use a private volume. | |||
|
|||
Note: | |||
|
|||
- The `O` flag is not allowed to be specified with the `Z` or `z` flags. Content mounted into the container is labeled with the private label. | |||
- The `O` flag is not allowed to be specified with the `Z`, `z` or `U` flags. Content mounted into the container is labeled with the private label. |
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.
Is there a reason to not allow Overlay options with the U Flag? In SELinux the kernel will prevent this. Might not be a good idea because it will trigger a copy-up, but it might be the case where content is intended to be used for the run of the container temporarily but not written to the host. Of course this would mean the chown would need to happen on each run of the container.
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.
Thanks. Let me work on this.
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.
Currently buildah will chown the source volume and then use the processUID and processGID to create the overlay temp dir, would this be the expected behaviour? Initially I tried to chown the overlay temp directory only, in the case of rootless containers the UID/GID were added correctly, but in the case of rootful containers the content of the source volume was never present on the overlay temp dir so the correct UID/GID were never added to sub dirs/files.
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.
If you chown the files after the volume is mounted, it should create new INODES in the upper directory with the correct ownership.
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.
It seems to work with rootless containers since the volume is mounted using fuse-overlayfs
here https://github.com/containers/buildah/blob/master/pkg/overlay/overlay.go#L64, but for containers created by root the overlay volume is mounted by crun using the native overlay type.
If I am not wrong there's no way to specify uid/gid as an option for overlay native mount type. The only way I can see this working is if the real source volume is chown just like volumes without the O flag. So the chown would be permanent but any other operation would be temporary.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: EduardoVega, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
40cdbb0
to
54d4857
Compare
54d4857
to
38b297d
Compare
@EduardoVega Please rebase to get past the ubuntu failures. |
Signed-off-by: Eduardo Vega <[email protected]>
38b297d
to
1f4e751
Compare
/lgtm |
What type of PR is this?
/kind feature
What this PR does / why we need it:
It adds the U volume flag to chown source volumes based on the uid, gid within the container.
When a new container is created with a user namespace, we want to get the uid,gid that has been assigned outside the container to chown source volumes. This will isolate the filesystem (source volumes) from other containers (users, groups) since they will be owned by the same user and group within the container.
This is required by podman, so it can parse the U volume flag.
Podman Issue: 7778
How to verify it
There is an integration test to validate this functionality.
Example:
Which issue(s) this PR fixes:
None
Special notes for your reviewer:
Does this PR introduce a user-facing change?
None
Signed-off-by: Eduardo Vega [email protected]