Skip to content

Commit 7ab4f43

Browse files
authored
Merge pull request #1519 from tklauser/moar-unix
libcontainer: use additional functions and constants from x/sys/unix
2 parents 825b5c0 + 4019833 commit 7ab4f43

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

libcontainer/container_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,11 +1290,11 @@ func (c *linuxContainer) criuNotifications(resp *criurpc.CriuResp, process *Proc
12901290
}
12911291
}
12921292
case notify.GetScript() == "orphan-pts-master":
1293-
scm, err := syscall.ParseSocketControlMessage(oob)
1293+
scm, err := unix.ParseSocketControlMessage(oob)
12941294
if err != nil {
12951295
return err
12961296
}
1297-
fds, err := syscall.ParseUnixRights(&scm[0])
1297+
fds, err := unix.ParseUnixRights(&scm[0])
12981298

12991299
master := os.NewFile(uintptr(fds[0]), "orphan-pts-master")
13001300
defer master.Close()

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)