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

podman cp: unexpected mkdir on symlink expansion #3894

Closed
edsantiago opened this issue Aug 27, 2019 · 4 comments · Fixed by #4101
Closed

podman cp: unexpected mkdir on symlink expansion #3894

edsantiago opened this issue Aug 27, 2019 · 4 comments · Fixed by #4101
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@edsantiago
Copy link
Collaborator

podman cp into a container, when the destination argument is a symlink pointing to a nonexistent path, and includes a trailing slash, will (surprisingly) mkdir that path:

# podman run -d --name cpc alpine sh -c 'sleep 999'
2c216ec654f5062d444d600f4dfabace3b01418b518fecafa5ba3e4074127655

! Create three tmp directories, d1 d2 d3, the first two with 
! a symlink 'x' pointing nowhere
# podman exec cpc sh -c 'mkdir /tmp/d1;ln -s /tmp/nonesuch1 /tmp/d1/x'
# podman exec cpc sh -c 'mkdir /tmp/d2;ln -s /tmp/nonesuch2 /tmp/d2/x'
# podman exec cpc sh -c 'mkdir /tmp/d3'
# podman exec cpc ls -lR /tmp
/tmp:
total 24
drwxr-xr-x    2 root     root          4096 Aug 27 19:35 d1
drwxr-xr-x    2 root     root          4096 Aug 27 19:35 d2
drwxr-xr-x    2 root     root          4096 Aug 27 19:35 d3

/tmp/d1:
total 0
lrwxrwxrwx    1 root     root            14 Aug 27 19:35 x -> /tmp/nonesuch1

/tmp/d2:
total 0
lrwxrwxrwx    1 root     root            14 Aug 27 19:35 x -> /tmp/nonesuch2

/tmp/d3:
total 0

! Create a file and copy it into the container in three different ways
# echo hi >/tmp/myfile
# podman cp /tmp/myfile cpc:/tmp/d1/x
# podman cp /tmp/myfile cpc:/tmp/d2/x/     <<<<---- note trailing slash!
# podman cp /tmp/myfile cpc:/tmp/d3/x
# podman exec cpc ls -lR /tmp
/tmp:
total 36
drwxr-xr-x    2 root     root          4096 Aug 27 19:35 d1
drwxr-xr-x    2 root     root          4096 Aug 27 19:35 d2
drwxr-xr-x    2 root     root          4096 Aug 27 19:36 d3
-rw-r--r--    1 root     root             3 Aug 27 19:36 nonesuch1    <<<<< weird
drwxr-xr-x    2 root     root          4096 Aug 27 19:36 nonesuch2    <<<<< weirder

/tmp/d1:
total 0
lrwxrwxrwx    1 root     root            14 Aug 27 19:35 x -> /tmp/nonesuch1

/tmp/d2:
total 0
lrwxrwxrwx    1 root     root            14 Aug 27 19:35 x -> /tmp/nonesuch2

/tmp/d3:
total 4
-rw-r--r--    1 root     root             3 Aug 27 19:36 x

/tmp/nonesuch2:
total 4
-rw-r--r--    1 root     root             3 Aug 27 19:36 myfile

When copying to /tmp/d1/x, where x points to nonexistent /tmp/nonesuch1, podman created the file /tmp/nonesuch1. This is weird: I would've expected an error (dangling symlink). But this is the same behavior as docker-1.13.1-103.git7f2769b.el7, so maybe we have to live with it.

When copying to /tmp/d2/x/, same as above but with a trailing slash, podman actually mkdir()s the dangling nonexistent directory, then places the file in that directory with the same name as the source file. This, I think, is bizarre and entirely wrong. (docker fails with 'no such directory').

podman master @ f221c61

@mheon
Copy link
Member

mheon commented Aug 28, 2019

While this definitely sounds like a bug - can you confirm that Docker doesn't do this? It seems like a sufficiently obscure case that I'm honestly not sure what the right thing to do it...

@mheon mheon added the kind/bug Categorizes issue or PR as related to a bug. label Aug 28, 2019
@edsantiago
Copy link
Collaborator Author

I confirmed it yesterday with docker-1.13.1-103.git7f2769b.el7: fails with 'no such directory'

@mheon
Copy link
Member

mheon commented Aug 28, 2019

Alright, that's our intended behavior, then
@QiWang19 PTAL

@TomSweeneyRedHat
Copy link
Member

@QiWang19 as a note, the test that @edsantiago recently put in will most likely fail after you correct this and you will need to adjust it to mirror the correct behavior.

@QiWang19 QiWang19 self-assigned this Sep 24, 2019
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 24, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 24, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 24, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 24, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 24, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 24, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 25, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
QiWang19 added a commit to QiWang19/podman that referenced this issue Sep 25, 2019
close containers#3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
edsantiago added a commit to edsantiago/libpod that referenced this issue Apr 18, 2022
This is an always-open PR used for simplifying the
buildah merge process.

Changes as of 2022-04-18:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with buildah containers#3894 (the registry one),
  which affected helpers.bash

