Instead of adding the same check for every drivers, execute the checks
in virAuthGetUsername and virAuthGetPassword. These funtions are called
when user is not set in the URI.
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org(a)gmail.com>
---
src/util/virauth.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/util/virauth.c b/src/util/virauth.c
index 8c450b6b31..759b8f0cd3 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -198,6 +198,12 @@ virAuthGetUsername(virConnectPtr conn,
if (virAuthGetConfigFilePath(conn, &path) < 0)
return NULL;
+ if (!auth || !auth->cb) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Missing or invalid auth pointer"));
+ return NULL;
+ }
+
return virAuthGetUsernamePath(path, auth, servicename,
defaultUsername, hostname);
}
@@ -262,5 +268,11 @@ virAuthGetPassword(virConnectPtr conn,
if (virAuthGetConfigFilePath(conn, &path) < 0)
return NULL;
+ if (!auth || !auth->cb) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Missing or invalid auth pointer"));
+ return NULL;
+ }
+
return virAuthGetPasswordPath(path, auth, servicename, username, hostname);
}
--
2.17.1