mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
rpc: Refactor the condition whether a client needs authentication
Add virNetServerClientAuthMethodImpliesAuthenticated() for deciding whether a authentication method implies that a client is automatically authenticated or not. Use this new function in virNetServerClientNeedAuthLocked(). Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
This commit is contained in:
parent
c10103e941
commit
be680bed4a
@ -354,6 +354,23 @@ static void virNetServerClientSockTimerFunc(int timer,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virNetServerClientAuthMethodImpliesAuthenticated:
|
||||
* @auth: authentication method to check
|
||||
*
|
||||
* Check if the passed authentication method implies that a client is
|
||||
* automatically authenticated.
|
||||
*
|
||||
* Returns true if @auth implies that a client is automatically
|
||||
* authenticated, otherwise false.
|
||||
*/
|
||||
static bool
|
||||
virNetServerClientAuthMethodImpliesAuthenticated(int auth)
|
||||
{
|
||||
return auth == VIR_NET_SERVER_SERVICE_AUTH_NONE;
|
||||
}
|
||||
|
||||
|
||||
static virNetServerClientPtr
|
||||
virNetServerClientNewInternal(unsigned long long id,
|
||||
virNetSocketPtr sock,
|
||||
@ -1521,7 +1538,7 @@ int virNetServerClientSendMessage(virNetServerClientPtr client,
|
||||
bool
|
||||
virNetServerClientNeedAuthLocked(virNetServerClientPtr client)
|
||||
{
|
||||
return !(client->auth == VIR_NET_SERVER_SERVICE_AUTH_NONE);
|
||||
return !virNetServerClientAuthMethodImpliesAuthenticated(client->auth);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user