spantaleev / sftpman

Application that handles sshfs/sftp file systems mounting.
GNU General Public License v3.0
32 stars 7 forks source link

Ability to change mount_path_base by configuration #4

Open renekliment opened 8 years ago

renekliment commented 8 years ago

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.

semyon-san commented 6 years ago

Why is it not inherently possible to mount under different directory?

spantaleev commented 6 years ago

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.

MorganRodgers commented 4 years ago

+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.

D-Vaillant commented 3 years ago

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}.

spantaleev commented 3 years ago

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.