sshfs-win icon indicating copy to clipboard operation
sshfs-win copied to clipboard

Symlinks do not work

Open eric-wieser opened this issue 7 years ago • 28 comments

I think this is simply a case of -o follow_symlinks not being provided as an argument to sshfs. Would it be sane to pass this by default within the net use handler?

I guess a bigger question would be how to actually pass extra arguments to sshfs via net use.

eric-wieser avatar May 11 '17 23:05 eric-wieser

Can you please give me an example of a symlink that does not work? Can you show me what it looks like on the SSH server side (I am particularly interested if it is an absolute or relative symlink).

I am fairly certain that symlinks do work on SSHFS-Win. However there are caveats.

  • It does not support absolute symlinks cleanly.

  • You cannot create symlinks unless you are Administrator on Windows.

billziss-gh avatar May 11 '17 23:05 billziss-gh

I guess a bigger question would be how to actually pass extra arguments to sshfs via net use.

I do not think sshfs-win.c supports passing extra arguments to the underlying sshfs.exe as it is currently. Patches welcome though :)

billziss-gh avatar May 11 '17 23:05 billziss-gh

Ah, looks like they are absolute symlinks, which is likely the problem.

Patches welcome though :)

My question was more "can you think of a sane way to pass arguments", not "how can I do this in the current release".

I guess an external config file could work

eric-wieser avatar May 11 '17 23:05 eric-wieser

My question was more "can you think of a sane way to pass arguments", not "how can I do this in the current release". Cramming yet more things into the URL doesn't sound too sensible.

I was thinking that it might be worthwhile to modify sshfs-win.c to accept extra arguments that it passes to sshfs.exe. Then one could change the registry entry at this location to pass those extra arguments:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\sshfs

billziss-gh avatar May 11 '17 23:05 billziss-gh

Not idea having it under HKEY_LOCAL_MACHINE - ideally, it would be configurable on at least a per-user basis, if not a per-connection one

eric-wieser avatar May 11 '17 23:05 eric-wieser

@billziss-gh Thank you very much for sshfs-win and winfsp.

I'm running into symlink issues too (the filesystems I mount have lots of them) so any quick solution (no matter how hacky) would be greatly appreciated while a more finessed solution is worked out and implemented when time allows.

Thanks again

samej71 avatar Aug 09 '17 04:08 samej71

@samej71 sorry for the very late response. I have just returned from vacation and my responses should be more timely.

What is the exact problem you are experiencing? If it is like the OP's problem, you could recompile sshfs-win.c with the -o follow_symlinks option baked in.

billziss-gh avatar Sep 01 '17 22:09 billziss-gh

@billziss-gh no worries at all. Life happens! :) I currently don't have a working compiler ecosystem and I download/installed/was using the (at the time) latest binary.

When I try to open a symlink that is a folder, I get an "Open Folder"-titled alert with the message "\sshfs\me@place\symlinkname is unavailable. If the location is on this PC, make sure the device of drive is connected or the disc is inserted, and then try again. If the location is on a network, make sure you're connected to the network or Internet, and then try again. If the location still can't be found, it might have been moved or deleted." Obviously, "me", "place", and "symlinkname" are not literal and show the real user, server, and symlink name that I am trying to access.

This only happens when I try to access folders that are symlinks. I have not tried to access symlinked files yet.

I just downloaded and reinstalled both winfsp and sshfs in case the binaries were updated since the last time I tried but I'm getting the same results.

samej71 avatar Sep 21 '17 02:09 samej71

@billziss-gh would you be willing to put an experimental build somewhere and I'll download and try it out?

samej71 avatar Oct 22 '17 16:10 samej71

Would it be possible to set up a build guide for this? I've never set up a cygwin build environment before, and I have the same issue as samej71.

aubade avatar Jan 10 '18 13:01 aubade

In order to build SSHFS-Win you will need:

  • A Cygwin build environment (including gcc, autoconf, etc)
  • The packages required by SSHFS. The fuse package is satisfied by installing WinFsp and the contained "FUSE for Cygwin". The glib and gthread packages are satisfied by the Cygwin glib package, installable via Cygwin setup.
  • You will also need Wix to build the SSHFS-Win installer.
  • To build SSHFS-Win simply:
    $ cd sshfs-win
    $ make
    

billziss-gh avatar Jan 10 '18 21:01 billziss-gh

BTW, there have been a couple of symlink fixes in the latest build of WinFsp 2018.1 B3.

billziss-gh avatar May 01 '18 21:05 billziss-gh

I've just attempted to use the latest build of WinFsp with symlinks. I had success with relative links that stayed within my home directory, but no success with leaving the home directory (../../../opt/www/share/) or by specifying an absolute path (/opt/www/share/). This folder is owned by the same user as the user accessing it.

