[Spice-devel] [PATCH] Report invalid password as a special auth error

Christophe Fergeau cfergeau at redhat.com
Tue May 26 07:14:02 PDT 2015


Hey,

I think you should report an error somehow in
spice_channel_send_spice_ticket() if SpiceSession::password is too
long.

Christophe

On Fri, May 22, 2015 at 06:12:35PM +0200, Cédric Bosdonnat wrote:
> Provide a special authentication error message for too long passwords.
> ---
>  Note: this patch needs a pending one for spice-common. submodule will
>  need to be updated.
> 
>  gtk/spice-channel.c | 18 ++++++++++++++----
>  gtk/spice-client.h  |  2 ++
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
> index 4e7d8b7..fbe3ab1 100644
> --- a/gtk/spice-channel.c
> +++ b/gtk/spice-channel.c
> @@ -1051,7 +1051,8 @@ static void spice_channel_send_spice_ticket(SpiceChannel *channel)
>  }
>  
>  /* coroutine context */
> -static void spice_channel_failed_authentication(SpiceChannel *channel)
> +static void spice_channel_failed_authentication(SpiceChannel *channel,
> +                                                gboolean invalidPassword)
>  {
>      SpiceChannelPrivate *c = channel->priv;
>  
> @@ -1060,6 +1061,11 @@ static void spice_channel_failed_authentication(SpiceChannel *channel)
>                              SPICE_CLIENT_ERROR,
>                              SPICE_CLIENT_ERROR_AUTH_NEEDS_PASSWORD_AND_USERNAME,
>                              _("Authentication failed: password and username are required"));
> +    else if (invalidPassword)
> +        g_set_error_literal(&c->error,
> +                            SPICE_CLIENT_ERROR,
> +                            SPICE_CLIENT_ERROR_AUTH_INVALID_PASSWORD,
> +                            _("Authentication failed: password is too long"));
>      else
>          g_set_error_literal(&c->error,
>                              SPICE_CLIENT_ERROR,
> @@ -1086,9 +1092,13 @@ static gboolean spice_channel_recv_auth(SpiceChannel *channel)
>          return FALSE;
>      }
>  
> -    if (link_res != SPICE_LINK_ERR_OK) {
> +    if (link_res == SPICE_LINK_ERR_INVALID_PASSWORD) {
> +        CHANNEL_DEBUG(channel, "link result: invalid password");
> +        spice_channel_failed_authentication(channel, TRUE);
> +        return FALSE;
> +    } if (link_res != SPICE_LINK_ERR_OK) {
>          CHANNEL_DEBUG(channel, "link result: reply %d", link_res);
> -        spice_channel_failed_authentication(channel);
> +        spice_channel_failed_authentication(channel, FALSE);
>          return FALSE;
>      }
>  
> @@ -1662,7 +1672,7 @@ error:
>      if (saslconn)
>          sasl_dispose(&saslconn);
>  
> -    spice_channel_failed_authentication(channel);
> +    spice_channel_failed_authentication(channel, FALSE);
>      ret = FALSE;
>  
>  cleanup:
> diff --git a/gtk/spice-client.h b/gtk/spice-client.h
> index c2474d1..58d1f76 100644
> --- a/gtk/spice-client.h
> +++ b/gtk/spice-client.h
> @@ -60,6 +60,7 @@ G_BEGIN_DECLS
>   * @SPICE_CLIENT_USB_DEVICE_LOST: usb device disconnected (fatal IO error)
>   * @SPICE_CLIENT_ERROR_AUTH_NEEDS_PASSWORD: password is required
>   * @SPICE_CLIENT_ERROR_AUTH_NEEDS_PASSWORD_AND_USERNAME: password and username are required
> + * @SPICE_CLIENT_ERROR_AUTH_INVALID_PASSWORD: password is too long
>   *
>   * Error codes returned by spice-client API.
>   */
> @@ -70,6 +71,7 @@ typedef enum
>      SPICE_CLIENT_USB_DEVICE_LOST,
>      SPICE_CLIENT_ERROR_AUTH_NEEDS_PASSWORD,
>      SPICE_CLIENT_ERROR_AUTH_NEEDS_PASSWORD_AND_USERNAME,
> +    SPICE_CLIENT_ERROR_AUTH_INVALID_PASSWORD,
>  } SpiceClientError;
>  
>  GQuark spice_client_error_quark(void);
> -- 
> 2.1.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150526/c6833fa8/attachment-0001.sig>


More information about the Spice-devel mailing list