Просмотр исходного кода

Disable chrootarchive.init() on Windows

Disables user.Lookup() and net.LookupHost() in the init() function on Windows.

Any package that simply imports pkg/chrootarchive will panic on Windows
Nano Server, due to missing netapi32.dll. While docker itself is not
meant to run on Nano Server, binaries that may import this package and
run on Nano server, will fail even if they don't really use any of the
functionality in this package while running on Nano.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Gabriel Adrian Samfira 2 лет назад
Родитель
Сommit
f49c88f1c4
2 измененных файлов с 9 добавлено и 9 удалено
  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 (
 	"fmt"
 	"io"
-	"net"
 	"os"
-	"os/user"
 	"path/filepath"
 
 	"github.com/docker/docker/pkg/archive"
 	"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
 func NewArchiver(idMapping idtools.IdentityMapping) *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 (
 	"io"
+	"net"
+	"os/user"
 	"path/filepath"
 	"strings"
 
@@ -12,6 +14,13 @@ import (
 	"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 {
 	relDest, err := resolvePathInChroot(root, dest)
 	if err != nil {