From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] PATCH: 5/7: Include auth credentials in 'info vnc'
Date: Thu, 12 Feb 2009 15:03:48 +0000 [thread overview]
Message-ID: <20090212150348.GU9894@redhat.com> (raw)
In-Reply-To: <20090212145302.GO9894@redhat.com>
This patch extends the 'info vnc' monitor output to include information
about the VNC client authentication credentials.
For clients authenticated using SASL, this will output the username.
For clients authenticated using x509 certificates, this will output
the x509 distinguished name.
Auth can be stacked, so both username & x509 dname may be shown.
(qemu) info vnc
Server: active
address: 0.0.0.0:5901
auth: vencrypt+x509+sasl
Client: active
address: 127.0.0.1:42956
x509 dname: C=GB,O=Red Hat,L=London,ST=London,CN=localhost
username: test
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
vnc-tls.c | 17 +++++++++++++++++
vnc-tls.h | 3 +++
vnc.c | 19 +++++++++++++++++--
3 files changed, 37 insertions(+), 2 deletions(-)
Daniel
diff -r 122f8a90f465 vnc-tls.c
--- a/vnc-tls.c Wed Feb 11 17:34:08 2009 +0000
+++ b/vnc-tls.c Wed Feb 11 17:34:11 2009 +0000
@@ -241,6 +241,22 @@ int vnc_tls_validate_certificate(struct
return -1;
}
+ if (i == 0) {
+ size_t dnameSize = 1024;
+ vs->tls.dname = qemu_malloc(dnameSize);
+ requery:
+ if ((ret = gnutls_x509_crt_get_dn (cert, vs->tls.dname, &dnameSize)) != 0) {
+ if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER) {
+ vs->tls.dname = qemu_realloc(vs->tls.dname, dnameSize);
+ goto requery;
+ }
+ gnutls_x509_crt_deinit (cert);
+ VNC_DEBUG("Cannot get client distinguished name: %s",
+ gnutls_strerror (ret));
+ return -1;
+ }
+ }
+
gnutls_x509_crt_deinit (cert);
}
@@ -346,6 +362,7 @@ void vnc_tls_client_cleanup(struct VncSt
vs->tls.session = NULL;
}
vs->tls.wiremode = VNC_WIREMODE_CLEAR;
+ free(vs->tls.dname);
}
diff -r 122f8a90f465 vnc-tls.h
--- a/vnc-tls.h Wed Feb 11 17:34:08 2009 +0000
+++ b/vnc-tls.h Wed Feb 11 17:34:11 2009 +0000
@@ -48,6 +48,9 @@ struct VncStateTLS {
/* Whether data is being TLS encrypted yet */
int wiremode;
gnutls_session_t session;
+
+ /* Client's Distinguished Name from the x509 cert */
+ char *dname;
};
int vnc_tls_client_setup(VncState *vs, int x509Creds);
diff -r 122f8a90f465 vnc.c
--- a/vnc.c Wed Feb 11 17:34:08 2009 +0000
+++ b/vnc.c Wed Feb 11 17:34:11 2009 +0000
@@ -176,6 +176,21 @@ void do_info_vnc(void)
term_puts("Client: active\n");
term_puts(clientAddr);
free(clientAddr);
+
+#ifdef CONFIG_VNC_TLS
+ if (vnc_state->tls.session &&
+ vnc_state->tls.dname)
+ term_printf(" x509 dname: %s\n", vnc_state->tls.dname);
+ else
+ term_puts(" x509 dname: none\n");
+#endif
+#ifdef CONFIG_VNC_SASL
+ if (vnc_state->sasl.conn &&
+ vnc_state->sasl.username)
+ term_printf(" username: %s\n", vnc_state->sasl.username);
+ else
+ term_puts(" username: none\n");
+#endif
}
}
}
@@ -1781,7 +1796,7 @@ static int protocol_client_auth(VncState
/* We only advertise 1 auth scheme at a time, so client
* must pick the one we sent. Verify this */
if (data[0] != vs->auth) { /* Reject auth */
- VNC_DEBUG("Reject auth %d\n", (int)data[0]);
+ VNC_DEBUG("Reject auth %d because it didn't match advertized\n", (int)data[0]);
vnc_write_u32(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
@@ -1821,7 +1836,7 @@ static int protocol_client_auth(VncState
#endif /* CONFIG_VNC_SASL */
default: /* Should not be possible, but just in case */
- VNC_DEBUG("Reject auth %d\n", vs->auth);
+ VNC_DEBUG("Reject auth %d server code bug\n", vs->auth);
vnc_write_u8(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Authentication failed";
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
next prev parent reply other threads:[~2009-02-12 15:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-12 14:53 [Qemu-devel] PATCH: 0/7: Support SASL authentication in VNC server Daniel P. Berrange
2009-02-12 15:01 ` [Qemu-devel] PATCH: 1/7: Extend 'info vnc' output to show client Daniel P. Berrange
2009-02-13 18:30 ` Anthony Liguori
2009-02-15 11:43 ` Daniel P. Berrange
2009-02-15 18:22 ` Anthony Liguori
2009-02-18 21:10 ` [Qemu-devel] " Mike Day
2009-02-12 15:02 ` [Qemu-devel] PATCH: 2/7: Push VncState struct into vnc.h Daniel P. Berrange
2009-02-14 22:09 ` Anthony Liguori
2009-02-15 11:43 ` Daniel P. Berrange
2009-02-12 15:02 ` [Qemu-devel] PATCH: 3/7: Split out VNC TLS auth code to separate file Daniel P. Berrange
2009-02-12 15:03 ` [Qemu-devel] PATCH: 4/7: Add SASL authentication extension to VNC Daniel P. Berrange
2009-02-12 15:03 ` Daniel P. Berrange [this message]
2009-02-12 15:04 ` [Qemu-devel] PATCH: 6/7: Support simple ACL for client authorization Daniel P. Berrange
2009-02-14 22:14 ` Anthony Liguori
2009-02-12 15:04 ` [Qemu-devel] PATCH: 7/7: Add external persistent ACL file Daniel P. Berrange
2009-02-14 22:16 ` Anthony Liguori
2009-02-15 11:28 ` Daniel P. Berrange
2009-02-12 15:43 ` [Qemu-devel] PATCH: 0/7: Support SASL authentication in VNC server Daniel P. Berrange
2009-02-14 22:17 ` Anthony Liguori
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=20090212150348.GU9894@redhat.com \
--to=berrange@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).