Be more precise in which cases the authentication is needed and
introduce *Locked.

Signed-off-by: Marc Hartmayer <mhart...@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiu...@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bw...@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <s...@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jfer...@redhat.com>
---
 src/libvirt_remote.syms      |  1 +
 src/rpc/virnetserverclient.c | 15 +++++++++++----
 src/rpc/virnetserverclient.h |  1 +
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 1c107e1d69aa..cecd71c49e7f 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -143,6 +143,7 @@ virNetServerClientIsLocal;
 virNetServerClientIsSecure;
 virNetServerClientLocalAddrStringSASL;
 virNetServerClientNeedAuth;
+virNetServerClientNeedAuthLocked;
 virNetServerClientNew;
 virNetServerClientNewPostExecRestart;
 virNetServerClientPreExecRestart;
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index f4a2571f55c5..748132ae6127 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -1518,12 +1518,19 @@ int virNetServerClientSendMessage(virNetServerClientPtr 
client,
 }
 
 
-bool virNetServerClientNeedAuth(virNetServerClientPtr client)
+bool
+virNetServerClientNeedAuthLocked(virNetServerClientPtr client)
 {
-    bool need = false;
+    return !(client->auth == VIR_NET_SERVER_SERVICE_AUTH_NONE);
+}
+
+
+bool
+virNetServerClientNeedAuth(virNetServerClientPtr client)
+{
+    bool need;
     virObjectLock(client);
-    if (client->auth)
-        need = true;
+    need = virNetServerClientNeedAuthLocked(client);
     virObjectUnlock(client);
     return need;
 }
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index 2569f93c3b52..1182d53c7059 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -147,6 +147,7 @@ int virNetServerClientSendMessage(virNetServerClientPtr 
client,
                                   virNetMessagePtr msg);
 
 bool virNetServerClientNeedAuth(virNetServerClientPtr client);
+bool virNetServerClientNeedAuthLocked(virNetServerClientPtr client);
 
 int virNetServerClientGetTransport(virNetServerClientPtr client);
 int virNetServerClientGetInfo(virNetServerClientPtr client,
-- 
2.13.4

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

Reply via email to