Skip to content

Commit 4019833

Browse files
committed
libcontainer: use PR_SET_NO_NEW_PRIVS from x/sys/unix
Use PR_SET_NO_NEW_PRIVS defined in golang.org/x/sys/unix instead of manually defining it. Signed-off-by: Tobias Klauser <[email protected]>
1 parent 54d27be commit 4019833

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

libcontainer/setns_init_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (l *linuxSetnsInit) Init() error {
4343
}
4444
}
4545
if l.config.NoNewPrivileges {
46-
if err := unix.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
46+
if err := unix.Prctl(unix.PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
4747
return err
4848
}
4949
}

libcontainer/standard_init_linux.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ func (l *linuxStandardInit) getSessionRingParams() (string, uint32, uint32) {
4242
return fmt.Sprintf("_ses.%s", l.config.ContainerId), 0xffffffff, newperms
4343
}
4444

45-
// PR_SET_NO_NEW_PRIVS isn't exposed in Golang so we define it ourselves copying the value
46-
// the kernel
47-
const PR_SET_NO_NEW_PRIVS = 0x26
48-
4945
func (l *linuxStandardInit) Init() error {
5046
if !l.config.Config.NoNewKeyring {
5147
ringname, keepperms, newperms := l.getSessionRingParams()
@@ -128,7 +124,7 @@ func (l *linuxStandardInit) Init() error {
128124
return err
129125
}
130126
if l.config.NoNewPrivileges {
131-
if err := unix.Prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
127+
if err := unix.Prctl(unix.PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); err != nil {
132128
return err
133129
}
134130
}

0 commit comments

Comments
 (0)