summaryrefslogtreecommitdiff
path: root/daemon/gvfsbackenddav.c
Commit message (Collapse)AuthorAgeFilesLines
* dav: Prevent g_object_unref call with NULL pointerOndrej Holy2023-02-281-1/+1
| | | | | | | | When the push method in DAV baclend is called with a nonexistent source file, the `GLib-GObject-CRITICAL **: 12:07:04.743: g_object_unref: assertion 'G_IS_OBJECT (object)' failed` message is printed because the `g_object_unref` function is called for a `NULL` pointer. Let's use `g_clear_object` instead to avoid this.
* dav: Prevent usage of NULL when user is not specifiedOndrej Holy2023-01-061-2/+4
| | | | | | | | | | | When the username is not part of an URI, then the following message is printed: `GVFS-CRITICAL **: 12:31:47.663: g_mount_spec_set_with_len_internal: assertion 'value != NULL' failed`. This is because `g_mount_spec_set` is called with `NULL`. It possibly lead to crash when it is build with the `G_DISABLE_CHECKS` option. This bug was introduced recently by the commit 6636d89f. Let's check the value before setting it to fix this. Related: https://gitlab.gnome.org/GNOME/gvfs/-/issues/644
* dav: Fix build without Avahi supportOndrej Holy2022-04-281-7/+9
| | | | | | | | | The recent commits break build when Avahi support is disabled. Let's add the missing ifdef directive and move some variable declarations to fix the build. Part of this change was originally proposed by the reporter of GNOME/gvfs#621. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/621
* dav: Drop user from URI as a workaround for Nextcloud bugOndrej Holy2022-04-221-26/+31
| | | | | | | | | | | | | | | Currently, it is not possible to connect to some Nextcloud servers when a username is part of URI. So this also affects volumes configured over GOA. The main problem seems to be that Nextcloud doesn't send the `WWW-Authenticate` header as a part of 401 response in certain cases (e.g. when 2FA is enabled). A recent libsoup change leads to the situation that DAV backend doesn't have a chance to specify a password as the `authenticate` signal is not called at all. This is because libsoup tries to authenticate with an empty password first. Let's drop the username from URI to avoid the password-less login attempt so the backend has at least one chance to try some password in this case... Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/617
* dav: Port DNS-SD resolver to async API to fix hangs when mountingOndrej Holy2022-04-211-45/+68
| | | | | | | | | | The mount operation hangs for DNS-SD style URIs (i.e. with `dav+sd` and `davs+sd` schemes) after the recent commit 9203fad5. This is because the backend now uses the asynchronous APIs, but the `GVfsDnsSdResolver` is still used synchronously. Let's use asynchronous API for the resolver as well to fix the hangs. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/618
* dav: Rewrite to libsoup async API to fix crashesDaniel Kolesa2022-04-071-725/+1189
| | | | | | | | | | | | | Since libsoup3 cannot deal with threads, we cannot use the do_ methods which execute in a thread pool. However, we can implement these in an async manner, which will bypass the thread pool and get rid of the issue. The write methods are left synchronous as they deal with a memory output stream and do not actually call libsoup. Therefore, we do not have to care whether they are threaded or not. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/609
* dav: Do not lose userinfo when copying URIsDaniel Kolesa2022-04-061-21/+7
| | | | | | | | | | The use of g_uri_build was also bad, since otherwise we would run into this: https://gitlab.gnome.org/GNOME/glib/-/issues/2619 While this should be fixed in glib, we need to work around this behavior for existing installations. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/614
* dav: Fix crashes caused by extra unrefOndrej Holy2022-03-231-1/+0
| | | | | | | | | The `mount_base` uri is unreffed twice. First time over the local `mount_base` pointer and for the second time over the `G_VFS_BACKEND_HTTP (backend)->mount_base` pointer. This leads to `SIGABRT` from the `__pthread_kill_implementation` function. Let's remove that extra unref to fix this crashes. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2066717
* dav, http: port to libsoup3Daniel Kolesa2022-02-011-703/+881
| | | | | | | | | | | | | The dav and http backends of the daemon now use libsoup3. Things should work more or less the same as before. One caveat is that the soup session no longer defaults to ssl-strict, so it will no longer silently accept certificates. This does not affect the DAV backend (it has its own handling which is replicated in the soup3 port) but it does affect the http backend. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/208
* daemon: Set filesystem::use-preview explicitlyAntónio Fernandes2021-01-221-0/+3
| | | | | | | It can be correctly implied from the value of filesystem::remote for many backends, but let's make it explicit for them too. Fixes https://gitlab.gnome.org/GNOME/gvfs/-/issues/497
* Use shorter strings for prompt dialog titlesJonas Dreßler2021-01-151-2/+3
| | | | | | | | | | | | | The layout of the modal dialogs in gnome-shell changed [1] and the title now is larger and uses the style of a headline. Make sure all titles remain fully visible and use shorter strings for those. Also unify the generic "Enter password" strings a bit to make work easier for translators and use this string for most cases: "Authentication Required\nEnter password for “%s”:" [1] https://gitlab.gnome.org/GNOME/gnome-shell/issues/1343
* trash: Do not fail when G_FILE_COPY_NO_FALLBACK_FOR_MOVE is usedwip/oholy/trash-performanceOndrej Holy2020-09-241-0/+7
| | | | | | | | | | | | | | Restoring files from the trash folder is slow in Nautilus as it attempts to do it recursively. This is because G_IO_ERROR_NOT_SUPPORTED is returned from g_file_move when G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag is used. The error is returned from client-side for pull/push operations after commit 2e765449 as in the most cases the copy-and-delete approach is really used there. But the problem is that it is not in all cases, like in the trash backend case, where the native move operation is used in fact. Let's handle the G_FILE_COPY_NO_FALLBACK_FOR_MOVE flag directly in the backends, but not in the trash backend. Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1589
* dav: Be sure that enumeration is possible when looking for a rootOndrej Holy2020-09-231-3/+4
| | | | | | | | | | | | | | | | | | | | | 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
* dav: Add support for NTLM authenticationOndrej Holy2020-05-121-0/+1
| | | | | | | Currently, only Basic and Digest authentication is possible for webdav backend. Let's add support for NTLM also. https://gitlab.gnome.org/GNOME/gvfs/issues/342
* dav: Add support for Negotiate authenticationOndrej Holy2020-05-121-0/+2
| | | | | | | Currently, only Basic and Digest authentication is possible for webdav backend. Let's add support for Negotiate also. https://gitlab.gnome.org/GNOME/gvfs/issues/342
* dav: Don't set a content-type that isn't certainBastien Nocera2019-10-111-5/+10
| | | | | | Don't ignore the result_uncertain flag from g_content_type_guess() as it might cause nautilus to incorrectly think that a particular file is of a certain type, and never check its magic.
* dav: Add support for services with IPv6 link-local addressesOndrej Holy2019-10-111-1/+13
| | | | | | | | | | The mount operation currently fails with "Invalid argument" error if GVfsDnsSdResolver returns link-local IPv6 address. This can quite easily happen also when using File Share functionality provided by GNOME. It fails because the link-local addresses requires interface to be specified. Let's append the interface in them to fix this issue. Fixes: https://gitlab.gnome.org/GNOME/gvfs/issues/423
* dav: Remove brackets from IPv6 address before useOndrej Holy2019-10-101-1/+5
| | | | | | This is follow up of commit d8556a0, which removes brackets when mounting over dav/davs schemes, however, the same fix is also needed when mounting over dav+sd/davs+sd schemes in order to prevent "Invalid URI" error.
* dav: Replace usage of deprecated GTimeVal by GDateTimeOndrej Holy2019-09-201-6/+8
| | | | | GTimeVal is deprecated. Let's replace it by GDateTime in order to prevent the deprecation warnings.
* dav: Fix mounting when 403 is returned for the parent folderOndrej Holy2019-09-131-0/+1
| | | | | | | | | | | | | | The recent commit e9653aa9, which allows mounting when 403 is returned instead of 401, broke the backend for the case when authentication succeeded for subdirectory and 403 is returned for the parent folder. The backend doesn't work properly, even though it doesn't return any error from the mount operation. Nautilus just shows "File is of unknown type" and the backend prints errors like "soup_auth_authenticate: assertion 'password != NULL' failed". Let's prevent usage of the workaround from commit e9653aa9 after the first successful auth to fix this issue. Fixes: https://gitlab.gnome.org/GNOME/gvfs/issues/417
* daemon: Use "Operation not supported" consistentlyMayank Sharma2019-03-211-2/+2
| | | | | | | | | GVfs uses different forms of "Operation not supported" string, e.g. "Operation unsupported", "Operation not supported by backend". Let's use "Operation not supported" consistently as this is also used in GLib. https://gitlab.gnome.org/GNOME/gvfs/issues/170
* dav: Try authenticate again even if 403 was returnedOndrej Holy2019-01-041-2/+29
| | | | | | | | | | | | Some servers e.g. davs://webdav.mc.gmx.net returns 403 status code instead of 401 in case of invalid credentials. This causes that libsoup fails immediately after the first login attempt, which is especially problem in case of the wrong credentials stored in the keyring. A user doesn't have any chance to manually specify correct credentials. Clear the credentials cache and force libsoup to call the authentication callback again... Closes: https://gitlab.gnome.org/GNOME/gvfs/issues/351
* Remove workaround for directory / folder iconswip/rishi/issue-2Debarshi Ray2018-08-141-3/+6
| | | | https://gitlab.gnome.org/GNOME/gvfs/issues/2
* dav: Increase max number of connections to prevent lockupsOndrej Holy2018-07-261-1/+9
| | | | | | | | | | | | Currently, the default value of max-conns-per-host libsoup property is used, which causes dav backend lockups if two files are opened. I don't see any easy solution how to prevent lockups, but we can definitely reduce the chance of them by increasing max-conns properties. Much bigger values are used by browsers nowadays. Hope that 32 is big enough for regular use cases and small enough to not flood a server and not block too much file descriptors... Closes: https://gitlab.gnome.org/GNOME/gvfs/issues/6
* dav: Ignore file size for directoriesOndrej Holy2018-05-151-0/+7
| | | | | | | | | | Most of the servers don't use "getcontentlength" node (which is used to set file size) for directories anyway. However, some servers report total size of files inside the directory, which is not expected and causes issues for clients. Let's simply ignore file size for directories if set. https://gitlab.gnome.org/GNOME/nautilus/issues/431
* dav: Prevent usage of uninitialized variableOndrej Holy2017-09-291-2/+1
| | | | | | | | | | More warnings are printed when building thanks to meson port. The mounting loop may be breaked before is_webdav variable is defined. Let's move the initialization to another place in order to prevent usage of uninitialized variable and the following warning: warning: ‘is_webdav’ may be used uninitialized in this function https://bugzilla.gnome.org/show_bug.cgi?id=786149
* dav: Prevent usage of uninitialized variableOndrej Holy2017-09-291-0/+1
| | | | | | | | | More warnings are printed when building thanks to meson port. The bytes_avail variable is guarded by have_bytes_avail, so it should not be used unitialized, but let's initialize it for sure in order to prevent the following warning: warning: ‘bytes_avail’ may be used uninitialized in this function https://bugzilla.gnome.org/show_bug.cgi?id=786149
* daemon: Avoid overflowing when querying for filesystem infoMichael Terry2017-08-211-1/+1
| | | | | | | Filesystem sizes can be large and in danger of overflowing. Guard against that possibility in the dav and fuse FS query code. https://bugzilla.gnome.org/show_bug.cgi?id=786177
* client: Escape ":[]" chars in host if it is not IPv6Ondrej Holy2016-12-121-1/+2
| | | | | | | | | | | The "[]:" chars are omitted currently when encoding uri, because they are valid for IPv6. This causes problems in some cases, e.g. output from g_file_get_uri(g_file_new_for_uri("dav+sd://foo%3Abar._webdav._tcp.local")) is "dav+sd://foo:bar._webdav._tcp.local/", which is obviously wrong. Add gvfs_is_ipv6 in order to detect IPv6 addresses and encode also "[]:" chars in other cases. Use gvfs_is_ipv6 to detect IPv6 also in some backends. https://bugzilla.gnome.org/show_bug.cgi?id=772849
* Use Unicode in translatable stringsPiotr Drąg2016-10-031-4/+4
| | | | | | See https://developer.gnome.org/hig/stable/typography.html https://bugzilla.gnome.org/show_bug.cgi?id=772219
* dav: Try also root when looking for the shortest prefixOndrej Holy2016-09-121-1/+1
| | | | | | | | Dav backend always tries to mount WebDAV share with the shortest prefix. Unfortunately, it never tries the root when looking for it excepting the case, when the root is already specified. https://bugzilla.gnome.org/show_bug.cgi?id=770549
* dav: better error when we can't find a mount baseChristian Kellner2016-08-291-2/+1
| | | | | | | If we have a DAV share, ie proper DAV header and good PROPFIND call but we are not in a collection we report a better error message. https://bugzilla.gnome.org/show_bug.cgi?id=770549
* dav: properly handle cancellation during mountingChristian Kellner2016-08-291-1/+2
| | | | | | | | | | If the user cancels the authentication dialog during the mount operation, we should catch that case and instead of returing G_IO_ERROR_FAILED we should G_IO_ERROR_FAILED_HANDLED. This will prevent an (expected) error being back to the user. This is in line with what other backends do in the same situation. https://bugzilla.gnome.org/show_bug.cgi?id=770549
* dav: cleanup in case of mount errorChristian Kellner2016-08-291-1/+3
| | | | | | Free the two messages use for mount root detection in case of error. https://bugzilla.gnome.org/show_bug.cgi?id=770549
* dav: better error handling during mountChristian Kellner2016-08-291-21/+44
| | | | | | | | | If we can detect that a location is not a webdav share then prefer that error message over any other. For other error cases also take errors from the PROPFIND call into account. Translate the status code into a proper GIO error code. https://bugzilla.gnome.org/show_bug.cgi?id=770549
* daemon: Set G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE attributeOndrej Holy2016-06-281-0/+3
| | | | | | | Mark all network-based backends as remote. This is useful to remove some hardcoded lists of filesystem types in GTK+. Bump required GLib version accordingly.
* dav: Fix IPv6 address handlingOndrej Holy2016-05-201-2/+15
| | | | | | | | | It is not possible to mount WebDAV share with IPv6 address currently. GMountSpec host contains brackets around the IPv6 address, however SoupURI doesn't. This patch handles this when converting GMountSpec to SoupURI and vice versa. https://bugzilla.gnome.org/show_bug.cgi?id=766631
* dav: Mark files as untrashableDebarshi Ray2015-08-251-0/+2
| | | | | | Otherwise nautilus will offer the wrong action in its UI. https://bugzilla.gnome.org/show_bug.cgi?id=753934
* Set filesystem::type for all backendsRoss Lagerwall2015-08-041-0/+1
| | | | | | | This attribute was being set inconsistently, and is used by the file chooser. https://bugzilla.gnome.org/show_bug.cgi?id=752834
* dav: Emit progress callbacks when copying and movingRoss Lagerwall2015-05-141-53/+32
| | | | | | | | | | For progress in applications like Nautilus to be shown correctly, they need at least one progress callback to be emitted at the end. This is supposed to be guaranteed according to the GIO documentation. With server-side copy and move using webdav, emit a single progress callback at the end with the source file size. https://bugzilla.gnome.org/show_bug.cgi?id=749354
* dav: Verify TLS certificatesRoss Lagerwall2015-04-091-14/+89
| | | | | | | | | | | | | | When mounting a secure webdav share, verify the certificate using the system certificate store, or if that is not possible, ask the user whether it is OK. ssl-strict is enabled for the SoupSession. If the first connection attempt fails, the certificate is presented to the user. If they agree to the certificate, then it is stored and compared with the certificate presented on each subsequent connection. It is an error if the certificate changes. https://bugzilla.gnome.org/show_bug.cgi?id=708306
* dav: do not set "application/octet-stream" mime typeOndrej Holy2015-03-031-5/+1
| | | | | | | | | | Mime type octet-stream is set when writing since commit 635c3b5, because soup_message_set_request requires to be called with mime type and we don't know it. Unfortunatelly some servers returns this mime type for written files instead of real mime type. Use soup_message_body_append instead without mimetype to fix this issue. https://bugzilla.gnome.org/show_bug.cgi?id=687757
* dav: Fix a few memory leaksRoss Lagerwall2015-02-101-2/+5
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=744078
* dav: Trim some duplicated textRoss Lagerwall2015-01-251-15/+2
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=743379
* dav: Fix up error handling when movingRoss Lagerwall2015-01-251-6/+8
| | | | | | | Don't leak the source and target URI when doing a server-side move. Also, don't continue after giving an G_IO_ERROR_EXISTS. https://bugzilla.gnome.org/show_bug.cgi?id=743379
* dav: Add support for server-side copyingRoss Lagerwall2015-01-251-0/+111
| | | | | | | | Use webdav's COPY method to implement support for server-side copying. This improves performance considerably, especially over slow connections. https://bugzilla.gnome.org/show_bug.cgi?id=743379
* dav: don't unescape the uri twiceOndrej Holy2015-01-221-13/+13
| | | | | | | | | path_equal tries to unescape path before comparing. Unfortunately this function is used also for already unescaped paths. Therefore unescaping can fail. This commit reverts changes which was done in commit 50af53d and unescape just uris, which aren't unescaped yet. https://bugzilla.gnome.org/show_bug.cgi?id=743298
* dav: try copy and delete fallback if backup couldn't be createdOndrej Holy2014-11-191-4/+17
| | | | | | | | | | Move operation fails immediately with G_IO_ERROR_CANT_CREATE_BACKUP if G_FILE_COPY_BACKUP is specified. Consequently copy and delete fallback isn't executed. Return NOT_SUPPORTED instead of CANT_CREATE_BACKUP to proceed with the fallback if G_FILE_COPY_NO_FALLBACK_FOR_MOVE isn't specified. https://bugzilla.gnome.org/show_bug.cgi?id=740057
* dav: Use g_try_realloc for output streamsRoss Lagerwall2014-11-041-2/+2
| | | | | | | | | When writing a large amount to a GMemoryOutputStream, the reallocation function can fail. Use g_try_realloc so that failures generate G_IO_ERROR_NO_SPACE rather than abort the process (as happens with g_realloc). https://bugzilla.gnome.org/show_bug.cgi?id=739428
* dav: Ignore parameters of the content type headerRoss Lagerwall2014-08-291-0/+11
| | | | | | | | | | Ignore parameters of the file's content type since these break applications which make use of the content type. E.g. If the server returns a type such as "text/plain; charset=utf-8", the file won't open in a text editor. https://bugzilla.gnome.org/show_bug.cgi?id=676627