diff --git a/src/util/util.c b/src/util/util.c index 62e0152c3e75bf3c7fe0a8b87c03054c2439f8c9..08c805057a51481b59782bd92b13c3833f534683 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -578,7 +578,7 @@ int virFileResolveLink(const char *linkpath, */ char *virFindFileInPath(const char *file) { - char *path; + char *path = NULL; char *pathiter; char *pathseg; char *fullpath = NULL; @@ -596,6 +596,15 @@ char *virFindFileInPath(const char *file) return NULL; } + /* If we are passed an anchored path (containing a /), then there + * is no path search - it must exist in the current directory + */ + if (strchr(file, '/')) { + if (virFileIsExecutable(file)) + ignore_value(virFileAbsPath(file, &path)); + return path; + } + /* copy PATH env so we can tweak it */ path = getenv("PATH");