fix DirIsAccessible

perms 0000 need to be checked explicitly
This commit is contained in:
André Roth
2024-07-23 13:08:55 +02:00
parent 4a0bdcbb64
commit deae90485a

View File

@@ -10,13 +10,13 @@ import (
// DirIsAccessible verifies that directory exists and is accessible
func DirIsAccessible(filename string) error {
_, err := os.Stat(filename)
fileStat, err := os.Stat(filename)
if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("error checking directory '%s': %s", filename, err)
}
} else {
if unix.Access(filename, unix.W_OK) != nil {
if fileStat.Mode().Perm() == 0000 || unix.Access(filename, unix.W_OK) != nil {
return fmt.Errorf("'%s' is inaccessible, check access rights", filename)
}
}