All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections
@ 2019-02-27 14:57 Daniel P. Berrangé
  2019-02-27 14:57 ` [Qemu-devel] [PATCH 1/2] vnc: allow specifying a custom authorization object name Daniel P. Berrangé
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2019-02-27 14:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Dr. David Alan Gilbert, libvir-list, Gerd Hoffmann,
	Markus Armbruster, Daniel P. Berrangé

This series provides the VNC parts of the authorization control series
previously posted as:

  v1: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg04482.html
  v2: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg05727.html
  v3: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg01639.html
  v4: https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg04319.html

The core authz framework is now merged & these patches have all had
positive review. Thus these VNC parts are ready to go into the VNC
maintainer's tree, should the maintainer consider them acceptable.

Note the 2nd patch is modifying the HMP, but I considered it part
of ui/vnc, since that's the only bit of QEMU which ever used these
HMP commands, and it has a dependancy on the first patch merging
first.

Daniel P. Berrangé (2):
  vnc: allow specifying a custom authorization object name
  monitor: deprecate acl_show, acl_reset, acl_policy, acl_add,
    acl_remove

 monitor.c            | 23 ++++++++++++++++++
 qemu-deprecated.texi | 11 +++++++++
 qemu-options.hx      | 35 ++++++++++++++++++--------
 ui/vnc.c             | 58 +++++++++++++++++++++++++++++++++++++-------
 4 files changed, 108 insertions(+), 19 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 1/2] vnc: allow specifying a custom authorization object name
  2019-02-27 14:57 [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
@ 2019-02-27 14:57 ` Daniel P. Berrangé
  2019-02-27 14:57 ` [Qemu-devel] [PATCH 2/2] monitor: deprecate acl_show, acl_reset, acl_policy, acl_add, acl_remove Daniel P. Berrangé
  2019-03-07 12:23 ` [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2019-02-27 14:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Dr. David Alan Gilbert, libvir-list, Gerd Hoffmann,
	Markus Armbruster, Daniel P. Berrange, Juan Quintela

From: "Daniel P. Berrange" <berrange@redhat.com>

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=tls0,dir=/home/berrange/qemutls,\
                  endpoint=server,verify-peer=yes \
          -object authz-simple,id=authz0,policy=deny,\
                  rules.0.match=O=RedHat,,L=London,rules.0.policy=allow \
          -object authz-simple,id=authz1,policy=deny,\
                  rules.0.match=fred@REDHAT.COM,rules.0.policy=allow \
                  rules.0.match=joe@REDHAT.COM,rules.0.policy=allow \
          -vnc 0.0.0.0:1,tls-creds=tls0,tls-authz=authz0,
	       sasl,sasl-authz=authz1 \
          ...other QEMU args...

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 qemu-deprecated.texi |  5 ++++
 qemu-options.hx      | 35 ++++++++++++++++++--------
 ui/vnc.c             | 58 +++++++++++++++++++++++++++++++++++++-------
 3 files changed, 79 insertions(+), 19 deletions(-)

diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 45c57952da..1258da4795 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -60,6 +60,11 @@ Support for invalid topologies will be removed, the user must ensure
 topologies described with -smp include all possible cpus, i.e.
   @math{@var{sockets} * @var{cores} * @var{threads} = @var{maxcpus}}.
 
+@subsection -vnc acl (since 4.0.0)
+
+The @code{acl} option to the @code{-vnc} argument has been replaced
+by the @code{tls-authz} and @code{sasl-authz} options.
+
 @section QEMU Machine Protocol (QMP) commands
 
 @subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0)
diff --git a/qemu-options.hx b/qemu-options.hx
index 1cf9aac1fe..c74f99b265 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1624,6 +1624,14 @@ will cause the VNC server socket to enable the VeNCrypt auth
 mechanism.  The credentials should have been previously created
 using the @option{-object tls-creds} argument.
 
+@item tls-authz=@var{ID}
+
+Provides the ID of the QAuthZ authorization object against which
+the client's x509 distinguished name will validated. This object is
+only resolved at time of use, so can be deleted and recreated on the
+fly while the VNC server is active. If missing, it will default
+to denying access.
+
 @item sasl
 
 Require that the client use SASL to authenticate with the VNC server.
