[PATCH 04/11] util: Alter virAuthGet*Path API return processing

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

 



If we never find the valid credtype in the list, then we'd return
NULL without an error signaled forcing the caller to generate one
that will probably be incorrect. Let's be specific.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virauth.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/util/virauth.c b/src/util/virauth.c
index a04abb613b..d706658135 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -191,10 +191,12 @@ virAuthGetUsernamePath(const char *path,
         if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
             VIR_FREE(cred.result);
 
-        break;
+        return cred.result;
     }
 
-    return cred.result;
+    virReportError(VIR_ERR_AUTH_FAILED, "%s",
+                   _("Missing VIR_CRED_AUTHNAME credential type"));
+    return NULL;
 }
 
 
@@ -267,10 +269,13 @@ virAuthGetPasswordPath(const char *path,
         if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
             VIR_FREE(cred.result);
 
-        break;
+        return cred.result;
     }
 
-    return cred.result;
+    virReportError(VIR_ERR_AUTH_FAILED, "%s",
+                   _("Missing VIR_CRED_PASSPHRASE or VIR_CRED_NOECHOPROMPT "
+                     "credential type"));
+    return NULL;
 }
 
 
-- 
2.17.1

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

  Powered by Linux