[PATCH 5/7] virnetserverclient: Add an internal method to retrieve client's identity

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

 



This method just aggregates various client object attributes, like socket
address, connection type (RO/RW), and some TCP/TLS/UNIX identity in an atomic
manner.

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/rpc/virnetserverclient.c | 26 ++++++++++++++++++++++++++
 src/rpc/virnetserverclient.h |  3 +++
 2 files changed, 29 insertions(+)

diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 396b0cc..ef1b568 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -1612,3 +1612,29 @@ virNetServerClientGetTransport(virNetServerClientPtr client)
 
     return ret;
 }
+
+int
+virNetServerClientGetInfo(virNetServerClientPtr client,
+                          bool *readonly, const char **sock_addr,
+                          virIdentityPtr *identity)
+{
+    int ret = -1;
+
+    virObjectLock(client);
+    *readonly = client->readonly;
+
+    if (!(*sock_addr = virNetServerClientRemoteAddrString(client))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("No network socket associated with client"));
+        goto cleanup;
+    }
+
+    *identity = NULL;
+    if (client->identity)
+        *identity = virObjectRef(client->identity);
+
+    ret = 0;
+ cleanup:
+    virObjectUnlock(client);
+    return ret;
+}
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index b576fde..2fbf60c 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -148,5 +148,8 @@ int virNetServerClientSendMessage(virNetServerClientPtr client,
 
 bool virNetServerClientNeedAuth(virNetServerClientPtr client);
 int virNetServerClientGetTransport(virNetServerClientPtr client);
+int virNetServerClientGetInfo(virNetServerClientPtr client,
+                              bool *readonly, const char **sock_addr,
+                              virIdentityPtr *identity);
 
 #endif /* __VIR_NET_SERVER_CLIENT_H__ */
-- 
2.4.11

--
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]