提交 8420a53e 编写于 作者: E Erik Skultety

virnetserverclient: Add an internal method to retrieve client's identity

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: NErik Skultety <eskultet@redhat.com>
上级 bde2cb61
......@@ -122,6 +122,7 @@ virNetServerClientDelayedClose;
virNetServerClientGetAuth;
virNetServerClientGetFD;
virNetServerClientGetIdentity;
virNetServerClientGetInfo;
virNetServerClientGetPrivateData;
virNetServerClientGetReadonly;
virNetServerClientGetSELinuxContext;
......
......@@ -1612,3 +1612,33 @@ 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;
}
if (!client->identity) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No identity information available for client"));
goto cleanup;
}
*identity = virObjectRef(client->identity);
ret = 0;
cleanup:
virObjectUnlock(client);
return ret;
}
......@@ -149,5 +149,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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册