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