Merge pull request #44848 from thaJeztah/23.0_backport_skip_lookup_on_windows

[23.0 backport] Disable chrootarchive.init() on Windows
This commit is contained in:
Sebastiaan van Stijn 2023-01-18 19:07:23 +01:00 committed by GitHub
commit 72f5fabd97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View file

@ -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{

View file

@ -9,7 +9,9 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"net"
"os" "os"
"os/user"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
@ -19,6 +21,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")
}
// untar is the entry-point for docker-untar on re-exec. This is not used on // untar is the entry-point for docker-untar on re-exec. This is not used on
// Windows as it does not support chroot, hence no point sandboxing through // Windows as it does not support chroot, hence no point sandboxing through
// chroot and rexec. // chroot and rexec.