Merge pull request #166 from gitido/fixes

Go1.5 compatibility fix
diff --git a/libcontainer/compat_1.5_linux.go b/libcontainer/compat_1.5_linux.go
new file mode 100644
index 0000000..c7bdf1f
--- /dev/null
+++ b/libcontainer/compat_1.5_linux.go
@@ -0,0 +1,10 @@
+// +build linux,!go1.5
+
+package libcontainer
+
+import "syscall"
+
+// GidMappingsEnableSetgroups was added in Go 1.5, so do nothing when building
+// with earlier versions
+func enableSetgroups(sys *syscall.SysProcAttr) {
+}
diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go
index a668019..108c58f 100644
--- a/libcontainer/container_linux.go
+++ b/libcontainer/container_linux.go
@@ -164,6 +164,7 @@
 			// user mappings are not supported
 			return nil, err
 		}
+		enableSetgroups(cmd.SysProcAttr)
 		// Default to root user when user namespaces are enabled.
 		if cmd.SysProcAttr.Credential == nil {
 			cmd.SysProcAttr.Credential = &syscall.Credential{}
diff --git a/libcontainer/setgroups_linux.go b/libcontainer/setgroups_linux.go
new file mode 100644
index 0000000..c7bdb60
--- /dev/null
+++ b/libcontainer/setgroups_linux.go
@@ -0,0 +1,11 @@
+// +build linux,go1.5
+
+package libcontainer
+
+import "syscall"
+
+// Set the GidMappingsEnableSetgroups member to true, so the process's
+// setgroups proc entry wont be set to 'deny' if GidMappings are set
+func enableSetgroups(sys *syscall.SysProcAttr) {
+	sys.GidMappingsEnableSetgroups = true
+}