render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From ed2b72afab3b9359cd3b6fab3ee38e56624e87f8 Mon Sep 17 00:00:00 2001
Message-Id: <ed2b72afab3b9359cd3b6fab3ee38e56624e87f8@dist-git>
From: Erik Skultety <eskultet@redhat.com>
Date: Mon, 1 Aug 2016 15:10:11 +0200
Subject: [PATCH] virconf: Fix config file path construction

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>
(cherry picked from commit c5d0a2a38525929515337ea21cb5c19903ccb05c)
---
 src/libvirt.c      |  2 +-
 src/util/virconf.c | 12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index a5e0e41..f26eec4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -970,7 +970,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')
diff --git a/src/util/virconf.c b/src/util/virconf.c
index 7c98588..8176296 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -1069,20 +1069,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;
         }
-- 
2.9.2