Fix working with read-only /dev#3345
Merged
mrunalp merged 3 commits intoopencontainers:masterfrom Jan 25, 2022
Merged
Conversation
Use os/file Chown method instead of bare unix.Fchown as it already have access to underlying fd, and produces nice-looking errors. This allows us to remove our error wrapping and some linter annotations. We still use unix.Fstat since os.Stat access to os-specific fields like uid/gid is not very straightforward. The only change here is to use file name (rather than fd) in the error text. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Since we already called fstat, we know the current file uid. In case it is the same as the one we want it to be, there's no point in trying chown. Remove the specific /dev/null check, as the above also covers it (comparing /dev/null uid with itself is true). This also fixes runc exec with read-only /dev for root user. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
In case of a read-only /dev, it's better to move on and let whatever is run in a container to handle any possible errors. This solves runc exec for a user with read-only /dev. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Contributor
Author
|
I guess I could add some integration tests, but this is pretty straightforward. |
Contributor
|
LGTM |
Contributor
|
@AkihiroSuda PTAL |
Contributor
|
@mrunalp PTAL |
Contributor
Author
|
Depending on podman release plans, we may need to have 1.1.1 released with the backport of this one. |
mrunalp
approved these changes
Jan 25, 2022
Contributor
Author
|
It looks like we need to release 1.1.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: do not chown
/dev/std{in,out,err}if there's no need; ignore EROFS when chown fails.For the context, see containers/podman#12954
Please review commit-by-commit.