R4wizard avatar May 21 '18 23:05 R4wizard

Make sure that your symlinks do not have any trailing slashes (i.e. point to /foo and not /foo/). There is a long-standing bug about this, that I will have fixed in WinFsp 2018.2 (i.e. cannot make the cut for the upcoming WinFsp 2018.1).

billziss-gh avatar May 22 '18 00:05 billziss-gh

Hi. I tried your software and I love it for its simplicity. However, I am too having trouble with symlinks. In my case, they point to another hard drive, but I get an error saying that the location is not available. From what I read, I suppose it will be fixed sometime in the future, right?

wonx avatar Jul 03 '18 16:07 wonx

Unfortunately it is not possible to have symlinks that point to an alternative drive using SSHFS-Win. This is because of a conflict of how symlinks work on POSIX/FUSE vs Windows.

You can only have symlinks that point within the same file system. If sshfs is started with -o rellinks then absolute symlinks will be allowed but will be assumed to point within the same file system and converted to relative ones.

billziss-gh avatar Jul 04 '18 14:07 billziss-gh

But does the server actually knows that it is a different file system? From a linux perspective, a different partition is just a folder. e.g. pointing to /media/usb1 from /home/username

wonx avatar Jul 04 '18 16:07 wonx

@wonx the problem is really on Windows.

Windows needs to understand a symlink for many reasons (e.g. when you open a file via a symlink) and it does not understand the POSIX format. So the POSIX format (single root file system) must be translated to the Windows format (with multiple roots on drives) and there lies the problem.

When the symlink is relative it is easy to translate to the Windows format. But when the symlink is absolute it is impossible for the Windows implementation to know what the symlink points to, because there is no single file system root as mentioned. For this reason, absolute symlinks are allowed only when -o rellinks is set, because then absolute symlinks are treated as relative to the mounted file system root (not the overall root).

billziss-gh avatar Jul 05 '18 15:07 billziss-gh

Ohh, I get it now. Thanks for the explanation.

wonx avatar Jul 06 '18 10:07 wonx

Any chance we could get the external configuration? even a registry key would suffice, just so I can have -o follow_symlinks

Chicken-Bones avatar Aug 06 '18 13:08 Chicken-Bones

@Chicken-Bones I am not sure what you are asking for.

billziss-gh avatar Aug 06 '18 17:08 billziss-gh

I believe the problem is that the sshfs arguments are hardcoded in sshfs-win.c and to enable symlinks one has to modify and rebuild it. As not everyone has development environment ready, it would be much easier to use some runtime switch or configuration to control this functionality.

pavelxkrejci avatar Aug 06 '18 18:08 pavelxkrejci

Perhaps this is the same issue I found related to affixing / during symbolic link creation, omitting it worked for me - see: https://github.com/billziss-gh/sshfs-win/issues/69

danielsokolowski avatar Oct 23 '18 04:10 danielsokolowski

i just used mount --bind on the linux side rather than bother with symlinks.

5k3lly avatar Aug 19 '19 14:08 5k3lly

sshfs-win.zip

Installation package with (-o follow_symlinks): .build/x64/dist/sshfs-win-3.5.20195-x64.msi

lexesv avatar Jul 13 '20 11:07 lexesv

I just made aware of sshfs-win -- COOL! Should help many of our datalad users who "mount" remote datalad datasets to their beloved windows boxes. But apparently git-annex'ed files symlinks aren't resolved and thus - fiasco. I would love to see this issue to be finally addressed. I wish I knew how to program on Windows (again, since did last time 22 years ago)

yarikoptic avatar Mar 11 '22 15:03 yarikoptic

I use this at command prompt cmd.exe: installation_path\sshfs-win.exe svc \sshfs\remote_user@remote_host\root_path drive_letter sshfs_options "C:\Program Files\SSHFS-Win\bin\sshfs-win.exe" svc \sshfs\remote_user@remote_host\\ Z: -o -follow_symlinks then I insert ssh_password then press enter. I open Z: drive and i see root filesystem and all symlinks works (relative and absolute symlink). This works with or without option -o -follow_symlinks (i think) because mounting root / filesystem. this works too: "C:\Program Files\SSHFS-Win\bin\sshfs-win.exe" svc \sshfs\remote_user@remote_host\\ Z:

AlessandroGiga avatar Sep 16 '22 14:09 AlessandroGiga

In Windows Registry, go to:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\sshfs\CommandLine

Change it to: svc %1 %2 %U -o follow_symlinks

popnfloss avatar Oct 20 '23 22:10 popnfloss