[PATCH 1/2] util: Add possibility to call virAuthGetPassword without conn object

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

 



To make this function callable from code that doesn't have the conn
object, call the conn-dependant code only if conn was provided.
---
 src/util/virauth.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/util/virauth.c b/src/util/virauth.c
index 6d9935d..738b3c5 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -205,7 +205,8 @@ virAuthGetUsername(virConnectPtr conn,
 }


-
+/* if this function is called with conn == NULL, the code requesting
+ * the password from the config file is skipped */
 char *
 virAuthGetPassword(virConnectPtr conn,
                    virConnectAuthPtr auth,
@@ -218,10 +219,12 @@ virAuthGetPassword(virConnectPtr conn,
     char *prompt;
     char *ret = NULL;

-    if (virAuthGetCredential(conn, servicename, "password", &ret) < 0)
-        return NULL;
-    if (ret != NULL)
-        return ret;
+    if (conn) {
+        if (virAuthGetCredential(conn, servicename, "password", &ret) < 0)
+            return NULL;
+        if (ret != NULL)
+            return ret;
+    }

     memset(&cred, 0, sizeof(virConnectCredential));

-- 
1.8.0

--
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]