On ti, 30 marras 2021, Matthew Miller wrote:
On Tue, Nov 30, 2021 at 07:13:45AM +0100, Martin Pitt wrote:
> Stephen Gallagher [2021-11-29 14:34 -0500]:
> > Alexander: Does samba have a drop-file configuration anywhere? So we
> > could specify `include = registry` when this Cockpit plugin is
> > installed, but not otherwise?
>
> IMHO this is generally not a good idea. Merely installing a (mostly
> unrelated) package should not unexpectedly reconfigure existing running
> services. The docs [1] don't really clarify the impact, but at least the
> "automatically activates registry shares" sounds like possibly unexpected
> fallout, and may violate the "least surprise" principle?
I think the alternative would be for the Cockpit plugin to, instead of
telling users to edit the config file by hand, have a button to _just do
it_. I don't like munging config files, though (so fragile!), so:
It looks from
https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html#INCLUDE
that although it doesn't have a drop-in file option, the include option
_normally_ means "literally include a file here as though typed in place",
and for some probably-too-clever-but-oh-well reason, "include = registry"
has a special meaning.
I can think of several things we could do with this, but if we don't want
surprising behavior, we could have [global] include
include = /etc/samba/cockpit.conf
in the standard package. I don't know how samba behaves if files are
missing, but if it doesn't cause errors, that file could just be not there
by default. Or, if it needs to have something, could just contain a
commment. Then, the Cockpit tool could then replace just that file
(either directly or with a symlink) when you press a button. (Samba server
doesn't start by default, so that button could also enable the service?)
I don't like this approach, it mixes too much of Cockpit-specific
assumptions here into the configuration that should be as neutral as
possible.
This whole plugin would only work for a simple file server with
password-based authentication. It will not work when Samba AD is
configured on the system (Samba AD does not support 'include =
registry'), it will not work without changes with Samba file server as a
member of FreeIPA or Active Directory domain.
Adding non-existing include file does create a lot of noise -- every
time Samba tools would parse configuration file. This would happen every
three minutes if any of Samba daemons configured to run -- for example,
if winbindd is configured to join an Active Directory domain, where
otherwise one would not even use smbd, just winbindd.
If you want to control smb.conf from this Cockpit plugin, then doing a
backup of existing smb.conf and clearly identifying what will be changed
in the configuration is needed. E.g. 'After pressing the button below,
your smb.conf will be backed up and registry configuration will be
enabled' -- after checking that existing smb.conf is compatible with
your mode of operation (e.g. that it does not have any of incompatible
server roles).
This all smells like a dedicated project in itself. We have been working
on a Cockpit plugin for Samba AD configuration upstream as a part of a
Google Summer of Code few years ago but didn't get that code to
production quality yet. There are not enough resources to dedicate to
this work either upstream or downstream (both Fedora and RHEL).
--
/ Alexander Bokovoy