[glib/glib-2-72: 1/2] Fix trashing sandboxed directories




commit cdf74f8169da90694590318569ad555c29253c37
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Apr 4 10:26:13 2022 -0400

    Fix trashing sandboxed directories
    
    We must not open the fd with O_PATH|O_NOFOLLOW,
    since the portal rejects that combination. Leaving
    out O_NOFOLLOW is fine in this case - we know it
    is a directory, we just received EISDIR.
    
    Fixes: #2629

 gio/gtrashportal.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gio/gtrashportal.c b/gio/gtrashportal.c
index 03c9332979..2f739600cf 100644
--- a/gio/gtrashportal.c
+++ b/gio/gtrashportal.c
@@ -89,8 +89,12 @@ g_trash_portal_trash_file (GFile   *file,
 
   fd = g_open (path, O_RDWR | O_CLOEXEC | O_NOFOLLOW);
   if (fd == -1 && errno == EISDIR)
-    /* If it is a directory, fall back to O_PATH */
-    fd = g_open (path, O_PATH | O_CLOEXEC | O_RDONLY | O_NOFOLLOW);
+    /* If it is a directory, fall back to O_PATH.
+     * Remove O_NOFOLLOW since
+     * a) we know it is a directory, not a symlink, and
+     * b) the portal reject this combination
+     */
+    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]