@@ -1639,18 +1647,25 @@ ensures a data encryption preventing compromise of authentication
 credentials. See the @ref{vnc_security} section for details on using
 SASL authentication.
 
+@item sasl-authz=@var{ID}
+
+Provides the ID of the QAuthZ authorization object against which
+the client's SASL username will validated. This object is
+only resolved at time of use, so can be deleted and recreated on the
+fly while the VNC server is active. If missing, it will default
+to denying access.
+
 @item acl
 
-Turn on access control lists for checking of the x509 client certificate
-and SASL party. For x509 certs, the ACL check is made against the
-certificate's distinguished name. This is something that looks like
-@code{C=GB,O=ACME,L=Boston,CN=bob}. For SASL party, the ACL check is
-made against the username, which depending on the SASL plugin, may
-include a realm component, eg @code{bob} or @code{bob@@EXAMPLE.COM}.
-When the @option{acl} flag is set, the initial access list will be
-empty, with a @code{deny} policy. Thus no one will be allowed to
-use the VNC server until the ACLs have been loaded. This can be
-achieved using the @code{acl} monitor command.
+Legacy method for enabling authorization of clients against the
+x509 distinguished name and SASL username. It results in the creation
+of two @code{authz-list} objects with IDs of @code{vnc.username} and
+@code{vnc.x509dname}. The rules for these objects must be configured
+with the HMP ACL commands.
+
+This option is deprecated and should no longer be used. The new
+@option{sasl-authz} and @option{tls-authz} options are a
+replacement.
 
 @item lossy
 
diff --git a/ui/vnc.c b/ui/vnc.c
index da4a21d4ce..15d6d2c5d3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3357,6 +3357,12 @@ static QemuOptsList qemu_vnc_opts = {
         },{
             .name = "acl",
             .type = QEMU_OPT_BOOL,
+        },{
+            .name = "tls-authz",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "sasl-authz",
+            .type = QEMU_OPT_STRING,
         },{
             .name = "lossy",
             .type = QEMU_OPT_BOOL,
@@ -3796,6 +3802,8 @@ void vnc_display_open(const char *id, Error **errp)
     const char *credid;
     bool sasl = false;
     int acl = 0;
+    const char *tlsauthz;
+    const char *saslauthz;
     int lock_key_sync = 1;
     int key_delay_ms;
 
@@ -3867,7 +3875,33 @@ void vnc_display_open(const char *id, Error **errp)
             goto fail;
         }
     }
+    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 = qemu_opt_get_bool(opts, "acl", false);
+    tlsauthz = 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 = 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 enabled");
+        goto fail;
+    }
 
     share = qemu_opt_get(opts, "share");
     if (share) {
@@ -3897,7 +3931,9 @@ void vnc_display_open(const char *id, Error **errp)
         vd->non_adaptive = true;
     }
 
-    if (acl) {
+    if (tlsauthz) {
+        vd->tlsauthzid = g_strdup(tlsauthz);
+    } else if (acl) {
         if (strcmp(vd->id, "default") == 0) {
             vd->tlsauthzid = g_strdup("vnc.x509dname");
         } else {
@@ -3908,15 +3944,19 @@ void vnc_display_open(const char *id, Error **errp)
                                               &error_abort));
     }
 #ifdef CONFIG_VNC_SASL
