winfsp / sshfs-win

SSHFS For Windows
https://winfsp.dev
Other
5.15k stars 260 forks source link

Drive letter captured by first user and not released. #200

Open Rizos39 opened 4 years ago

Rizos39 commented 4 years ago

I have installed SSHFS-Win 2020 (x64) 3.5.20024 and WinFsp 2020 1.6.20027 on a Window server 2016 and I am experiencing an unexpected behavior, I don't know if this is by design or if it is an bug. When a user maps a path to a letter using (net use X: \sshfs.r\user_1@host) that letter appears used for others users in the server a kind of global letter usage.

Accessing the path from the second user (dir x:\) gives: File Not Found.

Global letter usage of drive letter is annoying because it makes us not be able to use the same path for files, also once a letter is used in a session I can't find how to release it.

To reproduce:

User_1 in his session:

C:\Users\user_1>net use X: \\sshfs.r\user_1@192.168.0.1\folder_sftp user_1_pass
C:\Users\user_1>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
             X:        \\sshfs.r\user_1@192.168.0.1\folder_sftp 
                                                WinFsp.Np
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

User_2 in his session:

C:\Users\user_2>net use X: \\sshfs.r\user_2@192.168.0.1\folder_sftp user_2_pass
System error 85 has occurred.

The local device name is already in use.

C:\Users\user_2>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
             X:        \\sshfs.r\user_1@192.168.0.1\folder_sftp
                                                WinFsp.Np
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

C:\Users\user_2>dir x:\
 Volume in drive X has no label.
 Volume Serial Number is 6AEC-8D35

 Directory of x:\

File Not Found
C:\Users\user_2>

User_1:

C:\Users\user_1>net use x: /delete /y
x: was deleted successfully.

C:\Users\user_1>net use x: /delete /y
The network connection could not be found.

More help is available by typing NET HELPMSG 2250.

C:\Users\user_1>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
             X:        \\sshfs.r\user_1@10.132.6.168
                                                WinFsp.Np
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

C:\Users\user_1>

Why is drive X: still there ? ... some kind of caching ?

User_2:

C:\Users\user_2>net use X: \\sshfs.r\user_2@192.168.0.1\folder_sftp user_2_pass
System error 85 has occurred.

The local device name is already in use.

C:\Users\user_2>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
             X:        \\sshfs.r\user_1@192.168.0.1\folder_sftp
                                                WinFsp.Np
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

How do I get ride of X: ?

Is it possible for each user to have their own letter X:? Normal Windows sharing works this way as far as I know. šŸ˜ƒ

Thanks in advance

Rizos39 commented 4 years ago

Just to comment that several minutes after net use x: / delete / y, the letter is released and can be used by anyone. It is as if there was a certain delay between the command and the effective release by windows, but a delay of minutes.

billziss-gh commented 4 years ago

The drives created by sshfs-win are global.

WinFsp supports local drives but I have not tested them with sshfs-win. They may or may not work, but if you want to try them try adding the registry setting RunAs="." to the sshfs registry entry (found at HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\sshfs).

Rizos39 commented 4 years ago

I did it for the 3 services: sshfs , sshfs.k and sshfs.r And apparently it works. I will try it for a few days and comment back how it goes.

Thank you very much !! šŸ˜„

Rizos39 commented 4 years ago

As promised here is my review ..

I'm sorry to say that it works with drawbacks, in an unexpected way.

When a user_1 mounts an SFTP on a unit/letter, it allows a user_2 to mount that same SFTP or another one on that same letter, once done the registry touch šŸ˜„ !!

But then when user_2 does net use * /delete /y or logout, he/she disconnects all his connections and also user_1's. That is, when a user disconnects his connections, by logout or by command, all connections in the system are disconnected.

In addition to this, when user_2 does net use he see all his own connections and those of other users (tested with 2 users only).

Other point is that if user_2 uses the same credentials that user_1 (shared account for example), user_2 gets System error 67 has occurred.; The network name cannot be found

And one additional point, on several occasions I ended up with connections without any associated letters and that I could not close even doing logoff of all users. I had to restart the server.

To reproduce:

I had already set this in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\sshfs   RunAs="."
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\sshfs.k RunAs="."
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\sshfs.r RunAs="."

User_1 in his session:

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\user_1>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

C:\Users\user_1>net use X: \\sshfs.r\user_1@192.168.0.1\folder_sftp user_1_pass
The command completed successfully.

C:\Users\user_1>net use Y: \\sshfs.r\user_shared@192.168.0.2\path_here user_shared_pass
The command completed successfully.

C:\Users\user_1>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
             X:        \\sshfs.r\user_1@192.168.0.1\folder_sftp
                                                WinFsp.Np
             Y:        \\sshfs.r\user_shared@192.168.0.2\path_here
                                                WinFsp.Np
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

C:\Users\user_1>

User_2 in his session:

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\user_2>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
                       \\sshfs.r\user_shared@192.168.0.2\path_here
                                                WinFsp.Np
                       \\sshfs.r\user_1@192.168.0.1\folder_sftp
                                                WinFsp.Np
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

C:\Users\user_2>net use X: \\sshfs.r\user_2@192.168.0.1\folder_sftp user_2_pass
The command completed successfully.

C:\Users\user_2>net use Y: \\sshfs.r\user_shared@192.168.0.2\path_here user_shared_pass
System error 67 has occurred.

The network name cannot be found.

C:\Users\user_2>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
             X:        \\sshfs.r\user_2@192.168.0.1\folder_sftp
                                                WinFsp.Np
                       \\sshfs.r\user_shared@192.168.0.2\path_here
                                                WinFsp.Np
                       \\sshfs.r\user_1@192.168.0.1\folder_sftp
                                                WinFsp.Np
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

C:\Users\user_2>
C:\Users\user_2>
C:\Users\user_2>net use * /delete /y
You have these remote connections:

    X:              \\sshfs.r\user_2@192.168.0.1\folder_sftp
                    \\sshfs.r\user_shared@192.168.0.2\path_here
                    \\sshfs.r\user_1@192.168.0.1\folder_sftp
                    \\TSCLIENT\C
Continuing will cancel the connections.

The command completed successfully.

C:\Users\user_2>net use * /delete /y
You have these remote connections:

                    \\TSCLIENT\C
Continuing will cancel the connections.

The command completed successfully.

C:\Users\user_2>

Issues found here:

User_1 in his session:

C:\Users\user_1>net use
New connections will be remembered.

Status       Local     Remote                    Network

-------------------------------------------------------------------------------
Unavailable  X:        \\sshfs.r\user_1@192.168.0.1\folder_sftp
                                                Windows File System Proxy
Unavailable  Y:        \\sshfs.r\user_shared@192.168.0.2\path_here
                                                Windows File System Proxy
                       \\TSCLIENT\C              Microsoft Terminal Services
The command completed successfully.

C:\Users\user_1>
C:\Users\user_1>net use * /delete /y
You have these remote connections:

    X:              \\sshfs.r\user_1@192.168.0.1\folder_sftp
    Y:              \\sshfs.r\user_shared@192.168.0.2\path_here
                    \\TSCLIENT\C
Continuing will cancel the connections.

The command completed successfully.

C:\Users\user_1>net use * /delete /y
You have these remote connections:

                    \\TSCLIENT\C
Continuing will cancel the connections.

The command completed successfully.

C:\Users\user_1>

Issues found:

Does this make any sense to you ? , is really strange behavior.