Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a directory that already exists returns EPERM instead of EEXIST on OpenSSH #243

Closed
peterbelm opened this issue Jan 16, 2021 · 1 comment

Comments

@peterbelm
Copy link
Contributor

When connected to an OpenSSH server (and probably others), attempting to create a directory that already exists causes a generic Status 4 'Failure' result from the server. This is mapped to EPERM in sshfs, when really it should be reporting EEXIST.

While not usually a problem, code that relies on EEXIST being returned can encounter problems (such as git). This is the root cause of a downstream issue in sshfs-win.

I've created a pull request with a patch that will perform an access check if the mkdir request fails with EPERM, returning the correct EEXIST code if the access is successful. With the patch a git clone works properly on my machine with sshfs-win.

#242

@Nikratio
Copy link
Contributor

Closing this since the PR has been merged.

mtremer pushed a commit to ipfire/ipfire-2.x that referenced this issue Nov 24, 2021
- Update from 3.7.1 to 3.7.2
- Update of rootfile not required
- Changelog
   Release 3.7.2 (2021-06-08)
     * Added a secondary check so if a mkdir request fails with EPERM an access request
       will be tried - returning EEXIST if the access was successful.
       Fixes: libfuse/sshfs#243

Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 2, 2021
I have added a lot of unpleasant hacks to the code in order to make it
work with NetBSD librefuse. We really should fix it. I will probably
do it later. Release notes from the upstream are as follows:


Release 3.7.2 (2021-06-08)
--------------------------
* Added a secondary check so if a mkdir request fails with EPERM an access request will be
  tried - returning EEXIST if the access was successful.
    Fixes: libfuse/sshfs#243

Release 3.7.1 (2020-11-09)
--------------------------
* Minor bugfixes.

Release 3.7.0 (2020-01-03)
--------------------------
* New max_conns option enables the use of multiple connections to improve responsiveness
  during large file transfers. Thanks to Timo Savola for doing most of the implementation
  work, and thanks to CEA.fr for sponsoring remaining bugfixes and cleanups!

* The `buflimit` workaround is now disabled by default. The corresponding bug in OpenSSH
  has been fixed in 2007
  (cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365541#37), so this shouldn't be
  needed anymore. If you depend on this workaround, please let the SSHFS maintainers know,
  otherwise support for the workaround will be removed completely in a future version.

Release 3.6.0 (2019-11-03)
--------------------------
* Added "-o direct_io" option.
  This option disables the use of page cache in kernel.
  This is useful for example if the file size is not known before reading it.
  For example if you mount /proc dir from a remote host without the direct_io
  option, the read always will return zero bytes instead of actual data.
* Added --verbose option.
* Fixed a number of compiler warnings.
* Improved performance under OS X.

Release 3.5.2 (2019-04-13)
--------------------------
* Fixed "-o idmap=user" to map both UID and GID on all OSs.
* Fixed improper handling of sequential spaces spaces in "ssh_command" option

Release 3.5.1 (2018-12-22)
--------------------------
* Documentation updates
* Build system updates
* Added "BindInterface" as valid "-o" option.

Release 3.5.0 (2018-08-28)
--------------------------
* Fixed error code returned by rename(), allowing proper fallback.
* Port to Cygwin.

Release 3.4.0 (2018-06-29)
--------------------------
* Make utimens(NULL) result in timestamp "now" -- no more touched files
  dated 1970-01-01
* New `createmode` workaround.
* Fix `fstat` workaround regression.

Release 3.3.2 (2018-04-29)
--------------------------
* New `renamexdev` workaround.

Release 3.3.1 (2017-10-25)
--------------------------
* Manpage is now installed in correct directory.
* SSHFS now supports (or rather: ignores) some options that it may
  receive as result of being mounted from ``/etc/mtab``. This includes
  things like ``user``, ``netdev``, or ``auto``.

SSHFS 3.3.0 (2017-09-20)
------------------------
* Dropped support for writeback caching (and, as a consequence,
  "unreliable append" operation). As of kernel 4.14, the FUSE module's
  writeback implementation is not compatible with network filesystems
  and there are no imminent plans to change that.
* Add support for mounting from /etc/fstab
* Dropped support for building with autotools.
* Added missing options to man page.

Release 3.2.0 (2017-08-06)
--------------------------
* Re-enabled writeback cache.
* SSHFS now supports O_APPEND.

Release 3.1.0 (2017-08-04)
--------------------------
* Temporarily disabled the writeback cache feature, since there
  have been reports of dataloss when appending to files when
  writeback caching is enabled.

* Fixed a crash due to a race condition when listing
  directory contents.

* For improved backwards compatibility, SSHFS now also silently
  accepts the old ``-o cache_*`` options.

Release 3.0.0 (2017-07-08)
--------------------------
* sshfs now requires libfuse 3.1.0 or newer.
* When supported by the kernel, sshfs now uses writeback caching.
* The `cache` option has been renamed to `dir_cache` for clarity.
* Added unit tests
* --debug now behaves like -o debug_sshfs, i.e. it enables sshfs
  debugging messages rather than libfuse debugging messages.
* Documented limited hardlink support.
* Added support for building with Meson.
* Added support for more SSH options.
* Dropped support for the *nodelay* workaround - the last OpenSSH
  version for which this was useful was released in 2006.
* Dropped support for the *nodelaysrv* workaround. The same effect
  (enabling NODELAY on the server side *and* enabling X11 forwarding)
  can be achieved by explicitly passing `-o ForwardX11`
* Removed support for `-o workaround=all`. Workarounds should always
  enabled explicitly and only when needed. There is no point in always
  enabling a potentially changing set of workarounds.

Release 2.9 (2017-04-17)
------------------------
* Improved support for Cygwin.
* Various small bugfixes.

Release 2.8 (2016-06-22)
------------------------
* Added support for the "fsync" extension.
* Fixed a build problem with bitbake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants