提交 a8582e36 编写于 作者: E Erik Skultety

admin: Use the connection to determine a client is connected readonly

Prior to this change, we relied solely on the inherited readonly
attribute of a service's socket. This only worked for our UNIX sockets
(and only to some degree), but doesn't work for TCP sockets which are RW
by default, but such connections support RO as well. This patch forces
an update on the client object once we have established a connection to
reflect the nature of the connection itself rather than relying on the
underlying socket's attributes.
Clients connected to the admin server have always been connected as RW
only.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1524399Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 69ed99c7
......@@ -1814,6 +1814,11 @@ remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
if (priv->conn == NULL)
goto cleanup;
/* force update the @readonly attribute which was inherited from the
* virNetServerService object - this is important for sockets that are RW
* by default, but do accept RO flags, e.g. TCP
*/
virNetServerClientSetReadonly(client, (flags & VIR_CONNECT_RO));
rv = 0;
cleanup:
......
......@@ -153,6 +153,7 @@ virNetServerClientSendMessage;
virNetServerClientSetAuth;
virNetServerClientSetCloseHook;
virNetServerClientSetDispatcher;
virNetServerClientSetReadonly;
virNetServerClientStartKeepAlive;
virNetServerClientWantClose;
......
......@@ -638,6 +638,17 @@ bool virNetServerClientGetReadonly(virNetServerClientPtr client)
return readonly;
}
void
virNetServerClientSetReadonly(virNetServerClientPtr client,
bool readonly)
{
virObjectLock(client);
client->readonly = readonly;
virObjectUnlock(client);
}
unsigned long long virNetServerClientGetID(virNetServerClientPtr client)
{
return client->id;
......
......@@ -81,6 +81,7 @@ void virNetServerClientRemoveFilter(virNetServerClientPtr client,
int virNetServerClientGetAuth(virNetServerClientPtr client);
void virNetServerClientSetAuth(virNetServerClientPtr client, int auth);
bool virNetServerClientGetReadonly(virNetServerClientPtr client);
void virNetServerClientSetReadonly(virNetServerClientPtr client, bool readonly);
unsigned long long virNetServerClientGetID(virNetServerClientPtr client);
long long virNetServerClientGetTimestamp(virNetServerClientPtr client);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册