From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Eric Blake" <eblake@redhat.com>, "Max Reitz" <mreitz@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Paolo Bonzini" <pbonzini@redhat.com>,
qemu-block@nongnu.org, "Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH v4 10/10] vnc: allow specifying a custom ACL object name
Date: Wed, 11 May 2016 14:15:33 +0100 [thread overview]
Message-ID: <1462972533-30608-11-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1462972533-30608-1-git-send-email-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-acl' option takes the ID of a QAuthZ
object to use for checking TLS x509 distinguished names, and
the 'sasl-acl' option takes the ID of another object to use for
checking SASL usernames.
In this example, we setup two ACLs. 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 ACLs 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=tlsacl0,policy=deny,\
rules.0.match=O=RedHat,,L=London,rules.0.policy=allow \
-object authz-simple,id=saslacl0,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-acl=tlsacl0,
sasl,sasl-acl=saslacl0 \
...other QEMU args...
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
ui/vnc.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 64 insertions(+), 13 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index ba07715..939c3d3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3263,6 +3263,12 @@ static QemuOptsList qemu_vnc_opts = {
.name = "acl",
.type = QEMU_OPT_BOOL,
},{
+ .name = "tls-acl",
+ .type = QEMU_OPT_STRING,
+ },{
+ .name = "sasl-acl",
+ .type = QEMU_OPT_STRING,
+ },{
.name = "lossy",
.type = QEMU_OPT_BOOL,
},{
@@ -3485,6 +3491,8 @@ void vnc_display_open(const char *id, Error **errp)
int saslErr;
#endif
int acl = 0;
+ const char *tlsacl;
+ const char *saslacl;
int lock_key_sync = 1;
if (!vs) {
@@ -3672,6 +3680,27 @@ void vnc_display_open(const char *id, Error **errp)
}
}
acl = qemu_opt_get_bool(opts, "acl", false);
+ tlsacl = qemu_opt_get(opts, "tls-acl");
+ if (acl && tlsacl) {
+ error_setg(errp, "'acl' option is mutually exclusive with the "
+ "'tls-acl' options");
+ goto fail;
+ }
+ if (tlsacl && !vs->tlscreds) {
+ error_setg(errp, "'tls-acl' provided but TLS is not enabled");
+ goto fail;
+ }
+
+ saslacl = qemu_opt_get(opts, "sasl-acl");
+ if (acl && saslacl) {
+ error_setg(errp, "'acl' option is mutually exclusive with the "
+ "'sasl-acl' options");
+ goto fail;
+ }
+ if (saslacl && !sasl) {
+ error_setg(errp, "'sasl-acl' provided but SASL auth is not enabled");
+ goto fail;
+ }
share = qemu_opt_get(opts, "share");
if (share) {
@@ -3701,7 +3730,9 @@ void vnc_display_open(const char *id, Error **errp)
vs->non_adaptive = true;
}
- if (acl) {
+ if (tlsacl) {
+ vs->tlsaclname = g_strdup(tlsacl);
+ } else if (acl) {
if (strcmp(vs->id, "default") == 0) {
vs->tlsaclname = g_strdup("vnc.x509dname");
} else {
@@ -3712,19 +3743,39 @@ void vnc_display_open(const char *id, Error **errp)
&error_abort);
}
#ifdef CONFIG_VNC_SASL
- if (acl && sasl) {
- char *aclname;
+ if (sasl) {
+ if (saslacl) {
+ Object *container, *acl;
+ container = object_get_objects_root();
+ acl = object_resolve_path_component(container, saslacl);
+ if (!acl) {
+ error_setg(errp, "Cannot find ACL %s", saslacl);
+ goto fail;
+ }
- if (strcmp(vs->id, "default") == 0) {
- aclname = g_strdup("vnc.username");
- } else {
- aclname = g_strdup_printf("vnc.%s.username", vs->id);
- }
- vs->sasl.acl =
- QAUTHZ(qauthz_simple_new(aclname,
- QAUTHZ_SIMPLE_POLICY_DENY,
- &error_abort));
- g_free(aclname);
+ if (!object_dynamic_cast(acl, TYPE_QAUTHZ)) {
+ error_setg(errp, "Object '%s' is not a QAuthZ subclass",
+ saslacl);
+ goto fail;
+ }
+ vs->sasl.acl = QAUTHZ(acl);
+ } else if (acl) {
+ char *aclname;
+
+ if (strcmp(vs->id, "default") == 0) {
+ aclname = g_strdup("vnc.username");
+ } else {
+ aclname = g_strdup_printf("vnc.%s.username", vs->id);
+ }
+ vs->sasl.acl =
+ QAUTHZ(qauthz_simple_new(aclname,
+ QAUTHZ_SIMPLE_POLICY_DENY,
+ &error_abort));
+ g_free(aclname);
+ }
+ } else if (saslacl) {
+ error_setg(errp, "SASL ACL provided when SASL is disabled");
+ goto fail;
}
#endif
--
2.5.5
prev parent reply other threads:[~2016-05-11 13:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-11 13:15 [Qemu-devel] [PATCH v4 00/10]Provide a QOM-based authorization API Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 01/10] qdict: implement a qdict_crumple method for un-flattening a dict Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 02/10] qapi: allow QmpInputVisitor to auto-cast types Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 03/10] qom: support arbitrary non-scalar properties with -object Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 04/10] util: add QAuthZ object as an authorization base class Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 05/10] util: add QAuthZSimple object type for a simple access control list Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 06/10] acl: delete existing ACL implementation Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 07/10] qemu-nbd: add support for ACLs for TLS clients Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 08/10] nbd: allow an ACL to be set with nbd-server-start QMP command Daniel P. Berrange
2016-05-11 13:15 ` [Qemu-devel] [PATCH v4 09/10] chardev: add support for ACLs for TLS clients Daniel P. Berrange
2016-05-11 13:15 ` Daniel P. Berrange [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462972533-30608-11-git-send-email-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.