Source: golang Version: 1.5.1-4 Severity: normal Tags: patch upstream Dear Maintainer,
Tests fail in my sid chroot because, on the Ubuntu kernel at least, the tests that try to create a new user namespace all fail in a chroot. I fixed this upstream but it'd be nice to have this in the 1.5 packaging too so here's a backport of the patch. Cheers, mwh -- System Information: Debian Release: stretch/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 4.2.0-18-generic (SMP w/4 CPU cores) Locale: LANG=en_NZ.UTF-8, LC_CTYPE=en_NZ.UTF-8 (charmap=locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory ANSI_X3.4-1968) Shell: /bin/sh linked to /bin/dash Init: unable to detect
diff --git a/debian/patches/series b/debian/patches/series index e7c92b7..e189b35 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ support-new-relocations.patch +skip-userns-tests-when-chrooted.patch diff --git a/debian/patches/skip-userns-tests-when-chrooted.patch b/debian/patches/skip-userns-tests-when-chrooted.patch new file mode 100644 index 0000000..15bd724 --- /dev/null +++ b/debian/patches/skip-userns-tests-when-chrooted.patch @@ -0,0 +1,37 @@ +Description: skip tests that create a user namespace when chrooted +Origin: https://go.googlesource.com/go/+/21efa7b2bc872958bcb252f5ab4dc52b2b0abeae +Applied-Upstream: commit:21efa7b2bc872958bcb252f5ab4dc52b2b0abeae + +--- a/src/syscall/exec_linux_test.go ++++ b/src/syscall/exec_linux_test.go +@@ -17,6 +17,17 @@ + "testing" + ) + ++// Check if we are in a chroot by checking if the inode of / is ++// different from 2 (there is no better test available to non-root on ++// linux). ++func isChrooted(t *testing.T) bool { ++ root, err := os.Stat("/") ++ if err != nil { ++ t.Fatalf("cannot stat /: %v", err) ++ } ++ return root.Sys().(*syscall.Stat_t).Ino != 2 ++} ++ + func whoamiCmd(t *testing.T, uid, gid int, setgroups bool) *exec.Cmd { + if _, err := os.Stat("/proc/self/ns/user"); err != nil { + if os.IsNotExist(err) { +@@ -24,6 +35,12 @@ + } + t.Fatalf("Failed to stat /proc/self/ns/user: %v", err) + } ++ if isChrooted(t) { ++ // create_user_ns in the kernel (see ++ // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/user_namespace.c) ++ // forbids the creation of user namespaces when chrooted. ++ t.Skip("cannot create user namespaces when chrooted") ++ } + cmd := exec.Command("whoami") + cmd.SysProcAttr = &syscall.SysProcAttr{ + Cloneflags: syscall.CLONE_NEWUSER,