[glib/trash-check] trash portal: Fix permission checks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/trash-check] trash portal: Fix permission checks
- Date: Mon, 4 Mar 2019 14:05:37 +0000 (UTC)
commit 35fa50d4c94e5bb2f2e0fbb18468d64af8f447c1
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Mar 4 09:03:13 2019 -0500
trash portal: Fix permission checks
Implement the approach suggested in
https://gitlab.gnome.org/GNOME/glib/merge_requests/276
1. Try to open O_RDWR. On success, pass that fd
2. If EACCESS => fail the trash op, we "need" read-write to successfully trash it
3. If EISDIR => re-open the fd with O_PATH, and pass that (which will fail on snap,
but verify the dir for flatpaks)
gio/gtrashportal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gio/gtrashportal.c b/gio/gtrashportal.c
index a1e82102b..03a47a8b7 100644
--- a/gio/gtrashportal.c
+++ b/gio/gtrashportal.c
@@ -83,9 +83,9 @@ g_trash_portal_trash_file (GFile *file,
path = g_file_get_path (file);
fd = g_open (path, O_RDWR | O_CLOEXEC);
- if (fd == -1 && (errno == EACCES || errno == EISDIR))
- /* If we don't have write access, fall back to read-only */
- fd = g_open (path, O_CLOEXEC | O_RDONLY);
+ if (fd == -1 && errno == EISDIR)
+ /* If we don't have write access, fall back to O_PATH */
+ fd = g_open (path, O_PATH | O_CLOEXEC | O_RDONLY);
errsv = errno;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]