render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
6ae9ed
From ed2b72afab3b9359cd3b6fab3ee38e56624e87f8 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <ed2b72afab3b9359cd3b6fab3ee38e56624e87f8@dist-git>
6ae9ed
From: Erik Skultety <eskultet@redhat.com>
6ae9ed
Date: Mon, 1 Aug 2016 15:10:11 +0200
6ae9ed
Subject: [PATCH] virconf: Fix config file path construction
6ae9ed
6ae9ed
Since commit c4bdff19, the path to the configuration file has been constructed
6ae9ed
in the following manner:
6ae9ed
 - if no config filename was passed to virConfLoadConfigPath, libvirt.conf was
6ae9ed
 used as default
6ae9ed
 - otherwise the filename was concatenated with
6ae9ed
 "<config_dir>/libvirt/libvirt%s%s.conf" which in admin case resulted in
6ae9ed
 "libvirt-libvirt-admin.conf.conf". Obviously, this non-existent config led to
6ae9ed
 ignoring  all user settings in libvirt-admin.conf. This patch requires the
6ae9ed
 config filename to be always provided as an argument with the concatenation
6ae9ed
 being simplified.
6ae9ed
6ae9ed
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1357364
6ae9ed
6ae9ed
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6ae9ed
(cherry picked from commit c5d0a2a38525929515337ea21cb5c19903ccb05c)
6ae9ed
---
6ae9ed
 src/libvirt.c      |  2 +-
6ae9ed
 src/util/virconf.c | 12 ++++--------
6ae9ed
 2 files changed, 5 insertions(+), 9 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/libvirt.c b/src/libvirt.c
6ae9ed
index a5e0e41..f26eec4 100644
6ae9ed
--- a/src/libvirt.c
6ae9ed
+++ b/src/libvirt.c
6ae9ed
@@ -970,7 +970,7 @@ virConnectOpenInternal(const char *name,
6ae9ed
     if (ret == NULL)
6ae9ed
         return NULL;
6ae9ed
 
6ae9ed
-    if (virConfLoadConfig(&conf, NULL) < 0)
6ae9ed
+    if (virConfLoadConfig(&conf, "libvirt.conf") < 0)
6ae9ed
         goto failed;
6ae9ed
 
6ae9ed
     if (name && name[0] == '\0')
6ae9ed
diff --git a/src/util/virconf.c b/src/util/virconf.c
6ae9ed
index 7c98588..8176296 100644
6ae9ed
--- a/src/util/virconf.c
6ae9ed
+++ b/src/util/virconf.c
6ae9ed
@@ -1069,20 +1069,16 @@ virConfLoadConfigPath(const char *name)
6ae9ed
 {
6ae9ed
     char *path;
6ae9ed
     if (geteuid() == 0) {
6ae9ed
-        if (virAsprintf(&path, "%s/libvirt/libvirt%s%s.conf",
6ae9ed
-                        SYSCONFDIR,
6ae9ed
-                        name ? "-" : "",
6ae9ed
-                        name ? name : "") < 0)
6ae9ed
+        if (virAsprintf(&path, "%s/libvirt/%s",
6ae9ed
+                        SYSCONFDIR, name) < 0)
6ae9ed
             return NULL;
6ae9ed
     } else {
6ae9ed
         char *userdir = virGetUserConfigDirectory();
6ae9ed
         if (!userdir)
6ae9ed
             return NULL;
6ae9ed
 
6ae9ed
-        if (virAsprintf(&path, "%s/libvirt%s%s.conf",
6ae9ed
-                        userdir,
6ae9ed
-                        name ? "-" : "",
6ae9ed
-                        name ? name : "") < 0) {
6ae9ed
+        if (virAsprintf(&path, "%s/%s",
6ae9ed
+                        userdir, name) < 0) {
6ae9ed
             VIR_FREE(userdir);
6ae9ed
             return NULL;
6ae9ed
         }
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed