[PATCH] util: honor anchored names when searching for executables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I got bit in a debugging session on an uninstalled libvirtd; the
code tried to call out to the installed $LIBEXECDIR/libvirt_iohelper
instead of my just-built version.  So I set a breakpoint and altered
the binary name to be "./src/libvirt_iohelper", and it still failed
because I don't have "." on my PATH.

According to POSIX, execvp only searches PATH if the name does
not contain a slash.  Since we are trying to mimic that behavior,
an anchored name should be relative to the current working dir.

* src/util/util.c (virFindFileInPath): Anchored relative names do
not invoke a PATH search.
---
 src/util/util.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index 1441c51..20ccfa7 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -596,6 +596,14 @@ 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, '/')) {
+        virFileAbsPath(file, &path);
+        return path;
+    }
+
     /* copy PATH env so we can tweak it */
     path = getenv("PATH");

-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]