pkg/archive: adjust permissions for parent directories#44140
pkg/archive: adjust permissions for parent directories#44140vasiliy-ul wants to merge 1 commit intomoby:masterfrom
Conversation
|
The failure does not seem related to the change in this PR: Flaky test? |
|
Looks to be one of the BuildKit integration tests; https://github.com/moby/buildkit/blob/8e2d9b9006caadb74c1745608889a37ba139acc1/client/build_test.go#L1624-L1626 /cc @crazy-max FWIW; we're still pinning the tests to a specific commit for those integration tests, so it's possible fixes have been merged in BuildKit after that; moby/.github/workflows/buildkit.yml Line 80 in 3946173 |
|
@cpuguy83 @tonistiigi PTAL; perhaps one of you knows if there was a specific reason for picking these permissions; also see #44106 (comment), where I did some initial digging. |
|
For posterity; we discussed this in the maintainers meeting; so the reason these permissions are applies is that the image itself has no metadata for the parent directories. In that case, docker falls back to creating the parent paths with some default permissions. For overlay, we hit a different code-path, with similar code, but different default permissions (which coincidentally were updated some time ago in #42016); Lines 1056 to 1069 in c5c3568 From a consistency perspective, it makes sense to align those permissions (which is what this PR does), but we should consider formalising the behaviour (and permissions) in the OCI specification. |
|
|
||
| if _, err := os.Lstat(parentPath); err != nil && os.IsNotExist(err) { | ||
| err = system.MkdirAll(parentPath, 0600) | ||
| err = system.MkdirAll(parentPath, 0755) |
There was a problem hiding this comment.
Discussing further with @neersighted @corhere ; we may want to factor out this block, and also apply ownership (same as we do for overlay)), so that ownership is also consistent (may be important for rootless).
There was a problem hiding this comment.
Updated the ownership. Should be the same as for overlay now.
Use 0755 by default if the tar archive does not explicitly provide the mode settings for parent directories. This change makes the permissions and ownership of the resulting directory aligned with the implementation of the Upack function from pkg/archive/archive.go. Previously this was causing inconsistencies: depending on the configured graphdriver some directories were created with 0600 access bits. Signed-off-by: Vasiliy Ulyanov <[email protected]>
e961014 to
dbc0756
Compare
And meanwhile, what about this fix? Does it make sense to make the permissions consistent across various drivers for now? Also, is it smth I can help with? Just not familiar with the process... |
|
Hi @vasiliy-ul -- we discussed the correct behavior here extensively and came to the conclusion that we knew what we wanted the code to look like, and that it would be easier to just have someone present in the discussion write it than to try and communicate that through prose through multiple cycles. I'll try to have a successor PR up tomorrow, including your changes, but adding a regression test and some other refinements (e.g. hoisting out this common code shared with Regarding the OCI spec, I'll summarize the discussion on the linked issue. It's not going to stop us from changing things in Moby to be more consistent, but it's also an important for anyone coming across this work later to understand that this is currently implementation defined, and thus by definition whatever Moby does is correct. While |
|
Alternative implementation (with the code extracted to a function) is up in #44196 I see @neersighted added @vasiliy-ul as Co-Author (thanks!), so I marked that one as "supersedes" and "closes" this one. |
Use 0755 by default if the tar archive does not explicitly provide the mode settings for parent directories.
This change makes the resulting directory permissions aligned with the implementation of the Upack function from pkg/archive/archive.go. Previously this was causing inconsistencies: depending on the configured graphdriver some directories were created with 0600 access bits.
Fixes #44106
- What I did
Changed the default permissions for parent directories in the
UnpackLayerfunction:0600->0755.For reference:
archive.Unpackalready sets the mode to0755.- How I did it
- How to verify it
- Description for the changelog
The default access mode for unpacked directories is now set to 0755
- A picture of a cute animal (not mandatory but encouraged)