qemu/0023-vnc-password-file-and-incoming-conn.patch
Andreas Färber 8c721a87ae Accepting request 408549 from home:algraf:branches:Virtualization
- Remove deprecated patch "work-around-SA_RESTART-race" (boo#982208)
- Patch queue updated from git://github.com/openSUSE/qemu.git opensuse-2.6
* Patches dropped:
  0002-XXX-work-around-SA_RESTART-race-wit.patch
  0003-qemu-0.9.0.cvs-binfmt.patch
  0004-qemu-cvs-alsa_bitfield.patch
  0005-qemu-cvs-alsa_ioctl.patch
  0006-qemu-cvs-alsa_mmap.patch
  0007-qemu-cvs-gettimeofday.patch
  0008-qemu-cvs-ioctl_debug.patch
  0009-qemu-cvs-ioctl_nodirection.patch
  0010-block-vmdk-Support-creation-of-SCSI.patch
  0011-linux-user-add-binfmt-wrapper-for-a.patch
  0012-PPC-KVM-Disable-mmu-notifier-check.patch
  0013-linux-user-fix-segfault-deadlock.patch
  0014-linux-user-binfmt-support-host-bina.patch
  0015-linux-user-Ignore-broken-loop-ioctl.patch
  0016-linux-user-lock-tcg.patch
  0017-linux-user-Run-multi-threaded-code-.patch
  0018-linux-user-lock-tb-flushing-too.patch
  0019-linux-user-Fake-proc-cpuinfo.patch
  0020-linux-user-implement-FS_IOC_GETFLAG.patch
  0021-linux-user-implement-FS_IOC_SETFLAG.patch
  0022-linux-user-XXX-disable-fiemap.patch
  0023-slirp-nooutgoing.patch
  0024-vnc-password-file-and-incoming-conn.patch
  0025-linux-user-add-more-blk-ioctls.patch
  0026-linux-user-use-target_ulong.patch
  0027-block-Add-support-for-DictZip-enabl.patch
  0028-block-Add-tar-container-format.patch

OBS-URL: https://build.opensuse.org/request/show/408549
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=305
2016-07-14 15:50:35 +00:00

133 lines
4.0 KiB
Diff

From c15dcea01fb9d84e583abe7d558d7a31a937ddc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>
Date: Wed, 29 Aug 2012 20:06:01 +0200
Subject: [PATCH] vnc: password-file= and incoming-connections=
TBD (from SUSE Studio team)
---
ui/vnc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/ui/vnc.c b/ui/vnc.c
index d2ebf1f..ab65db9 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -58,6 +58,8 @@ static const struct timeval VNC_REFRESH_LOSSY = { 2, 0 };
static QTAILQ_HEAD(, VncDisplay) vnc_displays =
QTAILQ_HEAD_INITIALIZER(vnc_displays);
+static int allowed_connections = 0;
+
static int vnc_cursor_define(VncState *vs);
static void vnc_release_modifiers(VncState *vs);
@@ -1185,6 +1187,7 @@ static void vnc_disconnect_start(VncState *vs)
void vnc_disconnect_finish(VncState *vs)
{
int i;
+ static int num_disconnects = 0;
vnc_jobs_join(vs); /* Wait encoding jobs */
@@ -1235,6 +1238,13 @@ void vnc_disconnect_finish(VncState *vs)
object_unref(OBJECT(vs->sioc));
vs->sioc = NULL;
g_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);
+ }
}
ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
@@ -3200,6 +3210,39 @@ char *vnc_display_local_addr(const char *id)
return ret;
}
+static void read_file_password(const char *id, const 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 = g_malloc(length + 1);
+ rc = fread(passwd, 1, length, pfile);
+ fclose(pfile);
+
+ if (rc == length && rc > 0) {
+ vnc_display_password(id, passwd);
+ }
+
+ g_free(passwd);
+}
+
static QemuOptsList qemu_vnc_opts = {
.name = "vnc",
.head = QTAILQ_HEAD_INITIALIZER(qemu_vnc_opts.head),
@@ -3231,6 +3274,9 @@ static QemuOptsList qemu_vnc_opts = {
.name = "connections",
.type = QEMU_OPT_NUMBER,
},{
+ .name = "allowed-connections",
+ .type = QEMU_OPT_NUMBER,
+ },{
.name = "to",
.type = QEMU_OPT_NUMBER,
},{
@@ -3243,6 +3289,9 @@ static QemuOptsList qemu_vnc_opts = {
.name = "password",
.type = QEMU_OPT_BOOL,
},{
+ .name = "password-file",
+ .type = QEMU_OPT_STRING,
+ },{
.name = "reverse",
.type = QEMU_OPT_BOOL,
},{
@@ -3476,6 +3525,7 @@ void vnc_display_open(const char *id, Error **errp)
const char *share, *device_id;
QemuConsole *con;
bool password = false;
+ const char *password_file;
bool reverse = false;
const char *vnc;
char *h;
@@ -3601,6 +3651,10 @@ void vnc_display_open(const char *id, Error **errp)
goto fail;
}
}
+ password_file = qemu_opt_get(opts, "password-file");
+ if (password_file) {
+ read_file_password(id, password_file);
+ }
reverse = qemu_opt_get_bool(opts, "reverse", false);
lock_key_sync = qemu_opt_get_bool(opts, "lock-key-sync", true);
@@ -3689,6 +3743,7 @@ void vnc_display_open(const char *id, Error **errp)
vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
}
vs->connections_limit = qemu_opt_get_number(opts, "connections", 32);
+ allowed_connections = qemu_opt_get_number(opts, "allowed-connections", 0);
#ifdef CONFIG_VNC_JPEG
vs->lossy = qemu_opt_get_bool(opts, "lossy", false);