提交 be680bed 编写于 作者: M Marc Hartmayer 提交者: John Ferlan

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: NMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: NBoris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: NStefan Zimmermann <stzi@linux.vnet.ibm.com>
上级 c10103e9
...@@ -354,6 +354,23 @@ static void virNetServerClientSockTimerFunc(int timer, ...@@ -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 static virNetServerClientPtr
virNetServerClientNewInternal(unsigned long long id, virNetServerClientNewInternal(unsigned long long id,
virNetSocketPtr sock, virNetSocketPtr sock,
...@@ -1521,7 +1538,7 @@ int virNetServerClientSendMessage(virNetServerClientPtr client, ...@@ -1521,7 +1538,7 @@ int virNetServerClientSendMessage(virNetServerClientPtr client,
bool bool
virNetServerClientNeedAuthLocked(virNetServerClientPtr client) virNetServerClientNeedAuthLocked(virNetServerClientPtr client)
{ {
return !(client->auth == VIR_NET_SERVER_SERVICE_AUTH_NONE); return !virNetServerClientAuthMethodImpliesAuthenticated(client->auth);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册