Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.1:Update
kvm
kvm-studio-vnc.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kvm-studio-vnc.patch of Package kvm
Index: qemu-kvm-0.10.5/vnc.c =================================================================== --- qemu-kvm-0.10.5.orig/vnc.c +++ qemu-kvm-0.10.5/vnc.c @@ -43,7 +43,7 @@ #include <gnutls/x509.h> #endif /* CONFIG_VNC_TLS */ -// #define _VNC_DEBUG 1 +#define _VNC_DEBUG 1 #ifdef _VNC_DEBUG #define VNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) @@ -165,6 +165,7 @@ struct VncState static VncDisplay *vnc_display; /* needed for info vnc */ static DisplayChangeListener *dcl; +static int allowed_connections = 0; void do_info_vnc(void) { @@ -844,6 +845,8 @@ static void audio_del(VncState *vs) static int vnc_client_io_error(VncState *vs, int ret, int last_errno) { + static int num_disconnects = 0; + if (ret == 0 || ret == -1) { if (ret == -1) { switch (last_errno) { @@ -1057,6 +1060,8 @@ static void vnc_disconnect_start(VncStat static void vnc_disconnect_finish(VncState *vs) { + static int num_disconnects = 0; + qemu_del_timer(vs->timer); qemu_free_timer(vs->timer); if (vs->input.buffer) qemu_free(vs->input.buffer); @@ -1085,6 +1090,13 @@ static void vnc_disconnect_finish(VncSta qemu_free(vs->old_data); qemu_free(vs); + num_disconnects++; + if(allowed_connections > 0 && allowed_connections <= num_disconnects) { + VNC_DEBUG("Maximum number of disconnects (%d) reached:" + " Session terminating\n", allowed_connections); + exit(0); + } + } static ssize_t vnc_tls_pull(gnutls_transport_ptr_t transport, @@ -2458,6 +2470,39 @@ int vnc_display_password(DisplayState *d return 0; } +static void read_file_password(DisplayState *ds, char *filename) +{ + FILE *pfile = NULL; + char *passwd = NULL; + int start = 0, length = 0, rc = 0; + + if(strlen(filename) == 0) { + printf("No file supplied\n"); + return; + } + + pfile = fopen(filename, "r"); + if(pfile == NULL) { + printf("Could not read from %s\n", filename); + return; + } + + start = ftell(pfile); + fseek(pfile, 0L, SEEK_END); + length = ftell(pfile); + fseek(pfile, 0L, start); + + passwd = malloc(length+1); + rc = fread(passwd, 1, length, pfile); + fclose(pfile); + + if(rc == length && rc > 0) { + vnc_display_password(ds, passwd); + } + + free(passwd); +} + int vnc_display_open(DisplayState *ds, const char *display) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; @@ -2482,7 +2527,36 @@ int vnc_display_open(DisplayState *ds, c while ((options = strchr(options, ','))) { options++; if (strncmp(options, "password", 8) == 0) { + char *start, *end; + start = strchr(options, '='); + end = strchr(options, ','); password = 1; /* Require password auth */ + if (start && (!end || (start < end))) { + int len = end ? end-(start+1) : strlen(start+1); + char *text = qemu_malloc(len+1); + strncpy(text, start+1, len); + text[len] = '\0'; + + if (strncmp(options, "password-file=", 14) == 0) { + read_file_password(ds, text); + } else { + vnc_display_password(ds, text); + } + + free(text); + } + } else if (strncmp(options, "allowed-connections=", 20) == 0) { + char *start, *end; + start = strchr(options, '='); + end = strchr(options, ','); + if (start && (!end || (start < end))) { + int len = end ? end-(start+1) : strlen(start+1); + char *text = qemu_malloc(len+1); + strncpy(text, start+1, len); + text[len] = '\0'; + VNC_DEBUG("Maximum number of disconnects: %s\n", text); + allowed_connections = atoi(text); + } } else if (strncmp(options, "reverse", 7) == 0) { reverse = 1; } else if (strncmp(options, "to=", 3) == 0) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor