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

Feature Request: Support for WinFsp Launcher #3340

Open
billziss-gh opened this issue Jul 11, 2019 · 0 comments
Open

Feature Request: Support for WinFsp Launcher #3340

billziss-gh opened this issue Jul 11, 2019 · 0 comments

Comments

@billziss-gh
Copy link
Contributor

billziss-gh commented Jul 11, 2019

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 the net use command with a single backslash: \rclone\REMOTE\PATH\TO\FILES
  • %2: drive used in the net use command: y:
  • %U: user name of the user that issued the net use command in DOMAIN\USERNAME format: 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\FILES to REMOTE: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 symbol a, the second one by the symbol b, etc. So in our example, a would be rclone, b would be REMOTE, c would be PATH, d would be TO, and z would 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 symbol b, the "rest of the path" is everything after b (PATH\TO\FILES). The "replacement path separator" is used to replace all backslashes found within _, thus PATH\TO\FILES becomes PATH/TO/FILES.
    • 1: end the rule and apply it to the first argument (%1).
  • %\\_U: rewrite the string DOMAIN\USERNAME to DOMAIN\\USERNAME.
    • This is necessary because FUSE option parsing uses the backslash as an escape character in -o UserName=DOMAIN\\USERNAME.
  • %\/bU: rewrite the string DOMAIN\USERNAME to USERNAME.

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:

Map Network Drive

OneDrive Folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants