1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

virauth.c: Check for valid auth callback

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@gmail.com>
This commit is contained in:
Marcos Paulo de Souza 2018-08-02 21:27:51 -03:00 committed by Michal Privoznik
parent b0c3e93180
commit 69f4e093d0

View File

@ -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);
}