[virt-tools-list] [PATCH] Do not fail when the auth dialog is cancelled

Christophe Fergeau cfergeau at redhat.com
Tue Sep 23 12:55:55 UTC 2014


On Tue, Sep 23, 2014 at 02:39:53PM +0200, Christophe Fergeau wrote:
> On Tue, Sep 23, 2014 at 01:34:43PM +0200, Fabiano Fidêncio wrote:
> > https://bugzilla.redhat.com/show_bug.cgi?id=1145460
> > ---
> >  src/virt-viewer.c | 19 ++++++++++++-------
> >  1 file changed, 12 insertions(+), 7 deletions(-)
> > 
> > diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> > index f8a9ab5..3d7511a 100644
> > --- a/src/virt-viewer.c
> > +++ b/src/virt-viewer.c
> > @@ -57,6 +57,7 @@ struct _VirtViewerPrivate {
> >      gboolean withEvents;
> >      gboolean waitvm;
> >      gboolean reconnect;
> > +    gboolean auth_cancelled;
> >  };
> >  
> >  G_DEFINE_TYPE (VirtViewer, virt_viewer, VIRT_VIEWER_TYPE_APP)
> > @@ -615,6 +616,7 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
> >  {
> >      char **username = NULL, **password = NULL;
> >      VirtViewer *app = cbdata;
> > +    VirtViewerPrivate *priv = app->priv;
> >      int i;
> >      int ret = -1;
> >  
> > @@ -638,11 +640,11 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
> >      if (username || password) {
> >          VirtViewerWindow *vwin = virt_viewer_app_get_main_window(VIRT_VIEWER_APP(app));
> >          GtkWindow *win = virt_viewer_window_get_window(vwin);
> > -        ret = virt_viewer_auth_collect_credentials(win,
> > -                                                   "libvirt",
> > -                                                   app->priv->uri,
> > -                                                   username, password);
> > -        if (ret < 0)
> > +        priv->auth_cancelled = !virt_viewer_auth_collect_credentials(win,
> > +                                                                     "libvirt",
> > +                                                                     app->priv->uri,
> > +                                                                     username, password);
> > +        if (priv->auth_cancelled)
> >              goto cleanup;
> >      } else {
> >          ret = 0;
> > @@ -695,8 +697,11 @@ virt_viewer_connect(VirtViewerApp *app)
> >                                      &auth_libvirt,
> >                                      oflags);
> >      if (!priv->conn) {
> > -        virt_viewer_app_simple_message_dialog(app, _("Unable to connect to libvirt with URI %s"),
> > -                                              priv->uri ? priv->uri : _("[none]"));
> > +        if (!priv->auth_cancelled) {
> 
> I'd put this on the same line as if (!priv->conn), ack otherwise.

After further discussion, this can't be done this way as the full code
is
if (!priv->conn) {
    if (!priv->auth_cancelled)
        show error dialog

    return -1;


We want the return -1 regardless of auth_cancelled value so patch is
good as is.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20140923/4ef04e89/attachment.sig>


More information about the virt-tools-list mailing list