Repository navigation
Document autorun - #4972
Document autorun#4972
Conversation
|
I noted a stray The Linux docs look a bit thin? Maybe we should ask @animosity22 to contribute a setting up rclone with systemd section? Advice on how to avoid multiple rclone's running with cron is useful too. |
|
I encountered that rclone mounts on Windows tend to have rather long command line which doesn't fit in the slim field of nssm dialog, but its environment tab is wide enough, so I prefer to |
|
Good tip, @ivandeex. I can include a note about this. I don't know if we should include even more details on how to configure it with nssm? You seem to have experience with rclone mount and nssm, are you running it as SYSTEM user then? When installing as "self-contained" service with powershell Same with task scheduler, except with the "Run only when user is logged on" mode where it runs in my interactive session. With the "Run whether user is logged on or not" it will always run elevated regardless of the "Run with highest privileges" option, and I can not access the mount from my user - not even from an elevated command prompt. |
effe09c to
958a7aa
Compare
No, impossible! ... after a quick amend and force-push :) It was in the linux description, which I did not spend much time on. The Synchting guide had what seemed to be good descriptions for Linux and macOS as well, but I was kind of hoping someone else were willing to verify/adapt them to rclone (or write from scratch).. Syncthing has only the "syncing forever in background" mode, while rclone typically will do periodic syncing on schedule, and then also have mounting and all the other possible modes, so the description may not fit exactly. |
No, I'm running it with my interactive Windows user.
Currently I configure manually on Windows. I don't use PowerShell commandlets for that. If I need to restart a mount, I use
It's because issue #3216 is still unresolved. For now you should run Windows mounts as a normal user. |
OK. It will run in session 0 as normal windows services I guess, so hidden, but does the rclone process run elevated with this setup?
Thanks for the details!
I'm not sure, but I think this is a somewhat different case. My case was that I could never find the mounts at all. Rclone would always run elevated, don't know if that is part of the reason.
Either that, or #3340, are not these two different ways to solving the same thing? And with #3340 it is actually possible without changes in rclone - but it takes quite some advanced registry "hacking"? And isn't that primarily to be administrated as part of the WinFsp.Launcher, with its network provider allowing you to use "net use" instead of "rclone mount" commands? From my experience, even when installing as stand-alone service with |
No, it's not elevated.
If I change account to SYSTEM or run rclone as elevated user, I hit the same issue.
I see it this way (I may be wrong):
|
|
I just did a test with NSSM: It starts rclone elevated. And surprisingly (to me) WinFsp still detects it as running as a service, and uses the WinFsp.Launcher as I've described. After some reading it seems WinFsp is looking for process token WinServiceSid to detect if running as service, and rclone process has this token even when not being started directly as service but started as subprocess of nssm.exe. Starting from task scheduler it does not get this token (but instead WinBatchSid), and neither from command prompt (but instead WinInteractiveSid). This means it uses WinFsp.Launcher, even when started from NSSM, which means the mounting (DefineDosDevice api call) is performed as SYSTEM user. So I can see the mounted drive as my user. Starting identical rclone mount command from task scheduler with "Run whether user is logged on or not", it also is started elevated and process seems identical to when started as service - but it will not use WinFsp.Launcher, and therefore perform the mount as the configured task user - elevated - and I can not see the mounted drive. I think that is the explanation of the difference, which I found extremely strange and annoying when comparing the two methods.
Are you sure? If you stop the WinFsp.Launcher prosess, does your rclone mount from nssm still work?
When you tested rclone as elevated user, was that interactive then? I can't see anything to control this from nssm.. |
It works with WinFsp.Launcher service running or stopped. Windows 8.1 Pro x64
SYSTEM user - on the nssm EDIT added more details |
Strange, it is definitely opposite in my setup! Are you also on WinFsp version 2020.2?
In my case too, or actually it contains subkeys for built-in memfs, but nothing rclone related. But if I am correct, then an entry here is (only) needed when you want the service to be controlled by WinFsp, and then also get the "net use" integration etc. But the pipe api from WinFsp library (rclone) to the WinFsp.Launcher service to request it to perform the mounting (DefineDosDevice) is independent of the WinFsp registry configuration. It only checks that: 1) Process has the service token on it. 2) Is not running as SYSTEM user. And in my case both are true. The rclone.exe gets the service token, also when started by nssm. |
Only 2020.1, upgraded last year.
Probably it was created by WinFSP installer. I never edited it, only customized nssm services. |
I didn't dig this deep. |
No changes between 2020.1 and 2020.2 relevant for this case, as far as I can see. I'm considering installing 2020.1 to verify, though..
Yes, I have Win 10 (1909). If WinFsp version is not the cause, then this should mean that in Win8.1 rclone does not get the service token, as shown by the following screenshot mix from SysInternals Process Explorer: Edit: And perhaps also the difference of elevated service process or not is due to Windows versions. |
|
@albertony |
Great! I was hoping to write a guide that describes exactly how to get it to work, but if there is so much differences between versions etc it is going to be hard - must either write much shorter/vaguer, or separate guides for different versions etc... More work than I was planning to invest.. These process/security internals are hard to grasp, so I am by no means an expert myself. Process Explorer is a great tool to get some insight into Windows! I don't know if you meant you had checked it or not: But if you are willing to check: Find nssm, and the rclone beneath it. On both of them: Double click to show properties. Go to Security tab. Find an entry for group name starting with "Mandatory Label" and flag "Integrity". The last part of the name should be Low, Medium or High, where High is an indication of it running with full administrative privileges ("elevated"). Then see if there is an entry for group "NT AUTHORITY\SERVICE" and flag "Mandatory". This is the "token" given to processes running as services. Applications you start yourself will get the interactive token (NT AUTHORITY\INTERACTIVE), and task scheduler uses batch token (NT AUTHORITY\BATCH). I am wondering if rclone is elevated or not, and if it has the service token or not. It would also be interesting to know the same for the nssm process. From what I understand WinFsp checks the presence of "NT AUTHORITY\SERVICE" in the process, in our case rclone, and when this token is present it assumes it is running as service, and does not separate between it being running as a stand-alone service (like when I just installed it with New-Service command in PowerShell) or as part of the WinFsp.Launcher system. |
|
Thank you for that info, I really appreciate it! Glad you included the english translations at the end! ;) So, I conclude that your nssm and rclone processes both:
That matches what I see in my test! But in my test it works only when WinFsp.Launcher service is running (because of this this). When I stop WinFsp.Launcher the mount no longer works: The nssm-based service I created for rclone mount is running, but mount drive does not appear, rclone log file contains "Mount failed", and I see in process explorer that rclone.exe is being restarted by nssm. I have WinFsp 2020.2. I think I tried to see through the changes between .1 and .2 without finding anything that stood out as relevant. I may have to uninstall and install 2020.1 to try it out, I can't think of anything else that could explain the difference.. |
Just did. No difference between WinFsp 2020.1 and 2020.2. |
|
Is this OK to merge now? Merge window for 1.55 approaching fast ;-) |
No! 😞 I'm not sure it is correct as is, and the observed differences in behavior without finding a good reason makes me rethink this entire doc, e.g. if it must be rewritten with much less detail, I'm not sure... |
20d52f1 to
e38a9f0
Compare
Changed my mind! But: I decided to change direction a bit, and deleted the detailed step-by-step guide for scheduled task, and some other details, and most importantly any sections affected by the uncertainty around user account, elevation, service token discussed above! My thinking is that I will not be able to complete the detail level as it was, and to clear out all uncertainties, within reasonable amount of time! And then there would be a lot of, hopefully, useful documentation that would also just rot in that big draft... So, if we can make this PR into something that we want to merge on short term, then a new PR can be created to with intention of getting the uncertainties cleared out and fill in more details as needed... @ncw, @ivandeex : What do you think? I have pushed a version now that should be ready for review. I will read through it a couple of times more myself, so might push some small updates still. Also, it is currently spread over several commits (to be able to easily see the removed sections etc) that I will squash later. Edit: Oh, and I added one commit which has not to do with autorun, but is an update to the mount doc related to user accounts. The topic is quite related to the autorun part, though, and links to it, so I just included it here instead of as a new PR. |
5e53f64 to
e187c1e
Compare
Yes that sounds like a good plan. I'd rather have something now and fill in gaps later. Will take a look now |
ncw
left a comment
There was a problem hiding this comment.
I think those docs look very useful.
The Linux ones need filling out but I'm happy to merge this now.
Can you squash the commits before merging?
|
Great!
Done! |
|
Merge when ready :-) |
|
@albertony |
|
Ah, ok, sorry about that - and thanks for the tip. Actually, I kind of knew about it... except I thought the commit messages should rather be "clean", for changelogs etc, so I have even removed the PR number when doing squash merges 🤦 If I click on the commit, there is a link to the PR in small font just below the commit message, but that is not enough I take it? |






What is the purpose of this change?
Documenting how to set up autostart of rclone, e.g. for mount or serve commands.
Mostly focus on Windows.
TODO:
Sources:
Was the change discussed in an issue or in the forum before?
Related to this PR: #4953
Checklist
I have added tests for all changes in this PR if appropriate.