diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-04-27 18:44:02 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-04-29 14:06:54 +0200 |
commit | a48c37df3765f42c779ac0674eb021f955ed9c07 (patch) | |
tree | ee491d29f01c292d36bf8aa09d9211a51cbc88b1 /vendor/github.com/mrunalp/fileutils/idtools.go | |
parent | 69c479b16e19f4f919fa820aeafe90cb113b8e0a (diff) | |
download | podman-a48c37df3765f42c779ac0674eb021f955ed9c07.tar.gz podman-a48c37df3765f42c779ac0674eb021f955ed9c07.tar.bz2 podman-a48c37df3765f42c779ac0674eb021f955ed9c07.zip |
fix broken hooks-dir test
The test has been broken since it was added 4 years ago. Instead of
using hardcoded paths we should use tmp files.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'vendor/github.com/mrunalp/fileutils/idtools.go')
-rw-r--r-- | vendor/github.com/mrunalp/fileutils/idtools.go | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/vendor/github.com/mrunalp/fileutils/idtools.go b/vendor/github.com/mrunalp/fileutils/idtools.go deleted file mode 100644 index bad6539df..000000000 --- a/vendor/github.com/mrunalp/fileutils/idtools.go +++ /dev/null @@ -1,54 +0,0 @@ -package fileutils - -import ( - "os" - "path/filepath" - "syscall" -) - -// MkdirAllNewAs creates a directory (include any along the path) and then modifies -// ownership ONLY of newly created directories to the requested uid/gid. If the -// directories along the path exist, no change of ownership will be performed -func MkdirAllNewAs(path string, mode os.FileMode, ownerUID, ownerGID int) error { - // make an array containing the original path asked for, plus (for mkAll == true) - // all path components leading up to the complete path that don't exist before we MkdirAll - // so that we can chown all of them properly at the end. If chownExisting is false, we won't - // chown the full directory path if it exists - var paths []string - st, err := os.Stat(path) - if err != nil && os.IsNotExist(err) { - paths = []string{path} - } else if err == nil { - if !st.IsDir() { - return &os.PathError{Op: "mkdir", Path: path, Err: syscall.ENOTDIR} - } - // nothing to do; directory path fully exists already - return nil - } - - // walk back to "/" looking for directories which do not exist - // and add them to the paths array for chown after creation - dirPath := path - for { - dirPath = filepath.Dir(dirPath) - if dirPath == "/" { - break - } - if _, err := os.Stat(dirPath); err != nil && os.IsNotExist(err) { - paths = append(paths, dirPath) - } - } - - if err := os.MkdirAll(path, mode); err != nil { - return err - } - - // even if it existed, we will chown the requested path + any subpaths that - // didn't exist when we called MkdirAll - for _, pathComponent := range paths { - if err := os.Chown(pathComponent, ownerUID, ownerGID); err != nil { - return err - } - } - return nil -} |