summaryrefslogtreecommitdiff
path: root/daemon/gvfsbackendadmin.c
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2017-07-12 13:36:06 +0200
committerOndrej Holy <oholy@redhat.com>2017-08-04 14:53:13 +0200
commit8e9439ef4abf1525d8c41dc6155e6165c853cac6 (patch)
tree810db7a0d80b00f69086e907250e9896f48d891e /daemon/gvfsbackendadmin.c
parent46956d5d8a862b6391e0aaf044cf380ebdd6762c (diff)
downloadgvfs-8e9439ef4abf1525d8c41dc6155e6165c853cac6.tar.gz
admin: Require mounting for each client explicitly
The admin backend is pretty special, because it can't use GMountOperation for authorization and polkit prompt is shown for each client. This leads to unwanted behavior because the admin prompt might be shown unexpectedly (e.g. when obtaining info for recently used files). Let's require mounting explicitly for each client. So each client gets G_IO_ERROR_NOT_MOUNTED if it hasn't called g_file_mountable_mount before. It works nicely for most of the apps which I tested (e.g. with Nautilus, GEdit, Totem, Evince, GIMP, LibreOffice). However, this requires changes for some applications, which expects that the file is already mounted (e.g. EOG). Unfortunatelly, it breaks utils like "gio list" because it fails with "The specified location is not mounted" error and "gio mount admin:///" doesn't help, because it has different PID. This isn't ideal, but it is better than the unexpected password prompts... https://bugzilla.gnome.org/show_bug.cgi?id=771285
Diffstat (limited to 'daemon/gvfsbackendadmin.c')
-rw-r--r--daemon/gvfsbackendadmin.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index 66c93797..d67353da 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -835,6 +835,23 @@ do_mount (GVfsBackend *backend,
GVfsBackendAdmin *self = G_VFS_BACKEND_ADMIN (backend);
GVfsJob *job = G_VFS_JOB (mount_job);
GError *error = NULL;
+ GMountSpec *real_spec;
+ const gchar *client;
+
+ client = g_mount_spec_get (mount_spec, "client");
+ if (client == NULL)
+ {
+ g_vfs_job_failed_literal (job, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ _("Invalid mount spec"));
+ return;
+ }
+
+ g_debug ("client=%s\n", client);
+
+ real_spec = g_mount_spec_new ("admin");
+ g_mount_spec_set (real_spec, "client", client);
+ g_vfs_backend_set_mount_spec (backend, real_spec);
+ g_mount_spec_unref (real_spec);
self->authority = polkit_authority_get_sync (NULL, &error);
@@ -880,15 +897,10 @@ static void
g_vfs_backend_admin_init (GVfsBackendAdmin *self)
{
GVfsBackend *backend = G_VFS_BACKEND (self);
- GMountSpec *mount_spec;
g_mutex_init (&self->polkit_mutex);
g_vfs_backend_set_user_visible (backend, FALSE);
- mount_spec = g_mount_spec_new ("admin");
- g_vfs_backend_set_mount_spec (backend, mount_spec);
- g_mount_spec_unref (mount_spec);
-
g_vfs_backend_set_icon_name (backend, "folder");
g_vfs_backend_set_symbolic_icon_name (backend, "folder-symbolic");
}