github.com/rumpl/bof@v23.0.0-rc.2+incompatible/pkg/system/path.go (about)

     1  package system // import "github.com/docker/docker/pkg/system"
     2  
     3  const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
     4  
     5  // DefaultPathEnv is unix style list of directories to search for
     6  // executables. Each directory is separated from the next by a colon
     7  // ':' character .
     8  // For Windows containers, an empty string is returned as the default
     9  // path will be set by the container, and Docker has no context of what the
    10  // default path should be.
    11  func DefaultPathEnv(os string) string {
    12  	if os == "windows" {
    13  		return ""
    14  	}
    15  	return defaultUnixPathEnv
    16  }
    17  
    18  // PathVerifier defines the subset of a PathDriver that CheckSystemDriveAndRemoveDriveLetter
    19  // actually uses in order to avoid system depending on containerd/continuity.
    20  type PathVerifier interface {
    21  	IsAbs(string) bool
    22  }
    23  
    24  // CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
    25  // is the system drive.
    26  // On Linux: this is a no-op.
    27  // On Windows: this does the following>
    28  // CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path.
    29  // This is used, for example, when validating a user provided path in docker cp.
    30  // If a drive letter is supplied, it must be the system drive. The drive letter
    31  // is always removed. Also, it translates it to OS semantics (IOW / to \). We
    32  // need the path in this syntax so that it can ultimately be concatenated with
    33  // a Windows long-path which doesn't support drive-letters. Examples:
    34  // C:			--> Fail
    35  // C:\			--> \
    36  // a			--> a
    37  // /a			--> \a
    38  // d:\			--> Fail
    39  func CheckSystemDriveAndRemoveDriveLetter(path string, driver PathVerifier) (string, error) {
    40  	return checkSystemDriveAndRemoveDriveLetter(path, driver)
    41  }