[libvirt] [PATCH] Move virGetUserEnt() to where its needed

Doug Goldstein cardoe at cardoe.com
Sun Jun 16 21:45:07 UTC 2013


In the first if case, virGetUserEnt() isn't necessary so don't bother
calling it before determining we need it.
---
Found this trying to get libvirtd running happily on my Mac OS X machine
for qemu. Unfortunately it appears virGetUserEnt() is always failing
on Mac OS X (getpwuid_r() returns 0 each time) because we are requesting
info on a different high value UIDs each time (32xxx). That's another
issue entirely but this fix allows me to ignore that and test other
fixes on my Mac.
---
 src/util/virutil.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index c5246bc..6fa0212e 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -759,12 +759,13 @@ static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdefdir)
 {
     const char *path = getenv(xdgenvname);
     char *ret = NULL;
-    char *home = virGetUserEnt(geteuid(), VIR_USER_ENT_DIRECTORY);
+    char *home = NULL;
 
     if (path && path[0]) {
         if (virAsprintf(&ret, "%s/libvirt", path) < 0)
             goto no_memory;
     } else {
+        home = virGetUserEnt(geteuid(), VIR_USER_ENT_DIRECTORY);
         if (virAsprintf(&ret, "%s/%s/libvirt", home, xdgdefdir) < 0)
             goto no_memory;
     }
-- 
1.8.1.5




More information about the libvir-list mailing list