Signed-off-by: Ed Santiago <santiago@redhat.com>
edsantiago added a commit to edsantiago/libpod that referenced this issue Apr 21, 2022
This is an always-open PR used for simplifying the
buildah merge process.

Changes as of 2022-04-18:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with buildah containers#3894 (the registry one),
  which affected helpers.bash

Signed-off-by: Ed Santiago <santiago@redhat.com>
edsantiago added a commit to edsantiago/libpod that referenced this issue Apr 21, 2022
This is an always-open PR used for simplifying the
buildah merge process.

Changes as of 2022-04-18:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with buildah containers#3894 (the registry one),
  which affected helpers.bash

Signed-off-by: Ed Santiago <santiago@redhat.com>
edsantiago added a commit to edsantiago/libpod that referenced this issue Apr 21, 2022
This is an always-open PR used for simplifying the
buildah merge process.

Changes as of 2022-04-21:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with:
  . buildah containers#3894 (the registry one), which affected helpers.bash in
    a way that resulted in conflicts here; and
  . buildah containers#3917 (etchosts), which caused offset-only diffs
    with no conflicts
- Reevaluate the bud skip list, and reenable some tests that
  seems to be passing now under podman:
  . bud with specified context ...
  . two tests that require a local registry (which buildah now runs)
  . bud with --cgroup-parent

Signed-off-by: Ed Santiago <santiago@redhat.com>

fixmeup

Signed-off-by: Ed Santiago <santiago@redhat.com>
edsantiago added a commit to edsantiago/libpod that referenced this issue Apr 22, 2022
This is an always-open PR used for simplifying the
buildah merge process.

Changes as of 2022-04-21:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with:
  . buildah containers#3894 (the registry one), which affected helpers.bash in
    a way that resulted in conflicts here; and
  . buildah containers#3917 (etchosts), which caused offset-only diffs
    with no conflicts
- Reevaluate the bud skip list, and reenable some tests that
  seems to be passing now under podman:
  . bud with specified context ...
  . two tests that require a local registry (which buildah now runs)
  . bud with --cgroup-parent

Signed-off-by: Ed Santiago <santiago@redhat.com>

fixmeup

Signed-off-by: Ed Santiago <santiago@redhat.com>
edsantiago added a commit to edsantiago/libpod that referenced this issue Apr 25, 2022
This is an always-open PR used for simplifying the
buildah merge process.

Changes as of 2022-04-21:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with:
  . buildah containers#3894 (the registry one), which affected helpers.bash in
    a way that resulted in conflicts here; and
  . buildah containers#3917 (etchosts), which caused offset-only diffs
    with no conflicts
- Reevaluate the bud skip list, and reenable some tests that
  seems to be passing now under podman:
  . bud with specified context ...
  . two tests that require a local registry (which buildah now runs)
  . bud with --cgroup-parent

Signed-off-by: Ed Santiago <santiago@redhat.com>

fixmeup

Signed-off-by: Ed Santiago <santiago@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Apr 25, 2022
Changes as of 2022-04-21:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with:
  . buildah containers#3894 (the registry one), which affected helpers.bash in
    a way that resulted in conflicts here; and
  . buildah containers#3917 (etchosts), which caused offset-only diffs
    with no conflicts
- Reevaluate the bud skip list, and reenable some tests that
  seems to be passing now under podman:
  . bud with specified context ...
  . two tests that require a local registry (which buildah now runs)
  . bud with --cgroup-parent

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Apr 26, 2022
Changes as of 2022-04-21:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with:
  . buildah containers#3894 (the registry one), which affected helpers.bash in
    a way that resulted in conflicts here; and
  . buildah containers#3917 (etchosts), which caused offset-only diffs
    with no conflicts
- Reevaluate the bud skip list, and reenable some tests that
  seems to be passing now under podman:
  . bud with specified context ...
  . two tests that require a local registry (which buildah now runs)
  . bud with --cgroup-parent

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan added a commit to rhatdan/podman that referenced this issue Apr 26, 2022
Changes as of 2022-04-21:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with:
  . buildah containers#3894 (the registry one), which affected helpers.bash in
    a way that resulted in conflicts here; and
  . buildah containers#3917 (etchosts), which caused offset-only diffs
    with no conflicts
- Reevaluate the bud skip list, and reenable some tests that
  seems to be passing now under podman:
  . bud with specified context ...
  . two tests that require a local registry (which buildah now runs)
  . bud with --cgroup-parent

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
gbraad pushed a commit to gbraad-redhat/podman that referenced this issue Jul 13, 2022
Changes as of 2022-04-21:

- apply-podman-deltas: minor cleanup
- buildah-tests.diff: deal with:
  . buildah containers#3894 (the registry one), which affected helpers.bash in
    a way that resulted in conflicts here; and
  . buildah containers#3917 (etchosts), which caused offset-only diffs
    with no conflicts
- Reevaluate the bud skip list, and reenable some tests that
  seems to be passing now under podman:
  . bud with specified context ...
  . two tests that require a local registry (which buildah now runs)
  . bud with --cgroup-parent

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants