[Spice-devel] [PATCH 3/3] Add support to handle username when connecting with SASL
Fabiano Fidêncio
fidencio at redhat.com
Thu Sep 25 05:22:50 PDT 2014
From: Dietmar Maurer <dietmar at proxmox.com>
---
gtk/spice-channel-priv.h | 1 +
gtk/spice-channel.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index 03eed38..c769972 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -136,6 +136,7 @@ struct _SpiceChannelPrivate {
GSList *flushing;
gboolean disable_channel_msg;
+ gboolean auth_username_required;
GError *error;
};
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 5d1a86e..bdaf072 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1077,7 +1077,8 @@ static void spice_channel_recv_auth(SpiceChannel *channel)
if (link_res != SPICE_LINK_ERR_OK) {
CHANNEL_DEBUG(channel, "link result: reply %d", link_res);
- g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0, SPICE_CHANNEL_ERROR_AUTH);
+ g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0,
+ c->auth_username_required ? SPICE_CHANNEL_ERROR_AUTH_USER_AND_PASS : SPICE_CHANNEL_ERROR_AUTH);
return;
}
@@ -1254,10 +1255,16 @@ spice_channel_gather_sasl_credentials(SpiceChannel *channel,
switch (interact[ninteract].id) {
case SASL_CB_AUTHNAME:
case SASL_CB_USER:
- g_warn_if_reached();
+ c->auth_username_required = TRUE;
+ if (spice_session_get_username(c->session) == NULL)
+ return FALSE;
+
+ interact[ninteract].result = spice_session_get_username(c->session);
+ interact[ninteract].len = strlen(interact[ninteract].result);
break;
case SASL_CB_PASS:
+ c->auth_username_required = FALSE;
if (spice_session_get_password(c->session) == NULL)
return FALSE;
@@ -1323,6 +1330,8 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
const void *val;
sasl_ssf_t ssf;
static const sasl_callback_t saslcb[] = {
+ { .id = SASL_CB_USER },
+ { .id = SASL_CB_AUTHNAME },
{ .id = SASL_CB_PASS },
{ .id = 0 },
};
--
1.9.3
More information about the Spice-devel
mailing list