-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
podman copy files to the volume with a container #3094
Conversation
This does not fully solve the problem as it was written. It works for named volumes only, and not directories bind-mounted in via |
hm, 👀 will check that |
docker cp doesn't work for tmpfs. |
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 am very worried about the path logic here - I'm looking, and I don't think it holds up for any nontrivial path.
You might want to look into whether there are libraries that can do advanced manipulation like this, matching and trimming path prefixes.
cmd/podman/cp.go
Outdated
if path == "" { | ||
return false, specs.Mount{} | ||
} | ||
path = strings.Split(path, separator)[0] |
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.
Wait, how does this work? We split the original path on separators, then we compare it against the entire path of the volume (minus leading slash)? This doesn't seem like it makes sense.
Say I have two volumes, /tmp/test/a
and /tmp/test/b
, and I want to copy into /tmp/test/b
- what's to prevent this from matching /tmp/test/a
here?
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.
@mheon, changed the path match logic func matchVolumePath(path, target string) bool
, PTAL
return false, specs.Mount{} | ||
} | ||
path = strings.Split(path, separator)[0] | ||
for _, m := range ctr.Config().Spec.Mounts { |
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.
You also need to check if the mount is actually a bind mount
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.
m.Type == "bind"
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.
fixed
d66237e
to
e4fdaee
Compare
return false, specs.Mount{} | ||
} | ||
|
||
func matchVolumePath(path, target string) bool { |
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.
You probably want to do a path.Clean() on both paths first
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.
fixed. PTAL @mheon
1cfd775
to
b7d0dce
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mheon, QiWang19 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 |
LGTM |
LGTM, would like to get a @mheon head nod. |
Hold this until the CVE fix lands |
I need to re-review once the CVE is fixed to make sure we don't regress |
☔ The latest upstream changes (presumably #3214) made this pull request unmergeable. Please resolve the merge conflicts. |
CVE fix is landed. Rebase and we can re-review |
@mheon PTAL |
@QiWang19 Mind rebasing to fix CI? |
enabls podman to cpoy files between the host machine and the volume related with a container. Close containers#3059 Signed-off-by: Qi Wang <[email protected]>
@mheon I think this is ready to go in? |
/lgtm |
Close #3059
enabls podman to copy files between the host machine and the volume related to a container.
Signed-off-by: Qi Wang [email protected]