Skip to content

Commit

Permalink
add a test case about missing stricky bit
Browse files Browse the repository at this point in the history
Signed-off-by: lifubang <lifubang@acmcoder.com>
  • Loading branch information
lifubang committed Aug 2, 2023
1 parent 6a7f206 commit ddf97e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions libcontainer/mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ 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) {
// syscallMode returns the syscall-specific mode bits from Go's portable mode bits.
func syscallMode(i fs.FileMode) (o uint32) {
o |= uint32(i.Perm())
if i&fs.ModeSetuid != 0 {
o |= syscall.S_ISUID
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func mountToRootfs(c *mountConfig, m mountEntry) error {
return err
}
} else {
dt := fmt.Sprintf("mode=%04o", SyscallMode(stat.Mode()))
dt := fmt.Sprintf("mode=%04o", syscallMode(stat.Mode()))
if m.Data != "" {
dt = dt + "," + m.Data
}
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ function teardown() {
[[ "${lines[0]}" == *'mydomainname'* ]]
}

@test "runc run with tmpfs" {
requires root

mode=$(stat -c %A /tmp)
# shellcheck disable=SC2016
update_config '.process.args = ["sh", "-c", "stat -c %A /tmp"]'
update_config '.mounts += [{"destination": "/tmp", "type": "tmpfs", "source": "tmpfs", "options":["noexec","nosuid","nodev","rprivate"]}]'

runc run test_tmpfs
[ "$status" -eq 0 ]
[ "$output" = "$mode" ]
}

@test "runc run with tmpfs perms" {
# shellcheck disable=SC2016
update_config '.process.args = ["sh", "-c", "stat -c %a /tmp/test"]'
Expand Down

0 comments on commit ddf97e0

Please sign in to comment.