-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
The question of how to setup rclone for use with the WinFsp Launcher often comes up in this forum and elsewhere. I am opening this issue primarily to address this question, but also to request that rclone natively supports the creation of the necessary registry entries to be used by the WinFsp Launcher.
What is your current rclone version (output from rclone version)?
(Via chocolatey)
rclone v1.48.0
- os/arch: windows/amd64
- go version: go1.12.3
What problem are you are trying to solve?
Users often ask how to setup rclone mount so that they can "map" it as a network drive (via the Explorer or the net use command) or how to setup rclone mount to run under the SYSTEM account. The WinFsp Launcher can be used to support such scenarios; however setting up the Launcher for rclone mount is not straightforward, both because it requires users to make direct registry changes, but also because rclone mount does not understand the default command lines that the Launcher uses to launch file systems.
How do you think rclone should be changed to solve that?
The most recent Beta release of WinFsp (2019.3 B2 / v1.5B2) has added the Launcher ability to rewrite paths passed to the file system during launch. For example this allows a UNC path of \rclone\REMOTE\PATH\TO\FILES to be rewritten to REMOTE:PATH/TO/FILES before being passed to rclone mount. This eliminates the need for rclone mount to support the native UNC syntax in its command line. I discuss this in Path Rewriting below.
Furthermore rclone could be enhanced to have the ability to add the necessary Launcher registry entries during rclone config. I discuss this in Registry Entries further below.
Path Rewriting
For reference in the following, I am assuming that the user issued the command: net use y: \\rclone\REMOTE\PATH\TO\FILES. Assuming that the Launcher is properly configured to handle \rclone prefixes, it will pass the following arguments to the file system:
%1: UNC path used in thenet usecommand with a single backslash:\rclone\REMOTE\PATH\TO\FILES%2: drive used in thenet usecommand:y:%U: user name of the user that issued thenet usecommand inDOMAIN\USERNAMEformat: e.g.WINDOWS\billziss
The latest Launcher (2019.3 B2 / v1.5B2 or later) includes the ability to rewrite these paths in a format that rclone mount accepts:
%\/b:_1: rewrite the path\rclone\REMOTE\PATH\TO\FILEStoREMOTE:PATH/TO/FILES. This works as follows:%\: introduces a path rewriting rule/: defines a "replacement path separator"b: the original UNC path (\rclone\REMOTE\PATH\TO\FILES) is broken down into path components using backslash (\) as a separator. The first path component is referenced by the symbola, the second one by the symbolb, etc. So in our example,awould berclone,bwould beREMOTE,cwould bePATH,dwould beTO, andzwould be the empty string.:: is a literal symbol that is output when the path is rewritten._: means the "rest of the path". In this case because we used the symbolb, the "rest of the path" is everything afterb(PATH\TO\FILES). The "replacement path separator" is used to replace all backslashes found within_, thusPATH\TO\FILESbecomesPATH/TO/FILES.1: end the rule and apply it to the first argument (%1).
%\\_U: rewrite the stringDOMAIN\USERNAMEtoDOMAIN\\USERNAME.- This is necessary because FUSE option parsing uses the backslash as an escape character in
-o UserName=DOMAIN\\USERNAME.
- This is necessary because FUSE option parsing uses the backslash as an escape character in
%\/bU: rewrite the stringDOMAIN\USERNAMEtoUSERNAME.
With this we can now prepare the following command line for rclone mount:
mount %\/b:1 %2 -o VolumePrefix=%\/_1 -o UserName=%\\_U --config=C:\Users\\%\\/bU\.config\rclone\rclone.conf OTHER-ARGS
Registry Entries
With the above discussion in mind we can now determine the Launcher registry entries to create. These are presented below in .reg format, but with this issue I request that rclone adds the ability to produce these registry entries via rclone config or similar mechanism.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\rclone]
"Executable"="C:\\ProgramData\\chocolatey\\bin\\rclone.exe"
"CommandLine"="mount %\\/b:1 %2 -o VolumePrefix=%\\/_1 -o UserName=%\\\\_U --config=C:\\Users\\\\%\\/bU\\.config\\rclone\\rclone.conf"
"Security"="D:P(A;;RPWPLC;;;WD)"
With these registry entries I can now map a network drive from Explorer: