Ulrich Sibiller
2025-Jul-16 11:16 UTC
[Samba] Dynamic share configuration at connection time?
Ralph Boehme schrieb am 15.07.2025 13:47:> On 7/15/25 1:10 PM, Ulrich Sibiller via samba wrote: >> Unfortunately no-one has reacted so far. > > at least to me this just required too much mind bending for which I > didn't have the time on a volunteer basis.? That's why I had the TL;DR at the beginning. Basically I want to change some config parameter(s) of a share during connection startup, depending on information that is only available then (and not before). E.g. change the path parameter to point somewhere else. This path should only be used for that connection. For any additional connection the process has to be repeated. In other words: I should be possible for multiple connections to the same share having differing configs during runtime. Simple example where some subdirs reside on other locations: a) connection to \\server\share -> path is set to /mnt1/share in smb.conf b) connection to \\server\share\dir1 -> set path to /mnt2/share on the fly c) connection to \\server\share\dir2 -> set path to /mnt3/share on the fly So "share" is defined in smb.conf and has some config parameters. When connecting to \\server\share\dir1 the path config _for that connection only_ should be changed to /mnt2/share on the fly. (Please note that this is just simplified example. I am looking for a generic solution that allows for any share config parameter to be adjusted on the fly)>> I am thinking about writing an own VFS module for this but I am >> unsure if that is possible at all via a VFS module. Does anybody >> know? > Without really understanding what you're aiming at, but have you > considered "root preexec"? The script receives a bunch of useful > information:AFAIU root preexec is used to run a script when the connection is opened. Which would be the right time for my needs. But what next? What should it run to change the config for this single connection? Thx, Ulrich Sibiller -- Dipl.-Inf. Ulrich Sibiller science + computing ag System Administration Hagellocher Weg 73 Hotline +49 7071 9457 681 72070 Tuebingen, Germany https://atos.net/de/deutschland/sc
Robert Marcano
2025-Jul-16 16:05 UTC
[Samba] Dynamic share configuration at connection time?
On 7/16/25 7:16 AM, Ulrich Sibiller via samba wrote:> Ralph Boehme schrieb am 15.07.2025 13:47: >> On 7/15/25 1:10 PM, Ulrich Sibiller via samba wrote: >>> Unfortunately no-one has reacted so far. >> >> at least to me this just required too much mind bending for which I >> didn't have the time on a volunteer basis. > > ? That's why I had the TL;DR at the beginning. Basically I want to change some config parameter(s) of a share during connection startup, depending on information that is only available then (and not before). E.g. change the path parameter to point somewhere else. This path should only be used for that connection. For any additional connection the process has to be repeated. In other words: I should be possible for multiple connections to the same share having differing configs during runtime. > > Simple example where some subdirs reside on other locations: > a) connection to \\server\share -> path is set to /mnt1/share in smb.conf > b) connection to \\server\share\dir1 -> set path to /mnt2/share on the fly > c) connection to \\server\share\dir2 -> set path to /mnt3/share on the fly > > So "share" is defined in smb.conf and has some config parameters. When connecting to \\server\share\dir1 the path config _for that connection only_ should be changed to /mnt2/share on the fly. > > (Please note that this is just simplified example. I am looking for a generic solution that allows for any share config parameter to be adjusted on the fly) > >>> I am thinking about writing an own VFS module for this but I am >>> unsure if that is possible at all via a VFS module. Does anybody >>> know? >> Without really understanding what you're aiming at, but have you >> considered "root preexec"? The script receives a bunch of useful >> information: > > AFAIU root preexec is used to run a script when the connection is opened. Which would be the right time for my needs. But what next? What should it run to change the config for this single connection?You could try executing a preexec script that generates a file with a name based on the variable substitution %d (the process id of the current server process) And then include the file that is generated with %d somwehere in the name. If this works depends if Samba process first the prexec command before the includes.