2016-05-31 23:05:30 +02:00
|
|
|
From 1e6837a4cf1e2c757a9ee61f99ffd90dc97e3067 Mon Sep 17 00:00:00 2001
|
2013-02-10 19:32:29 +01:00
|
|
|
From: =?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>
|
2012-09-05 13:51:25 +02:00
|
|
|
Date: Wed, 29 Aug 2012 20:06:01 +0200
|
|
|
|
Subject: [PATCH] vnc: password-file= and incoming-connections=
|
|
|
|
|
|
|
|
TBD (from SUSE Studio team)
|
|
|
|
---
|
2015-03-21 12:46:36 +01:00
|
|
|
ui/vnc.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 55 insertions(+)
|
2012-09-05 13:51:25 +02:00
|
|
|
|
|
|
|
diff --git a/ui/vnc.c b/ui/vnc.c
|
2016-04-05 15:18:15 +02:00
|
|
|
index d2ebf1f..ab65db9 100644
|
2012-09-05 13:51:25 +02:00
|
|
|
--- a/ui/vnc.c
|
|
|
|
+++ b/ui/vnc.c
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -58,6 +58,8 @@ static const struct timeval VNC_REFRESH_LOSSY = { 2, 0 };
|
2015-03-21 12:46:36 +01:00
|
|
|
static QTAILQ_HEAD(, VncDisplay) vnc_displays =
|
|
|
|
QTAILQ_HEAD_INITIALIZER(vnc_displays);
|
2012-09-05 13:51:25 +02:00
|
|
|
|
|
|
|
+static int allowed_connections = 0;
|
2015-03-21 12:46:36 +01:00
|
|
|
+
|
2012-09-05 13:51:25 +02:00
|
|
|
static int vnc_cursor_define(VncState *vs);
|
|
|
|
static void vnc_release_modifiers(VncState *vs);
|
2015-03-21 12:46:36 +01:00
|
|
|
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -1185,6 +1187,7 @@ static void vnc_disconnect_start(VncState *vs)
|
2013-02-10 19:32:29 +01:00
|
|
|
void vnc_disconnect_finish(VncState *vs)
|
2012-09-05 13:51:25 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
+ static int num_disconnects = 0;
|
|
|
|
|
|
|
|
vnc_jobs_join(vs); /* Wait encoding jobs */
|
|
|
|
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -1235,6 +1238,13 @@ void vnc_disconnect_finish(VncState *vs)
|
|
|
|
object_unref(OBJECT(vs->sioc));
|
|
|
|
vs->sioc = NULL;
|
2012-09-05 13:51:25 +02:00
|
|
|
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);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
2016-04-05 15:18:15 +02:00
|
|
|
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;
|
2012-09-05 13:51:25 +02:00
|
|
|
}
|
|
|
|
|
2015-03-21 12:46:36 +01:00
|
|
|
+static void read_file_password(const char *id, const char *filename)
|
2012-09-05 13:51:25 +02:00
|
|
|
+{
|
|
|
|
+ FILE *pfile = NULL;
|
|
|
|
+ char *passwd = NULL;
|
|
|
|
+ int start = 0, length = 0, rc = 0;
|
|
|
|
+
|
2015-03-21 12:46:36 +01:00
|
|
|
+ if (strlen(filename) == 0) {
|
|
|
|
+ printf("No file supplied\n");
|
|
|
|
+ return;
|
2012-09-05 13:51:25 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pfile = fopen(filename, "r");
|
2015-03-21 12:46:36 +01:00
|
|
|
+ if (pfile == NULL) {
|
|
|
|
+ printf("Could not read from %s\n", filename);
|
|
|
|
+ return;
|
2012-09-05 13:51:25 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ start = ftell(pfile);
|
|
|
|
+ fseek(pfile, 0L, SEEK_END);
|
|
|
|
+ length = ftell(pfile);
|
|
|
|
+ fseek(pfile, 0L, start);
|
|
|
|
+
|
2015-03-21 12:46:36 +01:00
|
|
|
+ passwd = g_malloc(length + 1);
|
2012-09-05 13:51:25 +02:00
|
|
|
+ rc = fread(passwd, 1, length, pfile);
|
|
|
|
+ fclose(pfile);
|
|
|
|
+
|
2015-03-21 12:46:36 +01:00
|
|
|
+ if (rc == length && rc > 0) {
|
|
|
|
+ vnc_display_password(id, passwd);
|
2012-09-05 13:51:25 +02:00
|
|
|
+ }
|
|
|
|
+
|
2015-03-21 12:46:36 +01:00
|
|
|
+ g_free(passwd);
|
2012-09-05 13:51:25 +02:00
|
|
|
+}
|
|
|
|
+
|
2015-03-21 12:46:36 +01:00
|
|
|
static QemuOptsList qemu_vnc_opts = {
|
|
|
|
.name = "vnc",
|
|
|
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_vnc_opts.head),
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -3231,6 +3274,9 @@ static QemuOptsList qemu_vnc_opts = {
|
2015-03-21 12:46:36 +01:00
|
|
|
.name = "connections",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
},{
|
|
|
|
+ .name = "allowed-connections",
|
|
|
|
+ .type = QEMU_OPT_NUMBER,
|
|
|
|
+ },{
|
|
|
|
.name = "to",
|
|
|
|
.type = QEMU_OPT_NUMBER,
|
|
|
|
},{
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -3243,6 +3289,9 @@ static QemuOptsList qemu_vnc_opts = {
|
2015-03-21 12:46:36 +01:00
|
|
|
.name = "password",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
|
|
|
+ .name = "password-file",
|
|
|
|
+ .type = QEMU_OPT_STRING,
|
|
|
|
+ },{
|
|
|
|
.name = "reverse",
|
|
|
|
.type = QEMU_OPT_BOOL,
|
|
|
|
},{
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -3476,6 +3525,7 @@ void vnc_display_open(const char *id, Error **errp)
|
2015-03-21 12:46:36 +01:00
|
|
|
const char *share, *device_id;
|
|
|
|
QemuConsole *con;
|
|
|
|
bool password = false;
|
|
|
|
+ const char *password_file;
|
|
|
|
bool reverse = false;
|
|
|
|
const char *vnc;
|
2016-01-19 19:31:32 +01:00
|
|
|
char *h;
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -3601,6 +3651,10 @@ void vnc_display_open(const char *id, Error **errp)
|
2015-07-24 15:54:26 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
2015-03-21 12:46:36 +01:00
|
|
|
}
|
|
|
|
+ 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);
|
2016-04-05 15:18:15 +02:00
|
|
|
@@ -3689,6 +3743,7 @@ void vnc_display_open(const char *id, Error **errp)
|
2015-03-21 12:46:36 +01:00
|
|
|
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);
|
|
|
|
|
2016-01-19 19:31:32 +01:00
|
|
|
#ifdef CONFIG_VNC_JPEG
|
|
|
|
vs->lossy = qemu_opt_get_bool(opts, "lossy", false);
|