mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
14
vendor/github.com/moby/buildkit/util/system/path_unix.go
generated
vendored
Normal file
14
vendor/github.com/moby/buildkit/util/system/path_unix.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// +build !windows
|
||||
|
||||
package system
|
||||
|
||||
// DefaultPathEnv is unix style list of directories to search for
|
||||
// executables. Each directory is separated from the next by a colon
|
||||
// ':' character .
|
||||
const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
|
||||
// is the system drive. This is a no-op on Linux.
|
||||
func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) {
|
||||
return path, nil
|
||||
}
|
37
vendor/github.com/moby/buildkit/util/system/path_windows.go
generated
vendored
Normal file
37
vendor/github.com/moby/buildkit/util/system/path_windows.go
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// +build windows
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DefaultPathEnv is deliberately empty on Windows as the default path will be set by
|
||||
// the container. Docker has no context of what the default path should be.
|
||||
const DefaultPathEnv = ""
|
||||
|
||||
// CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path.
|
||||
// This is used, for example, when validating a user provided path in docker cp.
|
||||
// If a drive letter is supplied, it must be the system drive. The drive letter
|
||||
// is always removed. Also, it translates it to OS semantics (IOW / to \). We
|
||||
// need the path in this syntax so that it can ultimately be contatenated with
|
||||
// a Windows long-path which doesn't support drive-letters. Examples:
|
||||
// C: --> Fail
|
||||
// C:\ --> \
|
||||
// a --> a
|
||||
// /a --> \a
|
||||
// d:\ --> Fail
|
||||
func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) {
|
||||
if len(path) == 2 && string(path[1]) == ":" {
|
||||
return "", fmt.Errorf("No relative path specified in %q", path)
|
||||
}
|
||||
if !filepath.IsAbs(path) || len(path) < 2 {
|
||||
return filepath.FromSlash(path), nil
|
||||
}
|
||||
if string(path[1]) == ":" && !strings.EqualFold(string(path[0]), "c") {
|
||||
return "", fmt.Errorf("The specified path is not on the system drive (C:)")
|
||||
}
|
||||
return filepath.FromSlash(path[2:]), nil
|
||||
}
|
29
vendor/github.com/moby/buildkit/util/system/seccomp_linux.go
generated
vendored
Normal file
29
vendor/github.com/moby/buildkit/util/system/seccomp_linux.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// +build linux,seccomp
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var seccompSupported bool
|
||||
var seccompOnce sync.Once
|
||||
|
||||
func SeccompSupported() bool {
|
||||
seccompOnce.Do(func() {
|
||||
seccompSupported = getSeccompSupported()
|
||||
})
|
||||
return seccompSupported
|
||||
}
|
||||
|
||||
func getSeccompSupported() bool {
|
||||
if err := unix.Prctl(unix.PR_GET_SECCOMP, 0, 0, 0, 0); err != unix.EINVAL {
|
||||
// Make sure the kernel has CONFIG_SECCOMP_FILTER.
|
||||
if err := unix.Prctl(unix.PR_SET_SECCOMP, unix.SECCOMP_MODE_FILTER, 0, 0, 0); err != unix.EINVAL {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
7
vendor/github.com/moby/buildkit/util/system/seccomp_nolinux.go
generated
vendored
Normal file
7
vendor/github.com/moby/buildkit/util/system/seccomp_nolinux.go
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
// +build !linux,seccomp
|
||||
|
||||
package system
|
||||
|
||||
func SeccompSupported() bool {
|
||||
return false
|
||||
}
|
7
vendor/github.com/moby/buildkit/util/system/seccomp_noseccomp.go
generated
vendored
Normal file
7
vendor/github.com/moby/buildkit/util/system/seccomp_noseccomp.go
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
// +build !seccomp
|
||||
|
||||
package system
|
||||
|
||||
func SeccompSupported() bool {
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user