From cead5ce08aca281bd2282dab4ea4457b359dcd34 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Tue, 26 Jan 2010 18:53:40 -0200 Subject: [PATCH 2/9] VNC: Make 'auth' key mandatory RH-Author: Luiz Capitulino Message-id: <1264532026-7620-3-git-send-email-lcapitulino@redhat.com> Patchwork-id: 6628 O-Subject: [PATCH RHEL6 qemu-kvm 2/8] VNC: Make 'auth' key mandatory Bugzilla: 549759 RH-Acked-by: Markus Armbruster RH-Acked-by: Daniel P. Berrange RH-Acked-by: Juan Quintela There is no reason to have it as optional and the code in the server and client gets slightly simpler if the key is mandatory. While there also do some cleanup on how the server info is collected. Signed-off-by: Luiz Capitulino Signed-off-by: Anthony Liguori (cherry picked from commit a77893829c27ef9bbab267d8403f5e76a4c61dbf) --- vnc.c | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) Signed-off-by: Eduardo Habkost --- vnc.c | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/vnc.c b/vnc.c index 0def398..958fc1c 100644 --- a/vnc.c +++ b/vnc.c @@ -122,7 +122,7 @@ static int put_addr_qdict(QDict *qdict, struct sockaddr_storage *sa, return 0; } -static int vnc_qdict_local_addr(QDict *qdict, int fd) +static int vnc_server_addr_put(QDict *qdict, int fd) { struct sockaddr_storage sa; socklen_t salen; @@ -199,6 +199,16 @@ static const char *vnc_auth_name(VncDisplay *vd) { return "unknown"; } +static int vnc_server_info_put(QDict *qdict) +{ + if (vnc_server_addr_put(qdict, vnc_display->lsock) < 0) { + return -1; + } + + qdict_put(qdict, "auth", qstring_from_str(vnc_auth_name(vnc_display))); + return 0; +} + static QDict *do_info_vnc_client(Monitor *mon, VncState *client) { QDict *qdict; @@ -263,8 +273,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data) monitor_printf(mon, " address: %s:%s\n", qdict_get_str(server, "host"), qdict_get_str(server, "service")); - monitor_printf(mon, " auth: %s\n", - qdict_haskey(server, "auth") ? qdict_get_str(server, "auth") : "none"); + monitor_printf(mon, " auth: %s\n", qdict_get_str(server, "auth")); clients = qdict_get_qlist(server, "clients"); if (qlist_empty(clients)) { @@ -285,7 +294,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data) * - "enabled": true or false * - "host": server's IP address * - "service": server's port number - * - "auth": authentication method (optional) + * - "auth": authentication method * - "clients": a QList of all connected clients * * Clients are described by a QDict, with the following information: @@ -323,14 +332,7 @@ void do_info_vnc(Monitor *mon, QObject **ret_data) QOBJECT(clist)); assert(*ret_data != NULL); - qdict = qobject_to_qdict(*ret_data); - - if (vnc_display->auth != VNC_AUTH_NONE) { - qdict_put(qdict, "auth", - qstring_from_str(vnc_auth_name(vnc_display))); - } - - if (vnc_qdict_local_addr(qdict, vnc_display->lsock) < 0) { + if (vnc_server_info_put(qobject_to_qdict(*ret_data)) < 0) { qobject_decref(*ret_data); *ret_data = NULL; } -- 1.6.3.rc4.29.g8146