Browse Source

Merge pull request #44847 from gabriel-samfira/skip-lookup-on-windows

Disable chrootarchive.init() on Windows
Sebastiaan van Stijn 2 years ago
parent
commit
f481f9333d
2 changed files with 9 additions and 9 deletions
  1. 0 9
      pkg/chrootarchive/archive.go
  2. 9 0
      pkg/chrootarchive/archive_unix.go

+ 0 - 9
pkg/chrootarchive/archive.go

@@ -3,22 +3,13 @@ package chrootarchive // import "github.com/docker/docker/pkg/chrootarchive"
 import (
 import (
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"net"
 	"os"
 	"os"
-	"os/user"
 	"path/filepath"
 	"path/filepath"
 
 
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/idtools"
 )
 )
 
 
-func init() {
-	// initialize nss libraries in Glibc so that the dynamic libraries are loaded in the host
-	// environment not in the chroot from untrusted files.
-	_, _ = user.Lookup("docker")
-	_, _ = net.LookupHost("localhost")
-}
-
 // NewArchiver returns a new Archiver which uses chrootarchive.Untar
 // NewArchiver returns a new Archiver which uses chrootarchive.Untar
 func NewArchiver(idMapping idtools.IdentityMapping) *archive.Archiver {
 func NewArchiver(idMapping idtools.IdentityMapping) *archive.Archiver {
 	return &archive.Archiver{
 	return &archive.Archiver{

+ 9 - 0
pkg/chrootarchive/archive_unix.go

@@ -5,6 +5,8 @@ package chrootarchive // import "github.com/docker/docker/pkg/chrootarchive"
 
 
 import (
 import (
 	"io"
 	"io"
+	"net"
+	"os/user"
 	"path/filepath"
 	"path/filepath"
 	"strings"
 	"strings"
 
 
@@ -12,6 +14,13 @@ import (
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 )
 )
 
 
+func init() {
+	// initialize nss libraries in Glibc so that the dynamic libraries are loaded in the host
+	// environment not in the chroot from untrusted files.
+	_, _ = user.Lookup("docker")
+	_, _ = net.LookupHost("localhost")
+}
+
 func invokeUnpack(decompressedArchive io.Reader, dest string, options *archive.TarOptions, root string) error {
 func invokeUnpack(decompressedArchive io.Reader, dest string, options *archive.TarOptions, root string) error {
 	relDest, err := resolvePathInChroot(root, dest)
 	relDest, err := resolvePathInChroot(root, dest)
 	if err != nil {
 	if err != nil {