[patch 2/2] virt-viewer: use username and password for spice sessions with SASL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also set username if set inside configuration file.

Signed-off-by: Dietmar Maurer <dietmar@xxxxxxxxxxx>

Index: new/src/virt-viewer-session-spice.c
===================================================================
--- new.orig/src/virt-viewer-session-spice.c	2013-10-24 06:17:52.000000000 +0200
+++ new/src/virt-viewer-session-spice.c	2013-10-24 07:44:42.000000000 +0200
@@ -342,6 +342,11 @@
         g_object_set(G_OBJECT(session), "password", val, NULL);
         g_free(val);
     }
+    if (virt_viewer_file_is_set(file, "username")) {
+        gchar *val = virt_viewer_file_get_username(file);
+        g_object_set(G_OBJECT(session), "username", val, NULL);
+        g_free(val);
+    }
 
     if (virt_viewer_file_is_set(file, "tls-ciphers")) {
         gchar *val = virt_viewer_file_get_tls_ciphers(file);
@@ -462,12 +467,13 @@
 }
 
 static void
-virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED,
+virt_viewer_session_spice_main_channel_event(SpiceChannel *channel,
                                              SpiceChannelEvent event,
                                              VirtViewerSession *session)
 {
     VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
     gchar *password = NULL;
+    gchar *username = NULL;
 
     g_return_if_fail(self != NULL);
 
@@ -488,15 +494,22 @@
         break;
     case SPICE_CHANNEL_ERROR_AUTH:
         DEBUG_LOG("main channel: auth failure (wrong password?)");
+
+        gboolean auth_sasl = spice_channel_test_common_capability(channel, SPICE_COMMON_CAP_AUTH_SASL);
+
         int ret = virt_viewer_auth_collect_credentials(self->priv->main_window,
                                                        "SPICE",
                                                        NULL,
-                                                       NULL, &password);
+                                                       auth_sasl ? &username : NULL,
+                                                       &password);
         if (ret < 0) {
             g_signal_emit_by_name(session, "session-cancelled");
         } else {
             gboolean openfd;
 
+            if (auth_sasl) {
+                g_object_set(self->priv->session, "username", username, NULL);
+            }
             g_object_set(self->priv->session, "password", password, NULL);
             g_object_get(self->priv->session, "client-sockets", &openfd, NULL);
 
@@ -520,6 +533,7 @@
         break;
     }
 
+    g_free(username);
     g_free(password);
 }
 

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]