Re: [PATCH virt-viewer v3 2/2] ovirt: Allow to cancel authentication without showing error dialog

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

 



Hi,

> 
> I commented in the bug that you filed for that:
> https://bugzilla.gnome.org/show_bug.cgi?id=746455
> « I think it could sometimes be valid to try to authenticate with no
> username/password?
> Maybe introducing rest_proxy_auth_cancel() in the public API would be
> better? »
> 

With the rest_proxy_auth_cancel() https://bugzilla.gnome.org/show_bug.cgi?id=746537
and new libgovirt CANCELLED error https://bugzilla.gnome.org/show_bug.cgi?id=746539
the patch for virt-viewer can look like this (+using some version checks for libgovirt and librest):

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 4110b1e..1d6fb63 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -704,7 +704,7 @@ parse_ovirt_uri(const gchar *uri_str, char **rest_uri, char **name, char **usern
 }
 
 static gboolean
-authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth,
+authenticate_cb(RestProxy *proxy, RestProxyAuth *auth,
                 G_GNUC_UNUSED gboolean retrying, gpointer user_data)
 {
     gchar *username = NULL;
@@ -729,6 +729,8 @@ authenticate_cb(RestProxy *proxy, G_GNUC_UNUSED RestProxyAuth *auth,
                      "username", username,
                      "password", password,
                      NULL);
+    } else {
+        rest_proxy_auth_cancel(auth);
     }
 
     g_free(username);
@@ -863,6 +865,12 @@ create_ovirt_session(VirtViewerApp *app, const char *uri, GError **err)
     api = ovirt_proxy_fetch_api(proxy, &error);
     if (error != NULL) {
         g_debug("failed to get oVirt 'api' collection: %s", error->message);
+        if (g_error_matches(error, OVIRT_REST_CALL_ERROR, OVIRT_REST_CALL_ERROR_CANCELLED))
+            g_clear_error(&error);
+            g_set_error_literal(&error,
+                                VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED,
+                                _("Authentication was cancelled"));
+        }
         goto error;
     }
     vms = ovirt_api_get_vms(api);




Thanks,

Pavel

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list





[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux