]> xenbits.xensource.com Git - libvirt.git/commitdiff
rpc: Refactor the condition whether a client needs authentication
authorMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Thu, 21 Dec 2017 14:29:02 +0000 (15:29 +0100)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 4 Jan 2018 11:55:31 +0000 (06:55 -0500)
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>
src/rpc/virnetserverclient.c

index 748132ae6127f8f99a7de180650ce4caa701a2c3..afe4fb47a256807da2e5e7de1df37c66e934c17a 100644 (file)
@@ -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);
 }