From: John Ferlan Date: Tue, 14 Aug 2018 14:14:22 +0000 (-0400) Subject: util: Alter virAuthGet*Path API to generate auth->cb error X-Git-Tag: v4.7.0-rc1~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39f0f3ae6597b15c6fed6b9b49807aee2cc42341;p=thirdparty%2Flibvirt.git util: Alter virAuthGet*Path API to generate auth->cb error 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 Reviewed-by: Marcos Paulo de Souza --- diff --git a/src/util/virauth.c b/src/util/virauth.c index d706658135..5f1515e113 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -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; }