From nobody Sat May 4 17:41:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1513180064049761.1107223228018; Wed, 13 Dec 2017 07:47:44 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9D36C0587C9; Wed, 13 Dec 2017 15:47:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57F3E77D5F; Wed, 13 Dec 2017 15:47:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 608AA4BB79; Wed, 13 Dec 2017 15:47:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBDFlehx024578 for ; Wed, 13 Dec 2017 10:47:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 249447EE6E; Wed, 13 Dec 2017 15:47:40 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 695927EE6A; Wed, 13 Dec 2017 15:47:36 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Wed, 13 Dec 2017 16:47:28 +0100 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH] admin: Use the connection to determine a client is connected readonly X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 13 Dec 2017 15:47:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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=3D1524399 Signed-off-by: Erik Skultety Reviewed-by: John Ferlan --- daemon/remote.c | 5 +++++ src/libvirt_remote.syms | 1 + src/rpc/virnetserverclient.c | 11 +++++++++++ src/rpc/virnetserverclient.h | 1 + 4 files changed, 18 insertions(+) diff --git a/daemon/remote.c b/daemon/remote.c index c2111ae37..8e99a4d86 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -1814,6 +1814,11 @@ remoteDispatchConnectOpen(virNetServerPtr server ATT= RIBUTE_UNUSED, if (priv->conn =3D=3D NULL) goto cleanup; =20 + /* 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 =3D 0; =20 cleanup: diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 61c20d530..1c107e1d6 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -153,6 +153,7 @@ virNetServerClientSendMessage; virNetServerClientSetAuth; virNetServerClientSetCloseHook; virNetServerClientSetDispatcher; +virNetServerClientSetReadonly; virNetServerClientStartKeepAlive; virNetServerClientWantClose; =20 diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 6e086b7b4..f4a2571f5 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -638,6 +638,17 @@ bool virNetServerClientGetReadonly(virNetServerClientP= tr client) return readonly; } =20 + +void +virNetServerClientSetReadonly(virNetServerClientPtr client, + bool readonly) +{ + virObjectLock(client); + client->readonly =3D readonly; + virObjectUnlock(client); +} + + unsigned long long virNetServerClientGetID(virNetServerClientPtr client) { return client->id; diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h index e45c78882..2569f93c3 100644 --- a/src/rpc/virnetserverclient.h +++ b/src/rpc/virnetserverclient.h @@ -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 read= only); unsigned long long virNetServerClientGetID(virNetServerClientPtr client); long long virNetServerClientGetTimestamp(virNetServerClientPtr client); =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list