diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-03-02 19:01:05 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2015-12-18 15:02:11 +0000 |
commit | 2cc452281e1746f9c02d3c66633ce9e5bc391cae (patch) | |
tree | d19f09be771030e5730e821b0c1a2fb30af20016 /ui/vnc.c | |
parent | 04d2529da27db512dcbd5e99d0e26d333f16efcc (diff) |
ui: convert VNC server to use QIOChannelTLS
Switch VNC server over to using the QIOChannelTLS object for
the TLS session. This removes all remaining VNC specific code
for dealing with TLS handshakes.
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'ui/vnc.c')
-rw-r--r-- | ui/vnc.c | 69 |
1 files changed, 5 insertions, 64 deletions
@@ -1201,7 +1201,6 @@ void vnc_disconnect_finish(VncState *vs) vnc_tight_clear(vs); vnc_zrle_clear(vs); - qcrypto_tls_session_free(vs->tls); #ifdef CONFIG_VNC_SASL vnc_sasl_client_cleanup(vs); #endif /* CONFIG_VNC_SASL */ @@ -1267,38 +1266,6 @@ void vnc_client_error(VncState *vs) } -ssize_t vnc_tls_pull(char *buf, size_t len, void *opaque) -{ - VncState *vs = opaque; - ssize_t ret = qio_channel_read(vs->ioc, buf, len, NULL); - if (ret < 0) { - if (ret == QIO_CHANNEL_ERR_BLOCK) { - errno = EAGAIN; - } else { - errno = EIO; - } - return -1; - } - return ret; -} - - -ssize_t vnc_tls_push(const char *buf, size_t len, void *opaque) -{ - VncState *vs = opaque; - ssize_t ret = qio_channel_write(vs->ioc, buf, len, NULL); - if (ret < 0) { - if (ret == QIO_CHANNEL_ERR_BLOCK) { - errno = EAGAIN; - } else { - errno = EIO; - } - return -1; - } - return ret; -} - - /* * Called to write a chunk of data to the client socket. The data may * be the raw data, or may have already been encoded by SASL. @@ -1318,21 +1285,8 @@ ssize_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen) { Error *err = NULL; ssize_t ret; - if (vs->tls) { - ret = qcrypto_tls_session_write(vs->tls, (const char *)data, datalen); - if (ret < 0) { - if (errno == EAGAIN) { - ret = QIO_CHANNEL_ERR_BLOCK; - } else { - ret = -1; - error_setg_errno(&err, errno, "%s", - "Cannot write to TLS socket"); - } - } - } else { - ret = qio_channel_write( - vs->ioc, (const char *)data, datalen, &err); - } + ret = qio_channel_write( + vs->ioc, (const char *)data, datalen, &err); VNC_DEBUG("Wrote wire %p %zd -> %ld\n", data, datalen, ret); return vnc_client_io_error(vs, ret, &err); } @@ -1448,21 +1402,8 @@ ssize_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen) { ssize_t ret; Error *err = NULL; - if (vs->tls) { - ret = qcrypto_tls_session_read(vs->tls, (char *)data, datalen); - if (ret < 0) { - if (errno == EAGAIN) { - ret = QIO_CHANNEL_ERR_BLOCK; - } else { - ret = -1; - error_setg_errno(&err, errno, "%s", - "Cannot read from TLS socket"); - } - } - } else { - ret = qio_channel_read( - vs->ioc, (char *)data, datalen, &err); - } + ret = qio_channel_read( + vs->ioc, (char *)data, datalen, &err); VNC_DEBUG("Read wire %p %zd -> %ld\n", data, datalen, ret); return vnc_client_io_error(vs, ret, &err); } @@ -3773,7 +3714,7 @@ void vnc_display_open(const char *id, Error **errp) vs->tlsaclname = g_strdup_printf("vnc.%s.x509dname", vs->id); } qemu_acl_init(vs->tlsaclname); - } + } #ifdef CONFIG_VNC_SASL if (acl && sasl) { char *aclname; |