]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Alter virAuthGet*Path API to generate auth->cb error
authorJohn Ferlan <jferlan@redhat.com>
Tue, 14 Aug 2018 14:14:22 +0000 (10:14 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 15 Aug 2018 19:42:08 +0000 (15:42 -0400)
Rather than forcing the caller to generate an error, let's
generate the Username or Password error message failure if
the auth->cb fails. This is the last error path that needs
a specific message for various callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
src/util/virauth.c

index d7066581359fc33fb25be25415d476311cef1f96..5f1515e1130a4e0a2513b5c2b88fc764ea29be32 100644 (file)
@@ -188,8 +188,11 @@ virAuthGetUsernamePath(const char *path,
         cred.result = NULL;
         cred.resultlen = 0;
 
-        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
+        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+            virReportError(VIR_ERR_AUTH_FAILED, "%s",
+                           _("Username request failed"));
             VIR_FREE(cred.result);
+        }
 
         return cred.result;
     }
@@ -266,8 +269,11 @@ virAuthGetPasswordPath(const char *path,
         cred.result = NULL;
         cred.resultlen = 0;
 
-        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
+        if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+            virReportError(VIR_ERR_AUTH_FAILED, "%s",
+                           _("Password request failed"));
             VIR_FREE(cred.result);
+        }
 
         return cred.result;
     }