diff mbox

[2/3] spice: Implement set_password without password

Message ID d508957670b59ab9e4f7f610948fddae55039194.1424190993.git.mprivozn@redhat.com
State New
Headers show

Commit Message

Michal Prívozník Feb. 17, 2015, 4:40 p.m. UTC
This is quite easy. SPICE has a function to disable ticketing.
So, if no password was provided, call the function, and if a
password was provided, call another function to actually set it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 ui/spice-core.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/ui/spice-core.c b/ui/spice-core.c
index c8f7f18..50e1939 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -895,13 +895,24 @@  static int qemu_spice_set_ticket(bool fail_if_conn, bool disconnect_if_conn)
 int qemu_spice_set_passwd(const char *passwd,
                           bool fail_if_conn, bool disconnect_if_conn)
 {
-    if (strcmp(auth, "spice") != 0) {
+    if (strcmp(auth, "spice") != 0 && strcmp(auth, "none") != 0) {
         return -1;
     }
 
     g_free(auth_passwd);
     auth_passwd = g_strdup(passwd);
-    return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
+
+    if (!passwd) {
+        if (spice_server_set_noauth(spice_server) < 0)
+            return -1;
+        auth = "none";
+    } else {
+        if (qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn) < 0)
+            return -1;
+        auth = "spice";
+    }
+
+    return 0;
 }
 
 int qemu_spice_set_pw_expire(time_t expires)