Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
samba: don't restart smbd in samba-autoshare #1919
The samba-autoshare script that takes care of sharing mounted drives restarts smbd every time udevil mounts a disk. This can lead to a Samba restart frenzy on boot with several connected disks. This is unnecessary as Samba does not need to be restarted to pick up changes to shares in smb.conf.
This PR modifies samba-autoshare to simply regenerate the configuration (samba-config) and then extend the configuration according to LE settings (smbd-config).
While it's mostly true that if you simply update
However, that's not always the case, and sometimes a newly added share will refuse to be listed on the client - sometimes for several minutes - until
In addition, when a drive is unmounted although the share will be removed from
A "lingering" disconnected share could have catastrophic consequences - if a drive is unmounted without restarting
Simply updating the config without restarting
The only way to reliably add or remove a share is to restart
So while we will see a storm of service stop/starts at startup (hopefully lessened to some extent by recent changes), I think it's a necessary evil to avoid listing non-existent shares (which could be dangerous, leading to potential data loss), or not immediately listing new shares (which can be very frustrating for the user who wants to access their new share etc.).
According to the manual:
"The configuration file, and any files that it includes, are automatically reloaded every minute, if they change. You can force a reload by sending a SIGHUP to the server. Reloading the configuration file will not affect connections to any service that is already established. Either the user will have to disconnect from the service, or smbd killed and restarted."
So to speed up the configuration refresh one could use SIGHUP, but yes any already established connection will probably have the same configuration as when the client connected. Doing a complete restart doesn't seem like a good reason to me either way, for the above reason and also that any ongoing file operations to a share will be interrupted.
I don't see how you can avoid these "lingering" shares that you mention, as normally samba-autoshare is triggered by udev add/remove -> udevil-mount service. A user could manually unmount a drive and the share would still linger with or without this PR.
This is with one external drive (/dev/sda1, "Images") - installed at the time of booting - where the partition is mounted while
Reboot often enough and you should hit this condition.
The following works:
which results in:
Alternatively, maybe there's some additional systemd magic to ensure that
However as the pid file check seems to work, I'd go with that...