[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tramp never unmounts sshfs volumes

From: Michael Albinus
Subject: Re: Tramp never unmounts sshfs volumes
Date: Sun, 03 Oct 2021 10:47:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stephen Gildea <> writes:

Hi Stephen,

>>   > 3. Unmount if this process did the mount.  This is your idea of an
>>   > "unmount on cleanup" bit.  As with case 2, if this process did not do
>>   > the mount, Tramp would have to handle an unexpectedly closed connection.
>>   >
>>   > 4. Every Emacs uses its own mount point.  Multiple mount points could
>>   > still share an ssh connection but would no longer share the sshfs cache.
>>   > This option seems the simplest and cleanest to implement.
>>   I'm just working on 3, controlled by a user option. Let's see how it
>>   goes (with your testing), if not satisfying we'll have 4.
>>   Variant 4 has the disadvantage to leave several mount points when Emacs
>>   crashes or does not pass the cleanup machinery for whatever reason.
> I tested the patch you sent me that implements variant 3.

Thanks for your tests!

> tramp-cleanup-this-connection fails to unmount.  The problem is that
> vec is not a member of tramp-fuse-mount-points:
>     vec:
>     (tramp-file-name sshfs nil nil otherhost nil /home/gildea/ nil)
>     tramp-fuse-mount-points:
>     ((tramp-file-name sshfs nil nil otherhost nil /home/gildea/afile nil))


> tramp-cleanup-all-connections and exiting Emacs both do unmount, as expected.
> However, they leave behind the mount point directory, 
> /tmp/tramp.sshfs.otherhost/


> Two Emacs processes accessing the same remote host can confuse each other:
>    . open an sshfs file in Emacs 1
>    . open an sshfs file in Emacs 2 on the same remote host
>    . cleanup-all in Emacs 1
>    . try to access file again in Emacs 2 - fails: No such file or directory

Yes, you can always shoot yourself in the foot. It might be possible to
check this case, but is it really worth the effort?

> Also while testing I came across two behaviors that could be better.
> These are not regressions, as un-patched Tramp behaves the same.
> If I open a non-existent file, e.g.,
> /sshfs:otherhost:/tmp/newfile
> The following gets logged to *Messages*
> File is missing: Opening input file No such file or directory 
> /tmp/tramp.sshfs.otherhost/tmp/newfile
> and the buffer is shown as editing the local file
> /tmp/tramp.sshfs.otherhost/tmp/newfile

This happens for other methods as well, like /ssh:otherhost:/tmp/newfile.
It is a bug, I will work on this,

> Tramp will not share the ssh connection with an existing connection to
> the remote host, because it uses its own ControlPath.  This makes it
> harder to use Tramp with a remote host that requires user action to
> authenticate, as many two-factor methods do.  I would prefer that
> Tramp not set its own options and let the options in my .ssh/config
> control the connection.

See the Tramp manual, (info "(tramp) Frequently Asked Questions")

--8<---------------cut here---------------start------------->8---
   • TRAMP does not use default ‘ssh’ ‘ControlPath’

     TRAMP overwrites ‘ControlPath’ settings when initiating ‘ssh’
     sessions.  TRAMP does this to fend off a stall if a master session
     opened outside the Emacs session is no longer open.  That is why
     TRAMP prompts for the password again even if there is an ‘ssh’
     already open.

     Some ‘ssh’ versions support a ‘ControlPersist’ option, which allows
     you to set the ‘ControlPath’ provided the variable
     ‘tramp-ssh-controlmaster-options’ is customized as follows:

             "-o ControlPath=/tmp/ssh-ControlPath-%%r@%%h:%%p "
             "-o ControlMaster=auto -o ControlPersist=yes"))

     Note how ‘%r’, ‘%h’ and ‘%p’ must be encoded as ‘%%r’, ‘%%h’ and

     If the ‘~/.ssh/config’ file is configured appropriately for the
     above behavior, then any changes to ‘ssh’ can be suppressed with
     this ‘nil’ setting:

          (customize-set-variable 'tramp-use-ssh-controlmaster-options nil)

     This should also be set to ‘nil’ if you use the ‘ProxyCommand’ or
     ‘ProxyJump’ options in your ‘ssh’ configuration.

     On MS Windows, ‘tramp-use-ssh-controlmaster-options’ is set to
     ‘nil’ by default, because the MS Windows and MSYS2 implementations
     of ‘OpenSSH’ do not support this option properly.
--8<---------------cut here---------------end--------------->8---

The revised patch is appended.

Best regards, Michael.

Attachment: txtJJNpBESB3T.txt
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]