sftpman
sftpman copied to clipboard
Ability to change mount_path_base by configuration
It would be great if the mount path (currently fixed /mnt/sshfs) were configurable by the user.
Edit: Ah, just noticed it's under Known limitations. Well, let's keep this issue for better reference and discussion then.
Why is it not inherently possible to mount under different directory?
For simplicity, it only uses one directory, which it "believes to control exclusively".
sftpman
believes that /mnt/sshfs/
is its own and nothing else mounts under that directory.
This way, it knows that anything it finds there is an sftpman-managed system.
Figuring out which systems are mounted now is as simple as this code in EnvironmentModel
(sftpman/model.py
):
def get_mounted_ids(self):
# Looking for /mnt/sshfs/{id} in output that looks like this:
# user@host:/remote/path on /mnt/sshfs/id type fuse.sshfs ...
# "mount -l -t fuse.sshfs" cannot be used, as it requires root privileges
mounted = shell_exec('mount -l')
regex = re.compile(' %s(.+?) type fuse\.sshfs' % self.mount_path_base)
return regex.findall(mounted)
Thinking about it, the above code is a little fragile (as it depends on the above assumption of exclusive control over /mnt/sshfs/
).
If we want to have custom mount directories, the above code needs to be more complicated.
The UI in sftpman-gtk also needs to be more complicated to account for custom mount paths.
Having custom mount paths also introduces additional failure scenarios (permissions problems for some paths, but not for others, etc.)
Surely, it's possible to do, I just haven't felt the need to implement it and no one has contributed it. If there's enough interest, however, we can do it.
+1 for this. Apple has decided that the root file system shall be read only, so sftpman
does not work on the newest versions of macOS.
Took a stab at writing the beginnings of this feature. As far as I can tell sftpman doesn't have an application-level settings file, so I added one in json
for consistency.
https://github.com/D-Vaillant/sftpman/blob/chdir_mountpassbase/sftpman/model.py#L20
Another way of implementing this would be having the mount directory be defined absolutely by systems, defaulting to /mnt/sshfs/{system_name}
.
This seems like a good beginning.
I'd rather we enable it for all platforms and not make it depend on a flag (like CONFIG_SUPPORT
) that distributors would flip or not.