From 5d48aa61a74a2666c988b901075f9d0dee035acb Mon Sep 17 00:00:00 2001
Message-Id: <5d48aa61a74a2666c988b901075f9d0dee035acb.1424811078.git.jen@redhat.com>
In-Reply-To: <daa093cf3b29cc36a29e8aa34d6b64db07eee8be.1424811078.git.jen@redhat.com>
References: <daa093cf3b29cc36a29e8aa34d6b64db07eee8be.1424811078.git.jen@redhat.com>
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 18 Feb 2015 13:01:12 -0500
Subject: [CHANGE 4/4] spice: auth fixes
To: rhvirt-patches@redhat.com,
    jen@redhat.com

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1424264472-23532-2-git-send-email-kraxel@redhat.com>
Patchwork-id: 63890
O-Subject: [RHEL-6.7 qemu-kvm PATCH 1/1] spice: auth fixes
Bugzilla: 1115237
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
RH-Acked-by: Bandan Das <bsd@redhat.com>

Set auth to sasl when sasl is enabled, this makes "info spice" correctly
display sasl auth.  Also throw an error in case someone tries to set
a spice password via monitor without auth mode being "spice".

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit b1ea7b79e1675355ea7abe2548ad71dcf7d64b60)
Signed-off-by: Jeff E. Nelson <jen@redhat.com>

Conflicts:
	ui/spice-core.c
---
 ui/spice-core.c | 5 +++++
 1 file changed, 5 insertions(+)

Signed-off-by: Jeff E. Nelson <jen@redhat.com>
---
 ui/spice-core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 884ef4a..94f9664 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -735,6 +735,7 @@ void qemu_spice_init(void)
             fprintf(stderr, "spice: failed to enable sasl\n");
             exit(1);
         }
+        auth = "sasl";
 #else
         fprintf(stderr, "spice: sasl is not available (spice >= 0.9 required)\n");
         exit(1);
@@ -874,6 +875,10 @@ 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) {
+        return -1;
+    }
+
     free(auth_passwd);
     auth_passwd = strdup(passwd);
     return qemu_spice_set_ticket(fail_if_conn, disconnect_if_conn);
-- 
2.1.0

