How can one activate a mount of a remote SMB share when the remote machine connects?
This is more about discerning a local event triggered by the connection of a particular remote machine, than it is about the action taken on that event. What can be determined is the port and protocol, of course, probably the source IP, and perhaps its MAC.
To illustrate, imagine two Windows laptops named Blue and Green, each with a share named Data, that occasionally connect to a Linux Samba server named Martini. The objective is for Martini to mount \Blue\Data to /srv/blue (or wherever)(and do other things) when Blue connects, and mount \Green\Data to /srv/green (or wherever)(and do other things) when Green connects.
Perhaps I'm too deep in the weeds but this seems harder than it looks.
It's straightforward to mount a remote share when localhost connects to it, e.g., when Martini boots, does its thing, finds Blue and Green running, and mounts their shares.
I even have figured out how to activate a host mount of a share on a virtual machine when it fires up (create a systemd.path unit that monitors the VM's log file, then x-systemd.requires=foo.path in fstab).
For a fully remote machine, however, I'm drawing a blank. There is a roundabout / Rube Goldberg way via the iptables LOG target and rsyslog (directly or via a systemd.path unit) but that has too many moving pieces and seems like a kludge. The hope is that something more direct exists.
Socket activation can mind a port but (and I easily could be wrong) isn't obviously capable of discerning the connecting machine. Udev activation seems focused only on localhost's hardware. I haven't figured out a client-wise /dev, /proc, or other path to inspect, although I easily could have missed something. Perhaps there is something in /etc/samba/smb.conf.
Pending further tail-chasing, I thought I'd post to see what ideas the community might have. Any input would be most appreciated.