-    if (acl && sasl) {
-        if (strcmp(vd->id, "default") == 0) {
-            vd->sasl.authzid = g_strdup("vnc.username");
-        } else {
-            vd->sasl.authzid = g_strdup_printf("vnc.%s.username", vd->id);
+    if (sasl) {
+        if (saslauthz) {
+            vd->sasl.authzid = g_strdup(saslauthz);
+        } else if (acl) {
+            if (strcmp(vd->id, "default") == 0) {
+                vd->sasl.authzid = g_strdup("vnc.username");
+            } else {
+                vd->sasl.authzid = g_strdup_printf("vnc.%s.username", vd->id);
+            }
+            vd->sasl.authz = QAUTHZ(qauthz_list_new(vd->sasl.authzid,
+                                                    QAUTHZ_LIST_POLICY_DENY,
+                                                    &error_abort));
         }
-        vd->sasl.authz = QAUTHZ(qauthz_list_new(vd->sasl.authzid,
-                                                QAUTHZ_LIST_POLICY_DENY,
-                                                &error_abort));
     }
 #endif
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 2/2] monitor: deprecate acl_show, acl_reset, acl_policy, acl_add, acl_remove
  2019-02-27 14:57 [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
  2019-02-27 14:57 ` [Qemu-devel] [PATCH 1/2] vnc: allow specifying a custom authorization object name Daniel P. Berrangé
@ 2019-02-27 14:57 ` Daniel P. Berrangé
  2019-03-07 12:23 ` [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2019-02-27 14:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Dr. David Alan Gilbert, libvir-list, Gerd Hoffmann,
	Markus Armbruster, Daniel P. Berrangé,
	Juan Quintela

The various ACL related commands are obsolete now that the QAuthZ
framework for authorization is fully integrated throughout QEMU network
services. These only ever worked with VNC and were never used by libvirt.
Mark it as deprecated with no direct replacement to be provided.

Authorization is now provided by using 'object_add' together with
the 'tls-authz' or 'sasl-authz' parameters to the VNC server, and
equivalent for other network services.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 monitor.c            | 23 +++++++++++++++++++++++
 qemu-deprecated.texi |  6 ++++++
 2 files changed, 29 insertions(+)

diff --git a/monitor.c b/monitor.c
index defa129319..72061d5bae 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2032,6 +2032,19 @@ static QAuthZList *find_auth(Monitor *mon, const char *name)
     return QAUTHZ_LIST(obj);
 }
 
+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. Authorization "
+                 "for VNC should be performed using the pluggable QAuthZ "
+                 "objects");
+    warn_acl = true;
+}
+
 static void hmp_acl_show(Monitor *mon, const QDict *qdict)
 {
     const char *aclname = qdict_get_str(qdict, "aclname");
@@ -2039,6 +2052,8 @@ static void hmp_acl_show(Monitor *mon, const QDict *qdict)
     QAuthZListRuleList *rules;
     size_t i = 0;
 
+    hmp_warn_acl();
+
     if (!auth) {
         return;
     }
@@ -2062,6 +2077,8 @@ static void hmp_acl_reset(Monitor *mon, const QDict *qdict)
     const char *aclname = qdict_get_str(qdict, "aclname");
     QAuthZList *auth = find_auth(mon, aclname);
 
+    hmp_warn_acl();
+
     if (!auth) {
         return;
     }
@@ -2080,6 +2097,8 @@ static void hmp_acl_policy(Monitor *mon, const QDict *qdict)
     int val;
     Error *err = NULL;
 
+    hmp_warn_acl();
+
     if (!auth) {
         return;
     }
@@ -2124,6 +2143,8 @@ static void hmp_acl_add(Monitor *mon, const QDict *qdict)
     QAuthZListFormat format;
     size_t i = 0;
 
+    hmp_warn_acl();
+
     if (!auth) {
         return;
     }
@@ -2169,6 +2190,8 @@ static void hmp_acl_remove(Monitor *mon, const QDict *qdict)
     QAuthZList *auth = find_auth(mon, aclname);
     ssize_t i = 0;
 
+    hmp_warn_acl();
+
     if (!auth) {
         return;
     }
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 1258da4795..1e15f57e9c 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -104,6 +104,12 @@ The @option{[hub_id name]} parameter tuple of the 'hostfwd_add' and
 Use ``device_add'' for hotplugging vCPUs instead of ``cpu-add''.  See
 documentation of ``query-hotpluggable-cpus'' for additional details.
 
+@subsection acl_show, acl_reset, acl_policy, acl_add, acl_remove (since 4.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
 
 @subsection bluetooth (since 3.1)
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections
  2019-02-27 14:57 [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
  2019-02-27 14:57 ` [Qemu-devel] [PATCH 1/2] vnc: allow specifying a custom authorization object name Daniel P. Berrangé
  2019-02-27 14:57 ` [Qemu-devel] [PATCH 2/2] monitor: deprecate acl_show, acl_reset, acl_policy, acl_add, acl_remove Daniel P. Berrangé
@ 2019-03-07 12:23 ` Daniel P. Berrangé
  2019-03-07 13:27   ` Gerd Hoffmann
  2 siblings, 1 reply; 6+ messages in thread
From: Daniel P. Berrangé @ 2019-03-07 12:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: Dr. David Alan Gilbert, libvir-list, Gerd Hoffmann, Markus Armbruster

ping - soft freeze is less than a week away & i'd like this to get into
a ui queue pull request in time for 4.0 if there's no review objections

On Wed, Feb 27, 2019 at 02:57:53PM +0000, Daniel P. Berrangé wrote:
> This series provides the VNC parts of the authorization control series
> previously posted as:
> 
>   v1: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg04482.html
>   v2: https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg05727.html
>   v3: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg01639.html
>   v4: https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg04319.html
> 
> The core authz framework is now merged & these patches have all had
> positive review. Thus these VNC parts are ready to go into the VNC
> maintainer's tree, should the maintainer consider them acceptable.
> 
> Note the 2nd patch is modifying the HMP, but I considered it part
> of ui/vnc, since that's the only bit of QEMU which ever used these
> HMP commands, and it has a dependancy on the first patch merging
> first.
> 
> Daniel P. Berrangé (2):
>   vnc: allow specifying a custom authorization object name
>   monitor: deprecate acl_show, acl_reset, acl_policy, acl_add,
>     acl_remove
> 
>  monitor.c            | 23 ++++++++++++++++++
>  qemu-deprecated.texi | 11 +++++++++
>  qemu-options.hx      | 35 ++++++++++++++++++--------
>  ui/vnc.c             | 58 +++++++++++++++++++++++++++++++++++++-------
>  4 files changed, 108 insertions(+), 19 deletions(-)
> 
> -- 
> 2.20.1
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections
  2019-03-07 12:23 ` [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
@ 2019-03-07 13:27   ` Gerd Hoffmann
  2019-03-07 13:32     ` Daniel P. Berrangé
  0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2019-03-07 13:27 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: qemu-devel, Dr. David Alan Gilbert, libvir-list, Markus Armbruster

On Thu, Mar 07, 2019 at 12:23:58PM +0000, Daniel P. Berrangé wrote:
> ping - soft freeze is less than a week away & i'd like this to get into
> a ui queue pull request in time for 4.0 if there's no review objections

I'm aware, I'm busy preparing the pre-freeze pulls.  USB is on the list
already, busy with UI right now. VGA comes next.

Series queued.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections
  2019-03-07 13:27   ` Gerd Hoffmann
@ 2019-03-07 13:32     ` Daniel P. Berrangé
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2019-03-07 13:32 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: qemu-devel, Dr. David Alan Gilbert, libvir-list, Markus Armbruster

On Thu, Mar 07, 2019 at 02:27:30PM +0100, Gerd Hoffmann wrote:
> On Thu, Mar 07, 2019 at 12:23:58PM +0000, Daniel P. Berrangé wrote:
> > ping - soft freeze is less than a week away & i'd like this to get into
> > a ui queue pull request in time for 4.0 if there's no review objections
> 
> I'm aware, I'm busy preparing the pre-freeze pulls.  USB is on the list
> already, busy with UI right now. VGA comes next.
> 
> Series queued.

Thanks for the quick reply !

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-03-07 13:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 14:57 [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
2019-02-27 14:57 ` [Qemu-devel] [PATCH 1/2] vnc: allow specifying a custom authorization object name Daniel P. Berrangé
2019-02-27 14:57 ` [Qemu-devel] [PATCH 2/2] monitor: deprecate acl_show, acl_reset, acl_policy, acl_add, acl_remove Daniel P. Berrangé
2019-03-07 12:23 ` [Qemu-devel] [PATCH 0/2] ui: support for authorization control on TLS connections Daniel P. Berrangé
2019-03-07 13:27   ` Gerd Hoffmann
2019-03-07 13:32     ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.