summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2021-05-12 10:29:14 +0200
committerOndrej Holy <oholy@redhat.com>2021-06-07 07:28:17 +0000
commit3b3350a2d651d07c992d08681f389b9ece28993c (patch)
treeee75817b6bf782b0575b15ebca6e7089d270695b
parent141eee12c5c6c37e098cef2f1a80d1df58168d5b (diff)
downloadgvfs-3b3350a2d651d07c992d08681f389b9ece28993c.tar.gz
admin: Fix mount operation hang caused by pkexec failure
Currently, the mount operation for the admin backend can hang when the authentication dialog is dismissed for example. This is because `pkexec` exits before spawning the `gvfsd-admin` daemon. Let's catch that case and return the "Permission denied" error. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/565
-rw-r--r--daemon/mount.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/daemon/mount.c b/daemon/mount.c
index 33cae597..db271dd3 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -415,6 +415,30 @@ child_watch_cb (GPid pid,
gint status,
gpointer user_data)
{
+ MountData *data = user_data;
+ GError *error = NULL;
+ gint code = 0;
+
+ if (!g_spawn_check_exit_status (status, &error))
+ {
+ if (error->domain == G_SPAWN_EXIT_ERROR)
+ code = error->code;
+
+ g_clear_error (&error);
+ }
+
+ /* GVfs daemons always exit with 0, but gvfsd-admin is spawned over pkexec,
+ * which can fail when the authentication dialog is dismissed for example.
+ */
+ if (code == 126 || code == 127)
+ {
+ error = g_error_new_literal (G_IO_ERROR,
+ G_IO_ERROR_PERMISSION_DENIED,
+ _("Permission denied"));
+ mount_finish (data, error);
+ g_error_free (error);
+ }
+
g_spawn_close_pid (pid);
}
@@ -485,7 +509,7 @@ spawn_mount (MountData *data)
}
else
{
- g_child_watch_add (pid, child_watch_cb, NULL);
+ g_child_watch_add (pid, child_watch_cb, data);
}
g_strfreev (argv);