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=1524399
Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Erik Skultety 2017-12-13 14:39:40 +01:00
parent 69ed99c786
commit a8582e3656
4 changed files with 18 additions and 0 deletions

View File

@ -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:

View File

@ -153,6 +153,7 @@ virNetServerClientSendMessage;
virNetServerClientSetAuth;
virNetServerClientSetCloseHook;
virNetServerClientSetDispatcher;
virNetServerClientSetReadonly;
virNetServerClientStartKeepAlive;
virNetServerClientWantClose;

View File

@ -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;

View File

@ -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);