Revision 7e7e2ebc ui/vnc.c

b/ui/vnc.c
2124 2124
{
2125 2125
    /* We only advertise 1 auth scheme at a time, so client
2126 2126
     * must pick the one we sent. Verify this */
2127
    if (data[0] != vs->vd->auth) { /* Reject auth */
2127
    if (data[0] != vs->auth) { /* Reject auth */
2128 2128
       VNC_DEBUG("Reject auth %d because it didn't match advertized\n", (int)data[0]);
2129 2129
       vnc_write_u32(vs, 1);
2130 2130
       if (vs->minor >= 8) {
......
2135 2135
       vnc_client_error(vs);
2136 2136
    } else { /* Accept requested auth */
2137 2137
       VNC_DEBUG("Client requested auth %d\n", (int)data[0]);
2138
       switch (vs->vd->auth) {
2138
       switch (vs->auth) {
2139 2139
       case VNC_AUTH_NONE:
2140 2140
           VNC_DEBUG("Accept auth none\n");
2141 2141
           if (vs->minor >= 8) {
......
2165 2165
#endif /* CONFIG_VNC_SASL */
2166 2166

  
2167 2167
       default: /* Should not be possible, but just in case */
2168
           VNC_DEBUG("Reject auth %d server code bug\n", vs->vd->auth);
2168
           VNC_DEBUG("Reject auth %d server code bug\n", vs->auth);
2169 2169
           vnc_write_u8(vs, 1);
2170 2170
           if (vs->minor >= 8) {
2171 2171
               static const char err[] = "Authentication failed";
......
2210 2210
        vs->minor = 3;
2211 2211

  
2212 2212
    if (vs->minor == 3) {
2213
        if (vs->vd->auth == VNC_AUTH_NONE) {
2213
        if (vs->auth == VNC_AUTH_NONE) {
2214 2214
            VNC_DEBUG("Tell client auth none\n");
2215
            vnc_write_u32(vs, vs->vd->auth);
2215
            vnc_write_u32(vs, vs->auth);
2216 2216
            vnc_flush(vs);
2217 2217
            start_client_init(vs);
2218
       } else if (vs->vd->auth == VNC_AUTH_VNC) {
2218
       } else if (vs->auth == VNC_AUTH_VNC) {
2219 2219
            VNC_DEBUG("Tell client VNC auth\n");
2220
            vnc_write_u32(vs, vs->vd->auth);
2220
            vnc_write_u32(vs, vs->auth);
2221 2221
            vnc_flush(vs);
2222 2222
            start_auth_vnc(vs);
2223 2223
       } else {
2224
            VNC_DEBUG("Unsupported auth %d for protocol 3.3\n", vs->vd->auth);
2224
            VNC_DEBUG("Unsupported auth %d for protocol 3.3\n", vs->auth);
2225 2225
            vnc_write_u32(vs, VNC_AUTH_INVALID);
2226 2226
            vnc_flush(vs);
2227 2227
            vnc_client_error(vs);
2228 2228
       }
2229 2229
    } else {
2230
        VNC_DEBUG("Telling client we support auth %d\n", vs->vd->auth);
2230
        VNC_DEBUG("Telling client we support auth %d\n", vs->auth);
2231 2231
        vnc_write_u8(vs, 1); /* num auth */
2232
        vnc_write_u8(vs, vs->vd->auth);
2232
        vnc_write_u8(vs, vs->auth);
2233 2233
        vnc_read_when(vs, protocol_client_auth, 1);
2234 2234
        vnc_flush(vs);
2235 2235
    }
......
2494 2494
    }
2495 2495
}
2496 2496

  
2497
static void vnc_connect(VncDisplay *vd, int csock)
2497
static void vnc_connect(VncDisplay *vd, int csock, int skipauth)
2498 2498
{
2499 2499
    VncState *vs = qemu_mallocz(sizeof(VncState));
2500 2500
    int i;
2501 2501

  
2502 2502
    vs->csock = csock;
2503

  
2504
    if (skipauth) {
2505
	vs->auth = VNC_AUTH_NONE;
2506
#ifdef CONFIG_VNC_TLS
2507
	vs->subauth = VNC_AUTH_INVALID;
2508
#endif
2509
    } else {
2510
	vs->auth = vd->auth;
2511
#ifdef CONFIG_VNC_TLS
2512
	vs->subauth = vd->subauth;
2513
#endif
2514
    }
2515

  
2503 2516
    vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
2504 2517
    for (i = 0; i < VNC_STAT_ROWS; ++i) {
2505 2518
        vs->lossy_rect[i] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));
......
2557 2570

  
2558 2571
    int csock = qemu_accept(vs->lsock, (struct sockaddr *)&addr, &addrlen);
2559 2572
    if (csock != -1) {
2560
        vnc_connect(vs, csock);
2573
        vnc_connect(vs, csock, 0);
2561 2574
    }
2562 2575
}
2563 2576

  
......
2887 2900
        } else {
2888 2901
            int csock = vs->lsock;
2889 2902
            vs->lsock = -1;
2890
            vnc_connect(vs, csock);
2903
            vnc_connect(vs, csock, 0);
2891 2904
        }
2892 2905
        return 0;
2893 2906

  

Also available in: Unified diff