mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
b0c3e93180
commit
69f4e093d0
src/util
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue