[gvfs/wip/oholy/socket-fixes: 4/5] admin: Fail when peer credentials are not available




commit 09733ddc402fe3999ac323d8d4cbddd938659016
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Mar 30 11:03:51 2021 +0200

    admin: Fail when peer credentials are not available
    
    Currently, critical errors are printed when peer credentials aren't
    available (i.e. session bus fallback is used). Let's return an error
    immediately to prevent the criticals. Also add warning with suggestion
    to allow `--filesystem=xdg-run/gvfsd` access.
    
    https://gitlab.gnome.org/GNOME/gvfs/-/issues/305

 daemon/gvfsbackendadmin.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index d6168520..dd5eb3dc 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -95,6 +95,15 @@ check_permission (GVfsBackendAdmin *self,
   invocation = dbus_job->invocation;
   connection = g_dbus_method_invocation_get_connection (invocation);
   credentials = g_dbus_connection_get_peer_credentials (connection);
+  if (!credentials)
+    {
+      g_warning ("The admin backend doesn't work with the session bus "
+                 "fallback. Your application is probably missing "
+                 "--filesystem=xdg-run/gvfsd privileges.");
+      g_vfs_job_failed_literal (job, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+                                _("Operation not supported"));
+      return FALSE;
+    }
 
   pid = g_credentials_get_unix_pid (credentials, &error);
   if (error != NULL)


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