]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/pve/0052-vnc-refactor-to-QIOChannelSocket.patch
update to qemu 2.6.0
[pve-qemu-kvm.git] / debian / patches / pve / 0052-vnc-refactor-to-QIOChannelSocket.patch
CommitLineData
b07d35a5
TL
1From ff4737549236e6b122d36ef5893058c69795a57f Mon Sep 17 00:00:00 2001
2From: Thomas Lamprecht <t.lamprecht@proxmox.com>
3Date: Wed, 6 Apr 2016 16:47:54 +0200
4Subject: [PATCH 52/52] vnc: refactor to QIOChannelSocket
5
6Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7---
8 ui/vnc-auth-vencrypt.c | 31 ++++++++++++++++---------------
9 1 file changed, 16 insertions(+), 15 deletions(-)
10
11diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c
12index d11f1df..01aa1de 100644
13--- a/ui/vnc-auth-vencrypt.c
14+++ b/ui/vnc-auth-vencrypt.c
15@@ -28,27 +28,23 @@
16 #include "vnc.h"
17 #include "qapi/error.h"
18 #include "qemu/main-loop.h"
19-#include "qemu/sockets.h"
20+#include "io/channel-socket.h"
21
22 static int protocol_client_auth_plain(VncState *vs, uint8_t *data, size_t len)
23 {
24- const char *err = NULL;
25+ Error *err = NULL;
26 char username[256];
27 char passwd[512];
28
29- char clientip[256];
30- clientip[0] = 0;
31- struct sockaddr_in client;
32- socklen_t addrlen = sizeof(client);
33- if (getpeername(vs->csock, &client, &addrlen) == 0) {
34- inet_ntop(client.sin_family, &client.sin_addr,
35- clientip, sizeof(clientip));
36+ SocketAddress *clientip = qio_channel_socket_get_remote_address(vs->sioc, &err);
37+ if (err) {
38+ goto err;
39 }
40
41 if ((len != (vs->username_len + vs->password_len)) ||
42 (vs->username_len >= (sizeof(username)-1)) ||
43 (vs->password_len >= (sizeof(passwd)-1)) ) {
44- err = "Got unexpected data length";
45+ error_setg(&err, "Got unexpected data length");
46 goto err;
47 }
48
49@@ -59,26 +55,31 @@ static int protocol_client_auth_plain(VncState *vs, uint8_t *data, size_t len)
50
51 VNC_DEBUG("AUTH PLAIN username: %s pw: %s\n", username, passwd);
52
53- if (pve_auth_verify(clientip, username, passwd) == 0) {
54+ if (pve_auth_verify(clientip->u.inet.data->host, username, passwd) == 0) {
55 vnc_write_u32(vs, 0); /* Accept auth completion */
56 start_client_init(vs);
57+ qapi_free_SocketAddress(clientip);
58 return 0;
59 }
60
61- err = "Authentication failed";
62+ error_setg(&err, "Authentication failed");
63 err:
64 if (err) {
65- VNC_DEBUG("AUTH PLAIN ERROR: %s\n", err);
66+ const char *err_msg = error_get_pretty(err);
67+ VNC_DEBUG("AUTH PLAIN ERROR: %s\n", err_msg);
68 vnc_write_u32(vs, 1); /* Reject auth */
69 if (vs->minor >= 8) {
70- int elen = strlen(err);
71+ int elen = strlen(err_msg);
72 vnc_write_u32(vs, elen);
73- vnc_write(vs, err, elen);
74+ vnc_write(vs, err_msg, elen);
75 }
76+ error_free(err);
77 }
78 vnc_flush(vs);
79 vnc_client_error(vs);
80
81+ qapi_free_SocketAddress(clientip);
82+
83 return 0;
84
85 }
86--
872.1.4
88