Skip to content

Commit 553016d

Browse files
committed
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 <[email protected]>
1 parent 9d6821d commit 553016d

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

libcontainer/setns_init_linux.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/opencontainers/runc/libcontainer/seccomp"
1212
"github.com/opencontainers/runc/libcontainer/system"
1313
"github.com/opencontainers/selinux/go-selinux/label"
14+
15+
"golang.org/x/sys/unix"
1416
)
1517

1618
// linuxSetnsInit performs the container's initialization for running a new process
@@ -41,7 +43,7 @@ func (l *linuxSetnsInit) Init() error {
4143
}
4244
}
4345
if l.config.NoNewPrivileges {
44-
if err := system.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
46+
if err := unix.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
4547
return err
4648
}
4749
}

libcontainer/standard_init_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (l *linuxStandardInit) Init() error {
128128
return err
129129
}
130130
if l.config.NoNewPrivileges {
131-
if err := system.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
131+
if err := unix.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
132132
return err
133133
}
134134
}

libcontainer/system/linux.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,5 @@ func RunningInUserNS() bool {
133133

134134
// SetSubreaper sets the value i as the subreaper setting for the calling process
135135
func SetSubreaper(i int) error {
136-
return Prctl(PR_SET_CHILD_SUBREAPER, uintptr(i), 0, 0, 0)
137-
}
138-
139-
func Prctl(option int, arg2, arg3, arg4, arg5 uintptr) (err error) {
140-
_, _, e1 := unix.Syscall6(unix.SYS_PRCTL, uintptr(option), arg2, arg3, arg4, arg5, 0)
141-
if e1 != 0 {
142-
err = e1
143-
}
144-
return
136+
return unix.Prctl(PR_SET_CHILD_SUBREAPER, uintptr(i), 0, 0, 0)
145137
}

0 commit comments

Comments
 (0)