From 553016d7da3e10d69b8b3f6c2fa48a67cfbc12b1 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 7 Jun 2017 15:03:15 +0200 Subject: [PATCH] Use Prctl() from x/sys/unix instead of own wrapper Use unix.Prctl() instead of reimplemnting it as system.Prctl(). Signed-off-by: Tobias Klauser --- libcontainer/setns_init_linux.go | 4 +++- libcontainer/standard_init_linux.go | 2 +- libcontainer/system/linux.go | 10 +--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/libcontainer/setns_init_linux.go b/libcontainer/setns_init_linux.go index 48cc0ae0241..7ceed2bcccb 100644 --- a/libcontainer/setns_init_linux.go +++ b/libcontainer/setns_init_linux.go @@ -11,6 +11,8 @@ import ( "github.com/opencontainers/runc/libcontainer/seccomp" "github.com/opencontainers/runc/libcontainer/system" "github.com/opencontainers/selinux/go-selinux/label" + + "golang.org/x/sys/unix" ) // linuxSetnsInit performs the container's initialization for running a new process @@ -41,7 +43,7 @@ func (l *linuxSetnsInit) Init() error { } } if l.config.NoNewPrivileges { - if err := system.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil { + if err := unix.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil { return err } } diff --git a/libcontainer/standard_init_linux.go b/libcontainer/standard_init_linux.go index 98c7ae6dc88..a0376035354 100644 --- a/libcontainer/standard_init_linux.go +++ b/libcontainer/standard_init_linux.go @@ -128,7 +128,7 @@ func (l *linuxStandardInit) Init() error { return err } if l.config.NoNewPrivileges { - if err := system.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil { + if err := unix.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil { return err } } diff --git a/libcontainer/system/linux.go b/libcontainer/system/linux.go index 2ef7915a78f..42e406652c3 100644 --- a/libcontainer/system/linux.go +++ b/libcontainer/system/linux.go @@ -133,13 +133,5 @@ func RunningInUserNS() bool { // SetSubreaper sets the value i as the subreaper setting for the calling process func SetSubreaper(i int) error { - return Prctl(PR_SET_CHILD_SUBREAPER, uintptr(i), 0, 0, 0) -} - -func Prctl(option int, arg2, arg3, arg4, arg5 uintptr) (err error) { - _, _, e1 := unix.Syscall6(unix.SYS_PRCTL, uintptr(option), arg2, arg3, arg4, arg5, 0) - if e1 != 0 { - err = e1 - } - return + return unix.Prctl(PR_SET_CHILD_SUBREAPER, uintptr(i), 0, 0, 0) }