Add support for umask when exec container

Signed-off-by: WangXiaoSong <wang.xiaosong1@zte.com.cn>
This commit is contained in:
Wang-squirrel
2022-11-11 17:25:22 +08:00
committed by WangXiaoSong
parent 5a0642d6fd
commit 7b4c3fc111
2 changed files with 9 additions and 0 deletions

View File

@@ -59,6 +59,10 @@ func (l *linuxSetnsInit) Init() error {
return err
}
}
if l.config.Config.Umask != nil {
unix.Umask(int(*l.config.Config.Umask))
}
if err := selinux.SetExecLabel(l.config.ProcessLabel); err != nil {
return err
}

View File

@@ -21,4 +21,9 @@ function teardown() {
[ "$status" -eq 0 ]
# umask 63 decimal = umask 77 octal
[[ "${output}" == *"77"* ]]
runc exec test_busybox grep '^Umask:' "/proc/self/status"
[ "$status" -eq 0 ]
# umask 63 decimal = umask 77 octal
[[ "${output}" == *"77"* ]]
}