[gvfs/wip/oholy/runtime-dir-socket: 3/4] client: Show warning when peer-to-peer connection failed




commit 60ca0cea45fabf2b110f3ec2335f6d179ccf093c
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Sep 25 16:00:49 2020 +0200

    client: Show warning when peer-to-peer connection failed
    
    When peer-to-peer connection fails, the session bus is silently used
    instead by the asynchronous API. Let's add warnings to make it more
    obvious and mention that --filesystem=xdg-run/gvfsd is probably
    missing.

 client/gdaemonfile.c        | 15 ++++++++++++---
 client/gdaemonfilemonitor.c |  6 ++++--
 client/gdaemonmount.c       |  7 +++++--
 client/gvfsiconloadable.c   | 13 ++++++++++++-
 4 files changed, 33 insertions(+), 8 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index f11cf91c..6111b7bd 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -439,7 +439,13 @@ create_proxy_for_file2 (GFile *file1,
 
   connection = _g_dbus_connection_get_sync (mount_info1->dbus_id, cancellable, &local_error);
   if (connection == NULL)
-    goto out;
+    {
+      g_dbus_error_strip_remote_error (local_error);
+      g_warning ("The peer-to-peer connection failed: %s. Your application is "
+                 "probably missing --filesystem=xdg-run/gvfsd privileges.",
+                 local_error->message);
+      goto out;
+    }
 
   proxy = gvfs_dbus_mount_proxy_new_sync (connection,
                                           G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
@@ -613,8 +619,11 @@ async_got_connection_cb (GDBusConnection *connection,
   
   if (connection == NULL)
     {
-      /* TODO: we should probably test if we really want a session bus;
-       *       for now, this code is on par with the old dbus code */ 
+      g_dbus_error_strip_remote_error (io_error);
+      g_warning ("The peer-to-peer connection failed: %s. Falling back to the "
+                 "session bus. Your application is probably missing "
+                 "--filesystem=xdg-run/gvfsd privileges.", io_error->message);
+
       g_bus_get (G_BUS_TYPE_SESSION,
                  g_task_get_cancellable (data->task),
                  bus_get_cb,
diff --git a/client/gdaemonfilemonitor.c b/client/gdaemonfilemonitor.c
index 2d9f958f..6c80c6ab 100644
--- a/client/gdaemonfilemonitor.c
+++ b/client/gdaemonfilemonitor.c
@@ -180,8 +180,10 @@ g_daemon_file_monitor_new (const char *remote_id,
   connection = _g_dbus_connection_get_sync (daemon_monitor->remote_id, NULL, &error);
   if (connection == NULL)
     {
-      g_printerr ("Error getting connection for monitoring: %s (%s, %d)\n",
-                  error->message, g_quark_to_string (error->domain), error->code);
+      g_dbus_error_strip_remote_error (error);
+      g_warning ("The peer-to-peer connection failed: %s. Your application is "
+                 "probably missing --filesystem=xdg-run/gvfsd privileges.",
+                 error->message);
       g_error_free (error);
     }
   else
diff --git a/client/gdaemonmount.c b/client/gdaemonmount.c
index d49fad89..a3cb2578 100644
--- a/client/gdaemonmount.c
+++ b/client/gdaemonmount.c
@@ -315,8 +315,11 @@ async_got_connection_cb (GDBusConnection *connection,
 
   if (connection == NULL)
     {
-      /* TODO: we should probably test if we really want a session bus;
-       *       for now, this code is on par with the old dbus code */ 
+      g_dbus_error_strip_remote_error (io_error);
+      g_warning ("The peer-to-peer connection failed: %s. Falling back to the "
+                 "session bus. Your application is probably missing "
+                 "--filesystem=xdg-run/gvfsd privileges.", io_error->message);
+
       g_bus_get (G_BUS_TYPE_SESSION,
                  g_task_get_cancellable (task),
                  bus_get_cb,
diff --git a/client/gvfsiconloadable.c b/client/gvfsiconloadable.c
index 5050cfbe..45fb6c2c 100644
--- a/client/gvfsiconloadable.c
+++ b/client/gvfsiconloadable.c
@@ -59,7 +59,13 @@ create_proxy_for_icon (GVfsIcon *vfs_icon,
 
   connection = _g_dbus_connection_get_sync (mount_info->dbus_id, cancellable, &local_error);
   if (connection == NULL)
-    goto out;
+    {
+      g_dbus_error_strip_remote_error (local_error);
+      g_warning ("The peer-to-peer connection failed: %s. Your application is "
+                 "probably missing --filesystem=xdg-run/gvfsd privileges.",
+                 local_error->message);
+      goto out;
+    }
 
   proxy = gvfs_dbus_mount_proxy_new_sync (connection,
                                           G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | 
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
@@ -242,6 +248,11 @@ async_got_connection_cb (GDBusConnection *connection,
 
   if (connection == NULL)
     {
+      g_dbus_error_strip_remote_error (io_error);
+      g_warning ("The peer-to-peer connection failed: %s. Falling back to the "
+                 "session bus. Your application is probably missing "
+                 "--filesystem=xdg-run/gvfsd privileges.", io_error->message);
+
       g_bus_get (G_BUS_TYPE_SESSION,
                  g_task_get_cancellable (data->task),
                  bus_get_cb,


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