diff --git a/common/pkg/config/config.go b/common/pkg/config/config.go index 2b005d39f8..ea5c1adf8a 100644 --- a/common/pkg/config/config.go +++ b/common/pkg/config/config.go @@ -1168,27 +1168,6 @@ func IsValidDeviceMode(mode string) bool { return true } -// resolveHomeDir converts a path referencing the home directory via "~" -// to an absolute path -func resolveHomeDir(path string) (string, error) { - // check if the path references the home dir to avoid work - // don't use strings.HasPrefix(path, "~") as this doesn't match "~" alone - // use strings.HasPrefix(...) to not match "something/~/something" - if !(path == "~" || strings.HasPrefix(path, "~/")) { - // path does not reference home dir -> Nothing to do - return path, nil - } - - // only get HomeDir when necessary - home, err := unshare.HomeDir() - if err != nil { - return "", err - } - - // replace the first "~" (start of path) with the HomeDir to resolve "~" - return strings.Replace(path, "~", home, 1), nil -} - func rootlessConfigPath() (string, error) { if configHome := os.Getenv("XDG_CONFIG_HOME"); configHome != "" { return filepath.Join(configHome, _configPath), nil @@ -1201,20 +1180,6 @@ func rootlessConfigPath() (string, error) { return filepath.Join(home, UserOverrideContainersConfig), nil } -func stringsEq(a, b []string) bool { - if len(a) != len(b) { - return false - } - - for i := range a { - if a[i] != b[i] { - return false - } - } - - return true -} - var ( configErr error configMutex sync.Mutex diff --git a/common/pkg/config/config_local.go b/common/pkg/config/config_local.go index 4e2a0abc95..10d40dddba 100644 --- a/common/pkg/config/config_local.go +++ b/common/pkg/config/config_local.go @@ -9,37 +9,11 @@ import ( "path/filepath" "regexp" "strings" - "syscall" "github.com/container-orchestrated-devices/container-device-interface/pkg/parser" units "github.com/docker/go-units" ) -// isDirectory tests whether the given path exists and is a directory. It -// follows symlinks. -func isDirectory(path string) error { - path, err := resolveHomeDir(path) - if err != nil { - return err - } - - info, err := os.Stat(path) - if err != nil { - return err - } - - if !info.Mode().IsDir() { - // Return a PathError to be consistent with os.Stat(). - return &os.PathError{ - Op: "stat", - Path: path, - Err: syscall.ENOTDIR, - } - } - - return nil -} - func (c *EngineConfig) validatePaths() error { // Relative paths can cause nasty bugs, because core paths we use could // shift between runs or even parts of the program. - The OCI runtime