[gvfs/wip/oholy/dav-mount-check] dav: Be sure that enumeration is possible when looking for a root




commit b03b7955cf25e863c1aac2853ddaf647bfb70ea8
Author: Ondrej Holy <oholy redhat com>
Date:   Mon May 11 14:16:48 2020 +0200

    dav: Be sure that enumeration is possible when looking for a root
    
    The DAV backend tries to find the top-most directory when mounting.
    Unfortunatelly, for example with nextcloud.com, the enumeration job
    fails with `Method not allowed` error for the root directory found
    by this logic:
    
    ```
    <?xml version="1.0" encoding="utf-8"?>
    <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns";>
      <s:exception>Sabre\DAV\Exception\MethodNotAllowed</s:exception>
      <s:message>Listing members of this collection is disabled</s:message>
    </d:error>
    ```
    
    This is because nextcloud.com prevents listing of its users. Let's
    change the mount logic and always require info about children to be
    sure that enumeration won't fail later.
    
    Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/468

 daemon/gvfsbackenddav.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index 4ac94aca..5929ab6a 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -1446,7 +1446,6 @@ stat_location (GVfsBackend  *backend,
   return res;
 }
 
-
 /* ************************************************************************* */
 /* Authentication */
 
@@ -1930,8 +1929,10 @@ do_mount (GVfsBackend  *backend,
 
   last_good_path = NULL;
   msg_opts = soup_message_new_from_uri (SOUP_METHOD_OPTIONS, mount_base);
-  msg_stat = stat_location_begin (mount_base, FALSE);
 
+  /* The count_children parameter is intentionally set to TRUE to be sure that
+     enumeration is possible: https://gitlab.gnome.org/GNOME/gvfs/-/issues/468 */
+  msg_stat = stat_location_begin (mount_base, TRUE);
 
   do {
     GFileType file_type;
@@ -2012,7 +2013,7 @@ do_mount (GVfsBackend  *backend,
 
     if (is_collection == FALSE)
       break;
-    
+
     /* we have found a new good root, try the parent ... */
     g_free (last_good_path);
     last_good_path = mount_base->path;


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