aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_linux.go
diff options
context:
space:
mode:
authorJess Frazelle <me@jessfraz.com>2016-05-18 18:47:24 -0700
committerIan Lance Taylor <iant@golang.org>2016-05-20 00:51:46 +0000
commit8527b8ef9b00c72b1a8e30e5917c7bdd3c0e79ef (patch)
tree7f1e74c5edb6ba063e80f27696de7b2a274f225f /src/syscall/exec_linux.go
parent448246adff7feb868d66cfde82b36fcfd0e66b75 (diff)
downloadgo-8527b8ef9b00c72b1a8e30e5917c7bdd3c0e79ef.tar.xz
syscall: add Unshare flags to SysProcAttr on Linux
This patch adds Unshare flags to SysProcAttr for Linux systems. Fixes #1954 Change-Id: Id819c3f92b1474e5a06dd8d55f89d74a43eb770c Reviewed-on: https://go-review.googlesource.com/23233 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/syscall/exec_linux.go')
-rw-r--r--src/syscall/exec_linux.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go
index e49bad75b2..5a6b204997 100644
--- a/src/syscall/exec_linux.go
+++ b/src/syscall/exec_linux.go
@@ -32,6 +32,7 @@ type SysProcAttr struct {
Pgid int // Child's process group ID if Setpgid.
Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only)
Cloneflags uintptr // Flags for clone calls (Linux only)
+ Unshare uintptr // Flags for unshare calls (Linux only)
UidMappings []SysProcIDMap // User ID mappings for user namespaces.
GidMappings []SysProcIDMap // Group ID mappings for user namespaces.
// GidMappingsEnableSetgroups enabling setgroups syscall.
@@ -194,6 +195,14 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
}
}
+ // Unshare
+ if sys.Unshare != 0 {
+ _, _, err1 = RawSyscall(SYS_UNSHARE, sys.Unshare, 0, 0)
+ if err1 != 0 {
+ goto childerror
+ }
+ }
+
// User and groups
if cred := sys.Credential; cred != nil {
ngroups := uintptr(len(cred.Groups))