[PATCH v2 07/14] rpc: Refactor the condition whether a client needs authentication

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Stefan Zimmermann <stzi@xxxxxxxxxxxxxxxxxx>
---
 src/rpc/virnetserverclient.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 748132ae6127..afe4fb47a256 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -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);
 }
 
 
-- 
2.13.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux