mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 23:00:54 +00:00
Fix inconsistencies in session auth failures
The spice session implementation can retry authentication on its own, whereas the vnc session needs to tear down the session and re-connect in order to retry a failed authentication. This results in the following inconsistent behavior: VNC session: - emits a 'session-auth-failed' signal when the client does not support a particular authentication type (i.e.: a non-recoverable error) Spice session: - emits a 'session-auth-failed' signal when user enters an incorrect password, and immediately retries auth internally VNC session: - emits a 'session-auth-refused' error when user enters an invalid password (i.e.: a recoverable error) Spice Session: - never emits a 'session-auth-refused' signal Because of these differences, the VirtViewerApp code to handle authentication failures is a bit confusing and difficult to maintain. To fix this issue, make both the spice and VNC sessions emit the same signal when similar errors occur. We use the new session API added in the last commit to determine whether the session supports automatic retries so we know how to handle the signal.
This commit is contained in:
parent
5c0ed8a99f
commit
271c51d8de
@ -1488,7 +1488,7 @@ static void virt_viewer_app_cancelled(VirtViewerSession *session,
|
||||
}
|
||||
|
||||
|
||||
static void virt_viewer_app_auth_refused(VirtViewerSession *session G_GNUC_UNUSED,
|
||||
static void virt_viewer_app_auth_refused(VirtViewerSession *session,
|
||||
const char *msg,
|
||||
VirtViewerApp *self)
|
||||
{
|
||||
@ -1496,6 +1496,15 @@ static void virt_viewer_app_auth_refused(VirtViewerSession *session G_GNUC_UNUSE
|
||||
int ret;
|
||||
VirtViewerAppPrivate *priv = self->priv;
|
||||
|
||||
if (virt_viewer_session_can_retry_auth(session)) {
|
||||
virt_viewer_app_simple_message_dialog(self,
|
||||
_("Unable to authenticate with remote desktop server at %s: %s\n"),
|
||||
priv->pretty_address, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* if the session implementation cannot retry auth automatically, the
|
||||
* VirtViewerApp needs to schedule a new connection to retry */
|
||||
dialog = gtk_message_dialog_new(virt_viewer_window_get_window(priv->main_window),
|
||||
GTK_DIALOG_MODAL |
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@ -1515,7 +1524,6 @@ static void virt_viewer_app_auth_refused(VirtViewerSession *session G_GNUC_UNUSE
|
||||
priv->authretry = FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void virt_viewer_app_auth_failed(VirtViewerSession *session G_GNUC_UNUSED,
|
||||
const char *msg,
|
||||
VirtViewerApp *self)
|
||||
|
||||
@ -617,7 +617,7 @@ virt_viewer_session_spice_main_channel_event(SpiceChannel *channel,
|
||||
}
|
||||
|
||||
if (self->priv->pass_try > 0)
|
||||
g_signal_emit_by_name(session, "session-auth-failed",
|
||||
g_signal_emit_by_name(session, "session-auth-refused",
|
||||
error != NULL ? error->message : _("Invalid password"));
|
||||
self->priv->pass_try++;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user