Fix some file mode bits missing when doing mount syscall#3956
Merged
kolyshkin merged 2 commits intoopencontainers:mainfrom Aug 3, 2023
Merged
Fix some file mode bits missing when doing mount syscall#3956kolyshkin merged 2 commits intoopencontainers:mainfrom
kolyshkin merged 2 commits intoopencontainers:mainfrom
Conversation
824a5be to
aecd6da
Compare
Member
Author
aecd6da to
ddf97e0
Compare
cyphar
reviewed
Aug 2, 2023
ddf97e0 to
e80fd2a
Compare
cyphar
reviewed
Aug 2, 2023
libcontainer/mount_linux.go
Outdated
| import ( | ||
| "io/fs" | ||
| "strconv" | ||
| "syscall" |
Member
There was a problem hiding this comment.
(Nit: I prefer using unix for everything but it doesn't really matter.)
Contributor
There was a problem hiding this comment.
Same -- I think with Go2 there will be no syscall and we'll have to switch to x/sys/unix anyway, so better do it now.
kolyshkin
reviewed
Aug 2, 2023
libcontainer/mount_linux.go
Outdated
| } | ||
|
|
||
| // SyscallMode returns the syscall-specific mode bits from Go's portable mode bits. | ||
| func SyscallMode(i fs.FileMode) (o uint32) { |
Contributor
There was a problem hiding this comment.
Yeah, golang stdlib does the same conversion in archive/tar and archive/zip.
kolyshkin
reviewed
Aug 2, 2023
libcontainer/mount_linux.go
Outdated
Comment on lines
+109
to
+110
| // SyscallMode returns the syscall-specific mode bits from Go's portable mode bits. | ||
| func SyscallMode(i fs.FileMode) (o uint32) { | ||
| // syscallMode returns the syscall-specific mode bits from Go's portable mode bits. | ||
| func syscallMode(i fs.FileMode) (o uint32) { |
Contributor
There was a problem hiding this comment.
Can you merge this hunk into the first commit?
kolyshkin
reviewed
Aug 2, 2023
libcontainer/rootfs_linux.go
Outdated
| } | ||
| } else { | ||
| dt := fmt.Sprintf("mode=%04o", SyscallMode(stat.Mode())) | ||
| dt := fmt.Sprintf("mode=%04o", syscallMode(stat.Mode())) |
kolyshkin
reviewed
Aug 2, 2023
| [[ "${lines[0]}" == *'mydomainname'* ]] | ||
| } | ||
|
|
||
| @test "runc run with tmpfs" { |
Contributor
There was a problem hiding this comment.
nit: maybe add a link to issue, e.g.
# https://github.com/opencontainers/runc/issues/3952
@test "runc run with tmpfs" {
...e80fd2a to
88f84f7
Compare
Signed-off-by: lifubang <lifubang@acmcoder.com>
88f84f7 to
b7290e5
Compare
Signed-off-by: lifubang <lifubang@acmcoder.com>
b7290e5 to
83137c6
Compare
kolyshkin
referenced
this pull request
Aug 10, 2023
When a directory already exists (or after a container is restarted) the perms of the directory being mounted to were being used even when a different permission is set on the tmpfs mount options. This prepends the original directory perms to the mount options. If the perms were already set in the mount opts then those perms will win. This eliminates the need to perform a chmod after mount entirely. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Merged
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.
Fix #3952
When we call
unix.Mount, if we use file mode bits from the bits with the typefs.FileModedirectly, it will cause some bits missing.Please refer: https://github.com/golang/go/blob/83c4e533bcf71d86437a5aa9ffc9b5373208628c/src/os/file.go#L258-L265