Re: SSH Controlmaster holding devices

2024-02-05 Thread Andy Bradford
Thus said Courtney on Mon, 05 Feb 2024 12:55:20 -0800:

> I wasn't aware that it would still be impacted when leaving the cwd.

Your shell "left the  cwd" but the SSH process did  not. In other words,
don't start processes from  a mount point that you expect  to be able to
unmount later (or kill them first).

Andy



Re: SSH Controlmaster holding devices

2024-02-05 Thread Courtney
I wasn't aware that it would still be impacted when leaving the cwd. I 
understand
that it would behave this way when my shell is open when cwd is in that 
device.


Thank you for the clarification.

Courtney

On 2/5/24 12:36, Theo de Raadt wrote:

This has nothing to do with ssh.

Unix works this way.  You have not thought through that the cwd means.
It is a fd, on a vnode, as an inode on a filesystem.  Of course it
will prevent an unmount.





Re: SSH Controlmaster holding devices

2024-02-05 Thread Theo de Raadt
This has nothing to do with ssh.

Unix works this way.  You have not thought through that the cwd means.
It is a fd, on a vnode, as an inode on a filesystem.  Of course it
will prevent an unmount.



SSH Controlmaster holding devices

2024-02-05 Thread Courtney
Maybe this is a feature, but I found it strange that an ssh 
controlmaster process
will attach itself to a device whose directory you are in when you 
create that connection.


For example in my config

Host *
    IdentitiesOnly  yes
    ObscureKeystrokeTiming  yes
    ControlPath ~/.ssh/controlmasters/%r@%h%p
    ControlMaster   auto
    ControlPersist  60m

If I have a device mounted at /mnt/usb and I am cd'd into that directory and
ssh into a server, the control master will create a file at 
~/.ssh/controlmasters.
However, with the file created while cd'd into /mnt/usb, it makes the 
device mounted
at /mnt/usb busy and unmountable until that process exits, even though 
that process
has no relation to that device aside from having that dir be my pwd when 
using ssh.


Steps:

$ mnt /dev/sd3i /mnt/usb
$ cd /mnt/usb
$ ssh example.com
$ cd /
$ umount /mnt/usb
umount: /mnt/usb: Device busy
$ fstat -f /mnt/usb
USER CMD  PID   FD MOUNT    INUM  MODE R/W    SZ|DV
courtney ssh    40229   wd /mnt/usb    2  drwxr-xr-x r 4096
$ ps -ux | grep 40229
courtney 40229  0.0  0.0  2312  2664 ??  Ip 12:14PM    0:00.00 ssh: 
/home/courtney/.ssh/controlmasters/courtney@example.com22 [mux] (ssh)

$ ssh -O exit example.com
Exit request sent.
$ umount -v /mnt/usb
/dev/sd3i: unmount from /mnt/usb

I don't see the point of this happening. Is this expected/desirable 
behavior?


Courtney