-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Do not chown newly created volume sources #16782
Conversation
@containers/podman-maintainers PTAL |
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.
LGTM
@edsantiago PTAL
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan, vrothberg 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 |
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.
LGTM, @mheon PTAL
@@ -151,9 +151,6 @@ func (r *Runtime) newVolume(ctx context.Context, noCreatePluginVolume bool, opti | |||
if err := os.MkdirAll(volPathRoot, 0700); err != nil { | |||
return nil, fmt.Errorf("creating volume directory %q: %w", volPathRoot, err) | |||
} | |||
if err := idtools.SafeChown(volPathRoot, volume.config.UID, volume.config.GID); err != nil { |
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.
This isn't going to work, volume.config.UID
and volume.config.GID
are actual options that can be set during volume creation.
Should we stop defaulting them to the container's UID/GID instead, and make this happen if and only if they were deliberately set?
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 think the tests checks that case.
The problem was the higher level directories were being set incorrectly. We just want them to default to the users uid running podman.
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.
BTW, the answer is yes they should only be set if the user sets them. but not sure how that info can be recorded, I guess we could default the UID/GID to -1?
I was thinking about changing UID and GID to *int instead so we would have
a clear unset state, but negative integer works fine too.
…On Mon, Dec 12, 2022 at 3:30 PM Daniel J Walsh ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In libpod/runtime_volume_common.go
<#16782 (comment)>:
> @@ -151,9 +151,6 @@ func (r *Runtime) newVolume(ctx context.Context, noCreatePluginVolume bool, opti
if err := os.MkdirAll(volPathRoot, 0700); err != nil {
return nil, fmt.Errorf("creating volume directory %q: %w", volPathRoot, err)
}
- if err := idtools.SafeChown(volPathRoot, volume.config.UID, volume.config.GID); err != nil {
BTW, the answer is yes they should only be set if the user sets them. but
not sure how that info can be recorded, I guess we could default the
UID/GID to -1?
—
Reply to this email directly, view it on GitHub
<#16782 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3AOCDEARJGS5GNJVOBD3DWM6DO7ANCNFSM6AAAAAASXKKDYY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
686e37a
to
11cbb28
Compare
@mheon PTAL |
0c54ae9
to
d609f69
Compare
return os.Getuid(), gid | ||
case gid == -1: | ||
return uid, os.Getgid() | ||
} |
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.
Personal nit, YMMV.
In general, I've not been a fan of equality tests for -1. Can we convert these to uid > -1
or uid < 0
or some such?
@rhatdan tests are still being touchy. |
A friendly reminder that this PR had no activity for 30 days. |
When running containers with podman run --userns=keep-id --userns $UID:$GID -v test:/tmp/test ... The volumes directory ends up being owned by root within the user namespace, which is not root of the general namespace nor the users uid. If we just allow podman to create these directories with the same UID that is running podman, IE don't chown, they end up with the correct UID in all cases. The actual volume will be chowned to the UID of the container. Fixes: containers#16741 Signed-off-by: Daniel J Walsh <[email protected]>
Friendly ping, @rhatdan. I am going through open PRs and this one seems to have fallen off the radar. |
Yup. this one I think we really should have @mheon take over, since he understands this the best and I have little time to look into it. |
Going through old inactive PRs... |
When running containers with
podman run --userns=keep-id --userns $UID:$GID -v test:/tmp/test ...
The volumes directory ends up being owned by root within the user namespace, which is not root of the general namespace nor the users uid.
If we just allow podman to create these directories with the same UID that is running podman, IE don't chown, they end up with the correct UID in all cases.
The actual volume will be chowned to the UID of the container.
Fixes: #16741
Signed-off-by: Daniel J Walsh [email protected]
Does this PR introduce a user-facing change?