-
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
Only open save output file with WRONLY #12408
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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 |
@vrothberg @mtrmac @xandris 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.
No, it’s the Create
above that needs to be changed AFAICS.
(changing that Open(
, which is only used to read data for, O_WRONLY
can’t work anyway, AFAICS.)
Please have someone with a working Podman on Mac to test this, as well…
@mtrmac Better. |
Yes, this is what I think is going wrong and how to fix it, but please wait for a confirmation from someone who has Podman remote actually set up. |
I think this is only podman on a MAC too, correct. I could not get this to fail on Linux. |
It might be possible to reproduce on Linux using something like touch output;
chmod 0200 output # u=w,u-r
podman save $other-args -o output # Must be podman-remote! where the podman/cmd/podman/images/save.go Line 115 in 7324d94
|
Works for me. I checked out this branch, built it, and ran it on my Mac, comparing the behavior to the Homebrew-installed version:
|
@@ -270,7 +270,7 @@ func (ir *ImageEngine) Save(ctx context.Context, nameOrID string, tags []string, | |||
defer func() { _ = os.Remove(f.Name()) }() | |||
} | |||
default: | |||
f, err = os.Create(opts.Output) | |||
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) |
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.
Can we add a comment here that this mode is important.
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.
Sure, could you explain to me why? Or what should be in the comment?
default:
// This code was added to allow for opening stdout use on MAC. The mode 0644 is important.
f, err = os.OpenFile(opts.Output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
}
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 mean the flags os.O_WRONLY. If someone has to rework this they might not think about it and change it back to os.Create() for example.
Maybe adding a link to the issue would help
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.
Ok, I will write that.
The previous code fails on a MAC when opening /dev/stdout Fixes: containers#12402 [NO NEW TESTS NEEDED] No easy way to test this. Signed-off-by: Daniel J Walsh <[email protected]>
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, nice work!
/lgtm |
The previous code fails on a MAC when opening /dev/stdout
Fixes: #12402
[NO NEW TESTS NEEDED] No easy way to test this.
Signed-off-by: Daniel J Walsh [email protected]
What this PR does / why we need it:
How to verify it
Which issue(s) this PR fixes:
Special notes for your reviewer: