import (
"io/ioutil"
"log"
+ "os"
"path/filepath"
"strings"
)
fullName := item.Name()
if !strings.HasPrefix(fullName, prefix) {
- log.Printf("[DEBUG] skipping %q, not a %s", fullName, kind)
continue
}
continue
}
+ // Check that the file we found is usable
+ if !pathIsFile(absPath) {
+ log.Printf("[ERROR] ignoring non-file %s", absPath)
+ continue
+ }
+
log.Printf("[DEBUG] found %s %q", kind, fullName)
ret = append(ret, filepath.Clean(absPath))
continue
continue
}
- log.Printf("[WARNING] found legacy %s %q", kind, fullName)
+ // Check that the file we found is usable
+ if !pathIsFile(absPath) {
+ log.Printf("[ERROR] ignoring non-file %s", absPath)
+ continue
+ }
+
+ log.Printf("[WARN] found legacy %s %q", kind, fullName)
ret = append(ret, filepath.Clean(absPath))
}
return ret
}
+// Returns true if and only if the given path refers to a file or a symlink
+// to a file.
+func pathIsFile(path string) bool {
+ info, err := os.Stat(path)
+ if err != nil {
+ return false
+ }
+
+ return !info.IsDir()
+}
+
// ResolvePluginPaths takes a list of paths to plugin executables (as returned
// by e.g. FindPluginPaths) and produces a PluginMetaSet describing the
// referenced plugins.