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-remote run --cidfile results in files deleted on container host #21974

Open
allisonkarlitskaya opened this issue Mar 7, 2024 · 6 comments · May be fixed by #23155
Open

podman-remote run --cidfile results in files deleted on container host #21974

allisonkarlitskaya opened this issue Mar 7, 2024 · 6 comments · May be fixed by #23155
Assignees
Labels
jira kind/bug Categorizes issue or PR as related to a bug. stale-issue

Comments

@allisonkarlitskaya
Copy link

allisonkarlitskaya commented Mar 7, 2024

Issue Description

podman-remote has some understandable restrictions with respect to handling of --cidfile. In particular, we can't expect that the cidfile gets properly cleaned up on container exit in all cases, since there's nothing around to delete it.

Unfortunately, podman running on the container host will delete an different file (with the same name), if it is present.

Consider a typical toolbox setup where /var/tmp is different inside and outside of the toolbox. If you do podman-remote run --cidfile /var/tmp/cidfile inside of the toolbox then podman will erase /var/tmp/cidfile on the host system when the container exits.

I think this is probably because the path of the cidfile gets transmitted from podman-remote to podman on the container host, where podman accidentally interprets it as a local path. Transmitting the filename in the first place is never appropriate since this filename is meaningless on the container host, and the container host should also ensure that it rejects the filename (if it is transmitted) for the same reason.

Steps to reproduce the issue

Here's a small example session that reproduces the issue. I have two terminal windows open and go between running commands on the host and inside of the toolbox. The order of things shown here is the chronological order in which the commands were run.

Again: key to this example is that /var/tmp is different on the host and in the toolbox.

Create a file that's only visible on the host:

host$ echo 'IMPORTANT DATA' > /var/tmp/cidfile
host$ cat /var/tmp/cidfile
IMPORTANT DATA

This file is not visible inside of toolbox.

toolbox$ cat /var/tmp/cidfile
cat: /var/tmp/cidfile: No such file or directory

Then in the toolbox we start a container with a cidfile on the same name, but this is a different file, since /var/tmp is different:

toolbox$ podman-remote run --cidfile /var/tmp/cidfile fedora:latest true
toolbox$ cat /var/tmp/cidfile
2f8b3066a42d74b3278b732b336b4e7c9993c74d411a1d2f24a5badb8ecc1d92

Of course, on the host, our file is still present, in its original form.

host$ cat /var/tmp/cidfile
IMPORTANT DATA

Back in the toolbox, time to get rid of our container. We're not surprised that the cidfile doesn't get erased, since this is podman-remote:

toolbox$ podman-remote rm --cidfile /var/tmp/cidfile
2f8b3066a42d74b3278b732b336b4e7c9993c74d411a1d2f24a5badb8ecc1d92
toolbox$ cat /var/tmp/cidfile  # still there!
2f8b3066a42d74b3278b732b336b4e7c9993c74d411a1d2f24a5badb8ecc1d92

But back on the host, our IMPORTANT DATA is gone.

host$ cat /var/tmp/cidfile
cat: /var/tmp/cidfile: No such file or directory

Describe the results you received

A file was inappropriately deleted on the container host and the cidfile remained present where podman-remote was running.

Describe the results you expected

I expected no files to be deleted.

podman info output

Both podman and podman-remote are from Fedora 39, version 4.9.3.

Podman in a container

Yes

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

This is a normal toolbox environment on Fedora Silverblue 39.

Additional information

No response

@allisonkarlitskaya allisonkarlitskaya added the kind/bug Categorizes issue or PR as related to a bug. label Mar 7, 2024
@giuseppe
Copy link
Member

giuseppe commented Mar 8, 2024

I agree --cidfile doesn't seem to make sense with podman-remote, we should probably hide it.

@Luap99
Copy link
Member

Luap99 commented Mar 8, 2024

cidfile is fine, it is just that the server should never touch it as it is a client thing. It should never be send over the API.

@allisonkarlitskaya
Copy link
Author

For the record, we use and need podman-remote run --cidfile. Please don't remove it. :)

@rhatdan
Copy link
Member

rhatdan commented Mar 8, 2024

Agree cidfile makes sense on remote.

@giuseppe
Copy link
Member

giuseppe commented Mar 8, 2024

yeah I got confused with pidfile. The cid makes sense

Copy link

github-actions bot commented Apr 8, 2024

A friendly reminder that this issue had no activity for 30 days.

@mheon mheon added the jira label May 22, 2024
inknos added a commit to inknos/podman that referenced this issue Jul 1, 2024
Cidfile location should not be passed over on a remote connection. This
way you will not mess the host configuraion on container removal.

Resolves: containers#21974

Signed-off-by: Nicola Sella <nsella@redhat.com>
@inknos inknos linked a pull request Jul 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira kind/bug Categorizes issue or PR as related to a bug. stale-issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants