From nobody Fri May 3 21:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529080209460834.8689378975959; Fri, 15 Jun 2018 09:30:09 -0700 (PDT) Received: from localhost ([::1]:48030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTrbx-0006yW-TR for importer@patchew.org; Fri, 15 Jun 2018 12:30:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTr0O-0008TH-SJ for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTr0N-0006Zx-L2 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57266 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTr0K-0006Vy-KS; Fri, 15 Jun 2018 11:51:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 285AE40122B6; Fri, 15 Jun 2018 15:51:12 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFD9610FD2A6; Fri, 15 Jun 2018 15:51:10 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 16:50:58 +0100 Message-Id: <20180615155103.11924-2-berrange@redhat.com> In-Reply-To: <20180615155103.11924-1-berrange@redhat.com> References: <20180615155103.11924-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 15:51:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 15 Jun 2018 15:51:12 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/6] qemu-nbd: add support for authorization of TLS clients X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Max Reitz , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Currently any client which can complete the TLS handshake is able to use the NBD server. The server admin can turn on the 'verify-peer' option for the x509 creds to require the client to provide a x509 certificate. This means the client will have to acquire a certificate from the CA before they are permitted to use the NBD server. This is still a fairly low bar to cross. This adds a '--tls-authz OBJECT-ID' option to the qemu-nbd command which takes the ID of a previously added 'QAuthZ' object instance. This will be used to validate the client's x509 distinguished name. Clients failing the authorization check will not be permitted to use the NBD server. For example to setup authorization that only allows connection from a client whose x509 certificate distinguished name contains 'CN=3Dfred', you would use: qemu-nbd -object tls-creds-x509,id=3Dtls0,dir=3D/home/berrange/qemutls,\ endpoint=3Dserver,verify-peer=3Dyes \ -object authz-simple,id=3Dauthz0,policy=3Ddeny,\ rules.0.match=3D*CN=3Dfred,rules.0.policy=3Dallow \ -tls-creds tls0 \ -tls-authz authz0 ....other qemu-nbd args... Signed-off-by: Daniel P. Berrange --- include/block/nbd.h | 2 +- nbd/server.c | 12 +++++++----- qemu-nbd.c | 13 ++++++++++++- qemu-nbd.texi | 4 ++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index fcdcd54502..80ea9d240c 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -307,7 +307,7 @@ void nbd_export_close_all(void); void nbd_client_new(NBDExport *exp, QIOChannelSocket *sioc, QCryptoTLSCreds *tlscreds, - const char *tlsaclname, + const char *tlsauthz, void (*close_fn)(NBDClient *, bool)); void nbd_client_get(NBDClient *client); void nbd_client_put(NBDClient *client); diff --git a/nbd/server.c b/nbd/server.c index 9e1f227178..579fc828e1 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -100,7 +100,7 @@ struct NBDClient { =20 NBDExport *exp; QCryptoTLSCreds *tlscreds; - char *tlsaclname; + char *tlsauthz; QIOChannelSocket *sioc; /* The underlying data channel */ QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) = */ =20 @@ -677,7 +677,7 @@ static QIOChannel *nbd_negotiate_handle_starttls(NBDCli= ent *client, =20 tioc =3D qio_channel_tls_new_server(ioc, client->tlscreds, - client->tlsaclname, + client->tlsauthz, errp); if (!tioc) { return NULL; @@ -1250,7 +1250,7 @@ void nbd_client_put(NBDClient *client) if (client->tlscreds) { object_unref(OBJECT(client->tlscreds)); } - g_free(client->tlsaclname); + g_free(client->tlsauthz); if (client->exp) { QTAILQ_REMOVE(&client->exp->clients, client, next); nbd_export_put(client->exp); @@ -2140,7 +2140,7 @@ static coroutine_fn void nbd_co_client_start(void *op= aque) void nbd_client_new(NBDExport *exp, QIOChannelSocket *sioc, QCryptoTLSCreds *tlscreds, - const char *tlsaclname, + const char *tlsauthz, void (*close_fn)(NBDClient *, bool)) { NBDClient *client; @@ -2153,7 +2153,9 @@ void nbd_client_new(NBDExport *exp, if (tlscreds) { object_ref(OBJECT(client->tlscreds)); } - client->tlsaclname =3D g_strdup(tlsaclname); + if (tlsauthz) { + client->tlsauthz =3D g_strdup(tlsauthz); + } client->sioc =3D sioc; object_ref(OBJECT(client->sioc)); client->ioc =3D QIO_CHANNEL(sioc); diff --git a/qemu-nbd.c b/qemu-nbd.c index 51b9d38c72..c0c9c805c0 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -52,6 +52,7 @@ #define QEMU_NBD_OPT_TLSCREDS 261 #define QEMU_NBD_OPT_IMAGE_OPTS 262 #define QEMU_NBD_OPT_FORK 263 +#define QEMU_NBD_OPT_TLSAUTHZ 264 =20 #define MBR_SIZE 512 =20 @@ -66,6 +67,7 @@ static int shared =3D 1; static int nb_fds; static QIONetListener *server; static QCryptoTLSCreds *tlscreds; +static const char *tlsauthz; =20 static void usage(const char *name) { @@ -355,7 +357,7 @@ static void nbd_accept(QIONetListener *listener, QIOCha= nnelSocket *cioc, nb_fds++; nbd_update_server_watch(); nbd_client_new(newproto ? NULL : exp, cioc, - tlscreds, NULL, nbd_client_closed); + tlscreds, tlsauthz, nbd_client_closed); } =20 static void nbd_update_server_watch(void) @@ -533,6 +535,7 @@ int main(int argc, char **argv) { "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS }, { "trace", required_argument, NULL, 'T' }, { "fork", no_argument, NULL, QEMU_NBD_OPT_FORK }, + { "tls-authz", no_argument, NULL, QEMU_NBD_OPT_TLSAUTHZ }, { NULL, 0, NULL, 0 } }; int ch; @@ -755,6 +758,9 @@ int main(int argc, char **argv) g_free(trace_file); trace_file =3D trace_opt_parse(optarg); break; + case QEMU_NBD_OPT_TLSAUTHZ: + tlsauthz =3D optarg; + break; case QEMU_NBD_OPT_FORK: fork_process =3D true; break; @@ -819,6 +825,11 @@ int main(int argc, char **argv) error_get_pretty(local_err)); exit(EXIT_FAILURE); } + } else { + if (tlsauthz) { + error_report("--tls-authz is not permitted without --tls-creds= "); + exit(EXIT_FAILURE); + } } =20 if (disconnect) { diff --git a/qemu-nbd.texi b/qemu-nbd.texi index 9a84e81eed..8f16bfb513 100644 --- a/qemu-nbd.texi +++ b/qemu-nbd.texi @@ -91,6 +91,10 @@ of the TLS credentials object previously created with th= e --object option. @item --fork Fork off the server process and exit the parent once the server is running. +@item --tls-authz=3DID +Specify the ID of a qauthz object previously created with the +--object option. This will be used to authorize users who +connect against their x509 distinguished name. @item -v, --verbose Display extra debugging information @item -h, --help --=20 2.17.0 From nobody Fri May 3 21:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529080095383642.0431808387125; Fri, 15 Jun 2018 09:28:15 -0700 (PDT) Received: from localhost ([::1]:48011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTraA-0005GF-Es for importer@patchew.org; Fri, 15 Jun 2018 12:28:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTr0R-0008Vz-7t for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTr0P-0006bJ-2x for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49074 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTr0M-0006Xk-9P; Fri, 15 Jun 2018 11:51:14 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C95EAFFB5E; Fri, 15 Jun 2018 15:51:13 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5351B10FD2A6; Fri, 15 Jun 2018 15:51:12 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 16:50:59 +0100 Message-Id: <20180615155103.11924-3-berrange@redhat.com> In-Reply-To: <20180615155103.11924-1-berrange@redhat.com> References: <20180615155103.11924-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 15:51:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 15 Jun 2018 15:51:13 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/6] nbd: allow authorization with nbd-server-start QMP command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Max Reitz , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" As with the previous patch to qemu-nbd, the nbd-server-start QMP command also needs to be able to specify authorization when enabling TLS encryption. First the client must create a QAuthZ object instance using the 'object-add' command: { 'execute': 'object-add', 'arguments': { 'qom-type': 'authz-simple', 'id': 'authz0', 'parameters': { 'policy': 'deny', 'rules': [ { 'match': '*CN=3Dfred', 'policy': 'allow' } ] } } } They can then reference this in the new 'tls-authz' parameter when executing the 'nbd-server-start' command: { 'execute': 'nbd-server-start', 'arguments': { 'addr': { 'type': 'inet', 'host': '127.0.0.1', 'port': '9000' }, 'tls-creds': 'tls0', 'tls-authz': 'authz0' } } Signed-off-by: Daniel P. Berrange --- blockdev-nbd.c | 14 +++++++++++--- hmp.c | 2 +- include/block/nbd.h | 2 +- qapi/block.json | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 65a84739ed..1ef2989118 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -23,6 +23,7 @@ typedef struct NBDServerData { QIONetListener *listener; QCryptoTLSCreds *tlscreds; + char *tlsauthz; } NBDServerData; =20 static NBDServerData *nbd_server; @@ -37,7 +38,8 @@ static void nbd_accept(QIONetListener *listener, QIOChann= elSocket *cioc, { qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server"); nbd_client_new(NULL, cioc, - nbd_server->tlscreds, NULL, + nbd_server->tlscreds, + nbd_server->tlsauthz, nbd_blockdev_client_closed); } =20 @@ -53,6 +55,7 @@ static void nbd_server_free(NBDServerData *server) if (server->tlscreds) { object_unref(OBJECT(server->tlscreds)); } + g_free(server->tlsauthz); =20 g_free(server); } @@ -88,7 +91,7 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id,= Error **errp) =20 =20 void nbd_server_start(SocketAddress *addr, const char *tls_creds, - Error **errp) + const char *tls_authz, Error **errp) { if (nbd_server) { error_setg(errp, "NBD server already running"); @@ -118,6 +121,10 @@ void nbd_server_start(SocketAddress *addr, const char = *tls_creds, } } =20 + if (tls_authz) { + nbd_server->tlsauthz =3D g_strdup(tls_authz); + } + qio_net_listener_set_client_func(nbd_server->listener, nbd_accept, NULL, @@ -132,11 +139,12 @@ void nbd_server_start(SocketAddress *addr, const char= *tls_creds, =20 void qmp_nbd_server_start(SocketAddressLegacy *addr, bool has_tls_creds, const char *tls_creds, + bool has_tls_authz, const char *tls_authz, Error **errp) { SocketAddress *addr_flat =3D socket_address_flatten(addr); =20 - nbd_server_start(addr_flat, tls_creds, errp); + nbd_server_start(addr_flat, tls_creds, tls_authz, errp); qapi_free_SocketAddress(addr_flat); } =20 diff --git a/hmp.c b/hmp.c index ef93f4878b..74e18db103 100644 --- a/hmp.c +++ b/hmp.c @@ -2214,7 +2214,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *= qdict) goto exit; } =20 - nbd_server_start(addr, NULL, &local_err); + nbd_server_start(addr, NULL, NULL, &local_err); qapi_free_SocketAddress(addr); if (local_err !=3D NULL) { goto exit; diff --git a/include/block/nbd.h b/include/block/nbd.h index 80ea9d240c..8a8ae8c3a7 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -313,7 +313,7 @@ void nbd_client_get(NBDClient *client); void nbd_client_put(NBDClient *client); =20 void nbd_server_start(SocketAddress *addr, const char *tls_creds, - Error **errp); + const char *tls_authz, Error **errp); =20 =20 /* nbd_read diff --git a/qapi/block.json b/qapi/block.json index c694524002..8c7cc9b798 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -197,6 +197,7 @@ # # @addr: Address on which to listen. # @tls-creds: (optional) ID of the TLS credentials object. Since 2.6 +# @tls-authz: (optional) ID of the QAuthZ authorization object. Since 2.13 # # Returns: error if the server is already running. # @@ -204,7 +205,8 @@ ## { 'command': 'nbd-server-start', 'data': { 'addr': 'SocketAddressLegacy', - '*tls-creds': 'str'} } + '*tls-creds': 'str', + '*tls-authz': 'str'} } =20 ## # @nbd-server-add: --=20 2.17.0 From nobody Fri May 3 21:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529080244725179.38971044787138; Fri, 15 Jun 2018 09:30:44 -0700 (PDT) Received: from localhost ([::1]:48033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTrcZ-0007Vq-VO for importer@patchew.org; Fri, 15 Jun 2018 12:30:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTr0U-00007K-1D for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTr0S-0006cy-Mg for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:22 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58442 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTr0N-0006a1-V1; Fri, 15 Jun 2018 11:51:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70FC787A81; Fri, 15 Jun 2018 15:51:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0101F10FD2A6; Fri, 15 Jun 2018 15:51:13 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 16:51:00 +0100 Message-Id: <20180615155103.11924-4-berrange@redhat.com> In-Reply-To: <20180615155103.11924-1-berrange@redhat.com> References: <20180615155103.11924-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 15 Jun 2018 15:51:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 15 Jun 2018 15:51:15 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 3/6] migration: add support for a "tls-authz" migration parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Max Reitz , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The QEMU instance that runs as the server for the migration data transport (ie the target QEMU) needs to be able to configure access control so it can prevent unauthorized clients initiating an incoming migration. This adds a new 'tls-authz' migration parameter that is used to provide the QOM ID of a QAuthZ subclass instance that provides the access control check. This is checked against the x509 certificate obtained during the TLS handshake. Signed-off-by: Daniel P. Berrange Reviewed-by: Dr. David Alan Gilbert --- hmp.c | 9 +++++++++ migration/migration.c | 8 ++++++++ migration/tls.c | 2 +- qapi/migration.json | 12 +++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/hmp.c b/hmp.c index 74e18db103..bef8ea2531 100644 --- a/hmp.c +++ b/hmp.c @@ -370,6 +370,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); + monitor_printf(mon, " %s: '%s'\n", + MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ), + params->has_tls_authz ? params->tls_authz : ""); } =20 qapi_free_MigrationParameters(params); @@ -1632,6 +1635,12 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->tls_hostname->type =3D QTYPE_QSTRING; visit_type_str(v, param, &p->tls_hostname->u.s, &err); break; + case MIGRATION_PARAMETER_TLS_AUTHZ: + p->has_tls_authz =3D true; + p->tls_authz =3D g_new0(StrOrNull, 1); + p->tls_authz->type =3D QTYPE_QSTRING; + visit_type_str(v, param, &p->tls_authz->u.s, &err); + break; case MIGRATION_PARAMETER_MAX_BANDWIDTH: p->has_max_bandwidth =3D true; /* diff --git a/migration/migration.c b/migration/migration.c index 1e99ec9b7e..d14c8d7003 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -645,6 +645,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->tls_creds =3D g_strdup(s->parameters.tls_creds); params->has_tls_hostname =3D true; params->tls_hostname =3D g_strdup(s->parameters.tls_hostname); + params->has_tls_authz =3D true; + params->tls_authz =3D g_strdup(s->parameters.tls_authz); params->has_max_bandwidth =3D true; params->max_bandwidth =3D s->parameters.max_bandwidth; params->has_downtime_limit =3D true; @@ -1106,6 +1108,12 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) s->parameters.tls_hostname =3D g_strdup(params->tls_hostname->u.s); } =20 + if (params->has_tls_authz) { + g_free(s->parameters.tls_authz); + assert(params->tls_authz->type =3D=3D QTYPE_QSTRING); + s->parameters.tls_authz =3D g_strdup(params->tls_authz->u.s); + } + if (params->has_max_bandwidth) { s->parameters.max_bandwidth =3D params->max_bandwidth; if (s->to_dst_file) { diff --git a/migration/tls.c b/migration/tls.c index 3b9e8c9263..5171afc6c4 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -94,7 +94,7 @@ void migration_tls_channel_process_incoming(MigrationStat= e *s, =20 tioc =3D qio_channel_tls_new_server( ioc, creds, - NULL, /* XXX pass ACL name */ + s->parameters.tls_authz, errp); if (!tioc) { return; diff --git a/qapi/migration.json b/qapi/migration.json index f7e10ee90f..b9ba34e3a6 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -488,6 +488,10 @@ # hostname must be provided so that the server's x509 # certificate identity can be validated. (Since 2.7) # +# @tls-authz: ID of the 'authz' object subclass that provides access contr= ol +# checking of the TLS x509 certificate distinguished name. (Si= nce +# 2.13) +# # @max-bandwidth: to set maximum speed for migration. maximum speed in # bytes per second. (Since 2.8) # @@ -522,7 +526,7 @@ { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname', 'max-bandwidth', + 'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'x-multifd-channels', 'x-multifd-page-count', 'xbzrle-cache-size' ] } @@ -605,6 +609,7 @@ '*cpu-throttle-increment': 'int', '*tls-creds': 'StrOrNull', '*tls-hostname': 'StrOrNull', + '*tls-authz': 'StrOrNull', '*max-bandwidth': 'int', '*downtime-limit': 'int', '*x-checkpoint-delay': 'int', @@ -667,6 +672,10 @@ # associated with the migration URI, if any. (Since 2.9) # Note: 2.8 reports this by omitting tls-hostname instead. # +# @tls-authz: ID of the 'authz' object subclass that provides access contr= ol +# checking of the TLS x509 certificate distinguished name. (Si= nce +# 2.13) +# # @max-bandwidth: to set maximum speed for migration. maximum speed in # bytes per second. (Since 2.8) # @@ -704,6 +713,7 @@ '*cpu-throttle-increment': 'uint8', '*tls-creds': 'str', '*tls-hostname': 'str', + '*tls-authz': 'str', '*max-bandwidth': 'size', '*downtime-limit': 'uint64', '*x-checkpoint-delay': 'uint32', --=20 2.17.0 From nobody Fri May 3 21:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529078833355284.99452772081486; Fri, 15 Jun 2018 09:07:13 -0700 (PDT) Received: from localhost ([::1]:47827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTrFn-0003vJ-HD for importer@patchew.org; Fri, 15 Jun 2018 12:07:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTr0T-00007H-V7 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTr0S-0006d9-QL for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:22 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53176 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTr0P-0006bO-Ia; Fri, 15 Jun 2018 11:51:17 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 103D180125D6; Fri, 15 Jun 2018 15:51:17 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9918410FD2A6; Fri, 15 Jun 2018 15:51:15 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 16:51:01 +0100 Message-Id: <20180615155103.11924-5-berrange@redhat.com> In-Reply-To: <20180615155103.11924-1-berrange@redhat.com> References: <20180615155103.11924-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 15 Jun 2018 15:51:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 15 Jun 2018 15:51:17 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 4/6] chardev: add support for authorization for TLS clients X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Max Reitz , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Currently any client which can complete the TLS handshake is able to use a chardev server. The server admin can turn on the 'verify-peer' option for the x509 creds to require the client to provide a x509 certificate. This means the client will have to acquire a certificate from the CA before they are permitted to use the chardev server. This is still a fairly low bar. This adds a 'tls-authz=3DOBJECT-ID' option to the socket chardev backend which takes the ID of a previously added 'QAuthZ' object instance. This will be used to validate the client's x509 distinguished name. Clients failing the check will not be permitted to use the chardev server. For example to setup authorization that only allows connection from a client whose x509 certificate distinguished name contains 'CN=3Dfred', you would use: $QEMU -object tls-creds-x509,id=3Dtls0,dir=3D/home/berrange/qemutls,\ endpoint=3Dserver,verify-peer=3Dyes \ -object authz-simple,id=3Dauthz0,policy=3Ddeny,\ rules.0.match=3D\*CN=3Dfred,rules.0.policy=3Dallow \ -chardev socket,host=3D127.0.0.1,port=3D9000,server,\ tls-creds=3Dtls0,tls-authz=3Dauthz0 \ ...other qemud args... Signed-off-by: Daniel P. Berrange --- chardev/char-socket.c | 11 ++++++++++- chardev/char.c | 3 +++ qapi/char.json | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 159e69c3b1..d0c9d26025 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -53,6 +53,7 @@ typedef struct { QIONetListener *listener; GSource *hup_source; QCryptoTLSCreds *tls_creds; + char *tls_authz; int connected; int max_size; int do_telnetopt; @@ -729,7 +730,7 @@ static void tcp_chr_tls_init(Chardev *chr) if (s->is_listen) { tioc =3D qio_channel_tls_new_server( s->ioc, s->tls_creds, - NULL, /* XXX Use an ACL */ + s->tls_authz, &err); } else { tioc =3D qio_channel_tls_new_client( @@ -881,6 +882,7 @@ static void char_socket_finalize(Object *obj) if (s->tls_creds) { object_unref(OBJECT(s->tls_creds)); } + g_free(s->tls_authz); =20 qemu_chr_be_event(chr, CHR_EVENT_CLOSED); } @@ -986,6 +988,7 @@ static void qmp_chardev_open_socket(Chardev *chr, } } } + s->tls_authz =3D g_strdup(sock->tls_authz); =20 s->addr =3D addr =3D socket_address_flatten(sock->addr); =20 @@ -1066,6 +1069,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, const char *fd =3D qemu_opt_get(opts, "fd"); const char *tls_creds =3D qemu_opt_get(opts, "tls-creds"); SocketAddressLegacy *addr; + const char *tls_authz =3D qemu_opt_get(opts, "tls-authz"); ChardevSocket *sock; =20 if ((!!path + !!fd + !!host) !=3D 1) { @@ -1094,6 +1098,10 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Ch= ardevBackend *backend, } else { g_assert_not_reached(); } + if (tls_authz && !tls_creds) { + error_setg(errp, "Authorization can only be used when TLS is enabl= ed"); + return; + } =20 sock =3D backend->u.socket.data =3D g_new0(ChardevSocket, 1); qemu_chr_parse_common(opts, qapi_ChardevSocket_base(sock)); @@ -1111,6 +1119,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, Cha= rdevBackend *backend, sock->has_reconnect =3D true; sock->reconnect =3D reconnect; sock->tls_creds =3D g_strdup(tls_creds); + sock->tls_authz =3D g_strdup(tls_authz); =20 addr =3D g_new0(SocketAddressLegacy, 1); if (path) { diff --git a/chardev/char.c b/chardev/char.c index 76d866e6fe..d28c16ccca 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -837,6 +837,9 @@ QemuOptsList qemu_chardev_opts =3D { },{ .name =3D "tls-creds", .type =3D QEMU_OPT_STRING, + },{ + .name =3D "tls-authz", + .type =3D QEMU_OPT_STRING, },{ .name =3D "width", .type =3D QEMU_OPT_NUMBER, diff --git a/qapi/char.json b/qapi/char.json index ae19dcd1ed..284f3ee4f1 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -242,6 +242,7 @@ # @addr: socket address to listen on (server=3Dtrue) # or connect to (server=3Dfalse) # @tls-creds: the ID of the TLS credentials object (since 2.6) +# @tls-authz: the ID of the QAuthZ authorization object (since 2.13) # @server: create server socket (default: true) # @wait: wait for incoming connection on server # sockets (default: false). @@ -259,6 +260,7 @@ ## { 'struct': 'ChardevSocket', 'data': { 'addr' : 'SocketAddressLegacy= ', '*tls-creds' : 'str', + '*tls-authz' : 'str', '*server' : 'bool', '*wait' : 'bool', '*nodelay' : 'bool', --=20 2.17.0 From nobody Fri May 3 21:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529080778455589.7085479996233; Fri, 15 Jun 2018 09:39:38 -0700 (PDT) Received: from localhost ([::1]:48149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTrl8-00062N-2u for importer@patchew.org; Fri, 15 Jun 2018 12:39:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTr0V-00009f-Sv for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTr0U-0006fB-Hf for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53182 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTr0R-0006bp-6A; Fri, 15 Jun 2018 11:51:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB87480125D6; Fri, 15 Jun 2018 15:51:18 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A27910FD2AF; Fri, 15 Jun 2018 15:51:17 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 16:51:02 +0100 Message-Id: <20180615155103.11924-6-berrange@redhat.com> In-Reply-To: <20180615155103.11924-1-berrange@redhat.com> References: <20180615155103.11924-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 15 Jun 2018 15:51:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 15 Jun 2018 15:51:18 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 5/6] vnc: allow specifying a custom authorization object name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Max Reitz , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The VNC server has historically had support for ACLs to check both the SASL username and the TLS x509 distinguished name. The VNC server was responsible for creating the initial ACL, and the client app was then responsible for populating it with rules using the HMP 'acl_add' command. This is not satisfactory for a variety of reasons. There is no way to populate the ACLs from the command line, users are forced to use the HMP. With multiple network services all supporting TLS and ACLs now, it is desirable to be able to define a single ACL that is referenced by all services. To address these limitations, two new options are added to the VNC server CLI. The 'tls-authz' option takes the ID of a QAuthZ object to use for checking TLS x509 distinguished names, and the 'sasl-authz' option takes the ID of another object to use for checking SASL usernames. In this example, we setup two authorization rules. The first allows any client with a certificate issued by the 'RedHat' organization in the 'London' locality. The second ACL allows clients with either the 'joe@REDHAT.COM' or 'fred@REDHAT.COM' kerberos usernames. Both checks must pass for the user to be allowed. $QEMU -object tls-creds-x509,id=3Dtls0,dir=3D/home/berrange/qemutls,\ endpoint=3Dserver,verify-peer=3Dyes \ -object authz-simple,id=3Dauthz0,policy=3Ddeny,\ rules.0.match=3DO=3DRedHat,,L=3DLondon,rules.0.policy=3Da= llow \ -object authz-simple,id=3Dauthz1,policy=3Ddeny,\ rules.0.match=3Dfred@REDHAT.COM,rules.0.policy=3Dallow \ rules.0.match=3Djoe@REDHAT.COM,rules.0.policy=3Dallow \ -vnc 0.0.0.0:1,tls-creds=3Dtls0,tls-authz=3Dauthz0, sasl,sasl-authz=3Dauthz1 \ ...other QEMU args... Signed-off-by: Daniel P. Berrange --- qemu-doc.texi | 11 +++------- ui/vnc.c | 58 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/qemu-doc.texi b/qemu-doc.texi index cd05760cac..5b7e3faab2 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2917,15 +2917,10 @@ The @code{-localtime} option has been replaced by @= code{-rtc base=3Dlocaltime}. =20 The @code{-startdate} option has been replaced by @code{-rtc base=3D@var{d= ate}}. =20 -@subsection -virtioconsole (since 3.0.0) +@subsection -vnc acl (since 3.0.0) =20 -Option @option{-virtioconsole} has been replaced by -@option{-device virtconsole}. - -@subsection -clock (since 3.0.0) - -The @code{-clock} option is ignored since QEMU version 1.7.0. There is no -replacement since it is not needed anymore. +The @code{acl} option to the @code{-vnc} argument has been replaced +by the @code{tls-authz} and @code{sasl-authz} options. =20 @section QEMU Machine Protocol (QMP) commands =20 diff --git a/ui/vnc.c b/ui/vnc.c index 9fb8430c35..2da9433ca7 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3407,6 +3407,12 @@ static QemuOptsList qemu_vnc_opts =3D { },{ .name =3D "acl", .type =3D QEMU_OPT_BOOL, + },{ + .name =3D "tls-authz", + .type =3D QEMU_OPT_STRING, + },{ + .name =3D "sasl-authz", + .type =3D QEMU_OPT_STRING, },{ .name =3D "lossy", .type =3D QEMU_OPT_BOOL, @@ -3894,6 +3900,8 @@ void vnc_display_open(const char *id, Error **errp) int saslErr; #endif int acl =3D 0; + const char *tlsauthz; + const char *saslauthz; int lock_key_sync =3D 1; int key_delay_ms; =20 @@ -3999,7 +4007,33 @@ void vnc_display_open(const char *id, Error **errp) } } } + if (qemu_opt_get(opts, "acl")) { + error_report("The 'acl' option to -vnc is deprecated. " + "Please use the 'tls-authz' and 'sasl-authz' " + "options instead"); + } acl =3D qemu_opt_get_bool(opts, "acl", false); + tlsauthz =3D qemu_opt_get(opts, "tls-authz"); + if (acl && tlsauthz) { + error_setg(errp, "'acl' option is mutually exclusive with the " + "'tls-authz' option"); + goto fail; + } + if (tlsauthz && !vd->tlscreds) { + error_setg(errp, "'tls-authz' provided but TLS is not enabled"); + goto fail; + } + + saslauthz =3D qemu_opt_get(opts, "sasl-authz"); + if (acl && saslauthz) { + error_setg(errp, "'acl' option is mutually exclusive with the " + "'sasl-authz' option"); + goto fail; + } + if (saslauthz && !sasl) { + error_setg(errp, "'sasl-authz' provided but SASL auth is not enabl= ed"); + goto fail; + } =20 share =3D qemu_opt_get(opts, "share"); if (share) { @@ -4029,7 +4063,9 @@ void vnc_display_open(const char *id, Error **errp) vd->non_adaptive =3D true; } =20 - if (acl) { + if (tlsauthz) { + vd->tlsauthzid =3D g_strdup(tlsauthz); + } else if (acl) { if (strcmp(vd->id, "default") =3D=3D 0) { vd->tlsauthzid =3D g_strdup("vnc.x509dname"); } else { @@ -4040,15 +4076,19 @@ void vnc_display_open(const char *id, Error **errp) &error_abort)); } #ifdef CONFIG_VNC_SASL - if (acl && sasl) { - if (strcmp(vd->id, "default") =3D=3D 0) { - vd->sasl.authzid =3D g_strdup("vnc.username"); - } else { - vd->sasl.authzid =3D g_strdup_printf("vnc.%s.username", vd->id= ); + if (sasl) { + if (saslauthz) { + vd->sasl.authzid =3D g_strdup(saslauthz); + } else if (acl) { + if (strcmp(vd->id, "default") =3D=3D 0) { + vd->sasl.authzid =3D g_strdup("vnc.username"); + } else { + vd->sasl.authzid =3D g_strdup_printf("vnc.%s.username", vd= ->id); + } + vd->sasl.authz =3D QAUTHZ(qauthz_list_new(vd->sasl.authzid, + QAUTHZ_LIST_POLICY_DEN= Y, + &error_abort)); } - vd->sasl.authz =3D QAUTHZ(qauthz_list_new(vd->sasl.authzid, - QAUTHZ_LIST_POLICY_DENY, - &error_abort)); } #endif =20 --=20 2.17.0 From nobody Fri May 3 21:25:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529079012379998.0442695471888; Fri, 15 Jun 2018 09:10:12 -0700 (PDT) Received: from localhost ([::1]:47859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTrIg-0006Q5-79 for importer@patchew.org; Fri, 15 Jun 2018 12:10:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTr0W-0000AK-Cb for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTr0V-0006fj-81 for qemu-devel@nongnu.org; Fri, 15 Jun 2018 11:51:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53184 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fTr0S-0006cm-Pk; Fri, 15 Jun 2018 11:51:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F5CC80125D6; Fri, 15 Jun 2018 15:51:20 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5F1C10FD2A3; Fri, 15 Jun 2018 15:51:18 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 16:51:03 +0100 Message-Id: <20180615155103.11924-7-berrange@redhat.com> In-Reply-To: <20180615155103.11924-1-berrange@redhat.com> References: <20180615155103.11924-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 15 Jun 2018 15:51:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 15 Jun 2018 15:51:20 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'berrange@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 6/6] monitor: deprecate acl_show, acl_reset, acl_policy, acl_add, acl_remove X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , Markus Armbruster , Max Reitz , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The various ACL related commands are obsolete now that the QAuthZ framework for authorization is fully integrated throughout QEMU network services. Mark it as deprecated with no replacement to be provided. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- monitor.c | 23 +++++++++++++++++++++++ qemu-doc.texi | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/monitor.c b/monitor.c index 67c63013bd..c4a9ae5c85 100644 --- a/monitor.c +++ b/monitor.c @@ -2089,6 +2089,19 @@ static QAuthZList *find_auth(Monitor *mon, const cha= r *name) return QAUTHZ_LIST(obj); } =20 +static bool warn_acl; +static void hmp_warn_acl(void) +{ + if (warn_acl) { + return; + } + error_report("The acl_show, acl_reset, acl_policy, acl_add, acl_remove= " + "commands are deprecated with no replacement. Authorizati= on " + "for VNC should be performed using the pluggable QAuthZ " + "objects"); + warn_acl =3D true; +} + static void hmp_acl_show(Monitor *mon, const QDict *qdict) { const char *aclname =3D qdict_get_str(qdict, "aclname"); @@ -2096,6 +2109,8 @@ static void hmp_acl_show(Monitor *mon, const QDict *q= dict) QAuthZListRuleList *rules; size_t i =3D 0; =20 + hmp_warn_acl(); + if (!auth) { return; } @@ -2119,6 +2134,8 @@ static void hmp_acl_reset(Monitor *mon, const QDict *= qdict) const char *aclname =3D qdict_get_str(qdict, "aclname"); QAuthZList *auth =3D find_auth(mon, aclname); =20 + hmp_warn_acl(); + if (!auth) { return; } @@ -2137,6 +2154,8 @@ static void hmp_acl_policy(Monitor *mon, const QDict = *qdict) int val; Error *err =3D NULL; =20 + hmp_warn_acl(); + if (!auth) { return; } @@ -2172,6 +2191,8 @@ static void hmp_acl_add(Monitor *mon, const QDict *qd= ict) QAuthZListFormat format; size_t i =3D 0; =20 + hmp_warn_acl(); + if (!auth) { return; } @@ -2227,6 +2248,8 @@ static void hmp_acl_remove(Monitor *mon, const QDict = *qdict) QAuthZList *auth =3D find_auth(mon, aclname); ssize_t i =3D 0; =20 + hmp_warn_acl(); + if (!auth) { return; } diff --git a/qemu-doc.texi b/qemu-doc.texi index 5b7e3faab2..c6aad94015 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2938,6 +2938,14 @@ The ``query-cpus'' command is replaced by the ``quer= y-cpus-fast'' command. The ``arch'' output member of the ``query-cpus-fast'' command is replaced by the ``target'' output member. =20 +@section Human Monitor Protocol (HMP) commands + +@subsection acl_show, acl_reset, acl_policy, acl_add, acl_remove (since 3.= 0.0) + +The ``acl_show'', ``acl_reset'', ``acl_policy'', ``acl_add'', and +``acl_remove'' commands are deprecated with no replacement. Authorization +for VNC should be performed using the pluggable QAuthZ objects. + @section System emulator devices =20 @subsection ivshmem (since 2.6.0) --=20 2.17.0