-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix some file mode bits missing when doing mount syscall #3956
Conversation
824a5be
to
aecd6da
Compare
aecd6da
to
ddf97e0
Compare
ddf97e0
to
e80fd2a
Compare
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
libcontainer/mount_linux.go
Outdated
"strconv" | ||
"syscall" |
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.
(Nit: I prefer using unix for everything but it doesn't really matter.)
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.
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.
libcontainer/mount_linux.go
Outdated
@@ -103,3 +105,19 @@ func unmount(target string, flags int) error { | |||
} | |||
return nil | |||
} | |||
|
|||
// SyscallMode returns the syscall-specific mode bits from Go's portable mode bits. | |||
func SyscallMode(i fs.FileMode) (o uint32) { |
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.
Yeah, golang stdlib does the same conversion in archive/tar and archive/zip.
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) { | ||
// syscallMode returns the syscall-specific mode bits from Go's portable mode bits. | ||
func syscallMode(i fs.FileMode) (o uint32) { |
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 you merge this hunk into the first commit?
libcontainer/rootfs_linux.go
Outdated
dt := fmt.Sprintf("mode=%04o", SyscallMode(stat.Mode())) | ||
dt := fmt.Sprintf("mode=%04o", syscallMode(stat.Mode())) |
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.
same
@@ -77,6 +77,21 @@ function teardown() { | |||
[[ "${lines[0]}" == *'mydomainname'* ]] | |||
} | |||
|
|||
@test "runc run with tmpfs" { |
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.
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
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, thanks!
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>
Fix #3952
When we call
unix.Mount
, if we use file mode bits from the bits with the typefs.FileMode
directly, it will cause some bits missing.Please refer: https://github.com/golang/go/blob/83c4e533bcf71d86437a5aa9ffc9b5373208628c/src/os/file.go#L258-L265