Browse Source

Revert "Use real chroot if daemon is running in a user namespace"

This change was introduced early in the development of rootless support,
before all the kinks were worked out and rootlesskit was built. The
author was testing the daemon by inside a user namespace set up by runc,
observed that the unshare(2) syscall was returning EPERM, and assumed
that it was a fundamental limitation of user namespaces. Seeing as the
kernel documentation (of today) disagrees with that assessment and that
unshare demonstrably works inside user namespaces, I can only assume
that the EPERM was due to a quirk of their test environment, such as a
seccomp filter set up by runc blocking the unshare syscall.
https://github.com/moby/moby/pull/20902#issuecomment-236409406

Mount namespaces are necessary to address #38995 and #43390. Revert the
special-casing so those issues can also be fixed for rootless daemons.

This reverts commit dc950567c105153c0a2f8b40d16b989bbddcdb3c.

Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 2 years ago
parent
commit
317d3d10b8
1 changed files with 0 additions and 5 deletions
  1. 0 5
      pkg/chrootarchive/chroot_linux.go

+ 0 - 5
pkg/chrootarchive/chroot_linux.go

@@ -5,7 +5,6 @@ import (
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 
 
-	"github.com/containerd/containerd/pkg/userns"
 	"github.com/moby/sys/mount"
 	"github.com/moby/sys/mount"
 	"github.com/moby/sys/mountinfo"
 	"github.com/moby/sys/mountinfo"
 	"golang.org/x/sys/unix"
 	"golang.org/x/sys/unix"
@@ -18,10 +17,6 @@ import (
 // Old root is removed after the call to pivot_root so it is no longer available under the new root.
 // Old root is removed after the call to pivot_root so it is no longer available under the new root.
 // This is similar to how libcontainer sets up a container's rootfs
 // This is similar to how libcontainer sets up a container's rootfs
 func chroot(path string) (err error) {
 func chroot(path string) (err error) {
-	// if the engine is running in a user namespace we need to use actual chroot
-	if userns.RunningInUserNS() {
-		return realChroot(path)
-	}
 	if err := unix.Unshare(unix.CLONE_NEWNS); err != nil {
 	if err := unix.Unshare(unix.CLONE_NEWNS); err != nil {
 		return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
 		return fmt.Errorf("Error creating mount namespace before pivot: %v", err)
 	}
 	}