2018-02-05 16:05:59 -05:00
|
|
|
package system // import "github.com/docker/docker/pkg/system"
|
2017-05-26 19:14:18 -04:00
|
|
|
|
|
|
|
const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
|
|
|
|
|
|
|
// DefaultPathEnv is unix style list of directories to search for
|
|
|
|
// executables. Each directory is separated from the next by a colon
|
|
|
|
// ':' character .
|
2021-03-18 16:01:46 -04:00
|
|
|
// For Windows containers, an empty string is returned as the default
|
|
|
|
// path will be set by the container, and Docker has no context of what the
|
|
|
|
// default path should be.
|
2017-08-08 15:43:48 -04:00
|
|
|
func DefaultPathEnv(os string) string {
|
2021-03-18 16:01:46 -04:00
|
|
|
if os == "windows" {
|
2017-05-26 19:14:18 -04:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return defaultUnixPathEnv
|
|
|
|
}
|
2017-08-03 20:22:00 -04:00
|
|
|
|
|
|
|
// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
|
|
|
|
// is the system drive.
|
|
|
|
// On Linux: this is a no-op.
|
|
|
|
// On Windows: this does the following>
|
|
|
|
// 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
|
2018-02-10 06:28:12 -05:00
|
|
|
// need the path in this syntax so that it can ultimately be concatenated with
|
2017-08-03 20:22:00 -04:00
|
|
|
// a Windows long-path which doesn't support drive-letters. Examples:
|
|
|
|
// C: --> Fail
|
|
|
|
// C:\ --> \
|
|
|
|
// a --> a
|
|
|
|
// /a --> \a
|
|
|
|
// d:\ --> Fail
|
2022-09-22 20:49:47 -04:00
|
|
|
func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) {
|
|
|
|
return checkSystemDriveAndRemoveDriveLetter(path)
|
2017-08-03 20:22:00 -04:00
|
|
|
}
|