]> xenbits.xensource.com Git - libvirt.git/commitdiff
virconf: Fix config file path construction
authorErik Skultety <eskultet@redhat.com>
Tue, 26 Jul 2016 12:06:13 +0000 (14:06 +0200)
committerErik Skultety <eskultet@redhat.com>
Wed, 27 Jul 2016 10:13:13 +0000 (12:13 +0200)
Since commit c4bdff19, the path to the configuration file has been constructed
in the following manner:
 - if no config filename was passed to virConfLoadConfigPath, libvirt.conf was
 used as default
 - otherwise the filename was concatenated with
 "<config_dir>/libvirt/libvirt%s%s.conf" which in admin case resulted in
 "libvirt-libvirt-admin.conf.conf". Obviously, this non-existent config led to
 ignoring  all user settings in libvirt-admin.conf. This patch requires the
 config filename to be always provided as an argument with the concatenation
 being simplified.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1357364

Signed-off-by: Erik Skultety <eskultet@redhat.com>
src/libvirt.c
src/util/virconf.c

index 68c83179ab1a500978fd65c1aa67e04985c91d1c..52462e3abf4014757797c17bb326eb499d2e8dff 100644 (file)
@@ -969,7 +969,7 @@ virConnectOpenInternal(const char *name,
     if (ret == NULL)
         return NULL;
 
-    if (virConfLoadConfig(&conf, NULL) < 0)
+    if (virConfLoadConfig(&conf, "libvirt.conf") < 0)
         goto failed;
 
     if (name && name[0] == '\0')
index ee54072467178409f51aa370693fc93297b986c2..3e49f41b603ed9752626e671cf0d449587c04273 100644 (file)
@@ -1566,20 +1566,16 @@ virConfLoadConfigPath(const char *name)
 {
     char *path;
     if (geteuid() == 0) {
-        if (virAsprintf(&path, "%s/libvirt/libvirt%s%s.conf",
-                        SYSCONFDIR,
-                        name ? "-" : "",
-                        name ? name : "") < 0)
+        if (virAsprintf(&path, "%s/libvirt/%s",
+                        SYSCONFDIR, name) < 0)
             return NULL;
     } else {
         char *userdir = virGetUserConfigDirectory();
         if (!userdir)
             return NULL;
 
-        if (virAsprintf(&path, "%s/libvirt%s%s.conf",
-                        userdir,
-                        name ? "-" : "",
-                        name ? name : "") < 0) {
+        if (virAsprintf(&path, "%s/%s",
+                        userdir, name) < 0) {
             VIR_FREE(userdir);
             return NULL;
         }