Open rseichter opened 5 years ago
Thanks Ralph, I was going to put together this list sometime later today but you were too fast.
There's a lot we need to clean up before we adding these... I'll try to list them in a sensible order.
1. Variable replacement
The magic variables like @sbindir@
are replaced at build-time by ./configure
, but not unless you tell it to. The usual way is to rename the "source" file with an .in
suffix, like opendkim.initd.in
, and then that file needs to be added to the bottom of configure.ac
so that autoconf knows to process it (it will replace the variables, and save the output without the .in
suffix).
2. Use of runstatedir
Then, we should depend on a newer version of autoconf. At the top of configure.ac, there's a line like
AC_PREREQ(2.61)
which says what version needs to used, at a minimum. (This is only for developers). In autoconf-2.70, a new variable "runstatedir" was added:
https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
and that's what we want to use instead of /run
everywhere, so I think we should depend on autoconf-2.70.
3. Add a tmpfiles.d entry
The @runstatedir@/opendkim
directory needs special permissions, and a tmpfiles.d entry can do that for both OpenRC and systemd:
d @runstatedir@/opendkim 0755 opendkim opendkim
4. Using the new runstatedir to store the pid file and socket.
In the init script (and in upstream's system service file -- but we can worry about that later!), there are some things we can improve now that @runstatedir@
is available. The spirit of these is the same as the suggestions in my comment 5 on https://bugs.gentoo.org/606978, but instead of just declaring /run/opendkim
to be the socket path by fiat, here we're constructing it from @runstatedir@
at build time.
pidfile="@runstatedir@/${RC_SVCNAME}.pid"
(Note: RC_SVCNAME
is still fine, no need for $prog
)
And we can get rid of all of the socket handling stuff:
command_args="-P ${pidfile} -x ${CONFFILE}"
...
start_pre() {
# If this isn't a restart, make sure that the user's config isn't
# busted before we try to start the daemon (this will produce
# better error messages than if we just try to start it blindly).
#
# If, on the other hand, this *is* a restart, then the stop_pre
# action will have ensured that the config is usable and we don't
# need to do that again.
if [ "${RC_CMD}" != "restart" ]; then
checkconfig || return $?
fi
}
We can get rid of the conf.d file now too; it's not needed if OpenRC/systemd agree to use @runstatedir@/opendkim
for local sockets, and if the configuration file is the one source of truth for the socket path.
The stale socket handling has also been removed above, since we don't know the socket path. This is fine: the init system shouldn't be doing that anyway, and systemd doesn't do it. Stale sockets only get created in exceptional circumstances anyway, and when it happens, maybe you don't want your init system just deleting shit to hide the problem.
5. Configuration file updates
Now that "runstatedir" is gospel, we should put an example local socket entry in the config file, telling people that their local sockets should go in @runstatedir@/opendkim
. The example configs are already processed by autoconf, so in e.g. opendkim.conf.simple.in
we could add
# To use a local socket instead, specify a filename under @runstatedir@/opendkim.
# Socket local:@runstatedir@/opendkim/opendkim.sock
6. Install process
Rather than document the files that need to be copied and where in a README
, we should have e.g. make install-openrc
do it.
7. Conclusion / summary of goals
Ultimately, both systemd and OpenRC will have @runstatedir@/opendkim
created automatically, with the right permissions, by the tmpfiles.d entry. The socket would be set in the config file (where the correct path based on @runstatedir@
is shown), and then regardless of whether it was inet/local and regardless of the init system, things would just work.
Basically, we should be able to make && make install && make install-openrc
on Gentoo after setting the correct --runstatedir=/run
at build time, and have the resulting init script work out of the box, and have the systemd service also work out of the box with no changes.
It does seem like a lot of work, but supporting systemd forces us to do a few things simpler, and even though I'm a systemd hater, I think the simplicity is a good thing. With systemd's tmpfiles entry in place, we can just re-use it in OpenRC, greatly simplifying things there, too. Then it's just a matter of undoing some old cruft to bring the two to parity. And then upstreaming everything to get the cool @vars@
.
@orlitzky Please see my email.
@mskucherawy
I believe this is ready for serious consideration now. Most of the points I brought up in my earlier comment have been addressed:
runstatedir
support to the build system in anticipation of the next version of autotools.@variable@
substitution. Using e.g. AC_SUBST
in configure.ac
doesn't always substitute the full path, and a better way is suggested by the autotools documentation (in the "Installation Directory Variables" section). We haven't gone through and updated all of the other files that were using autoconf-based substitutions, but they are easily fixable now that the right framework is in place.A few things we didn't fix:
opendkim
user was hard-coded for the systemd stuff before, and I've left that alone. We hard-code it for OpenRC now, too. Some time in the future it can be made configurable. The new variable substitution framework should make it easy.--enable-openrc
or --enable-systemd
to the configure script before we started installing those scripts. OpenRC in particular installs to /etc/init.d
which might belong to some other piece of software. In any case, they're still installed -- just as documentation for now. As a packager this isn't a big deal, we just move it to the right place afterwards.Our Gentoo users are running the patch corresponding to this PR, and so far no one has complained. Ralph and I have also done a lot of testing. Carrying the patch isn't a big deal, but it makes it hard to pile on future improvements, so I hope we can get some feedback soon. Thanks for your time!
@mskucherawy This pull request has now been open for more than a year. Some form of reaction would be appreciated.
LGTM; are we going to add the RELEASE_NOTES text in here or in a later pull request?
@mskucherawy I'm not certain if this is a question you are asking your co-reviewers, or @orlitzky and myself? Michael has provided extensive information in a comment above, and I doubt there is much room for improvement left. Could you use Michael's comment as a basis for the release notes?
Most of these changes are invisible to end users. How in-depth would you like the release notes to be? Something like,
@variable@
substitution in the systemd service file.make runstatedir=/run
for now. The default is backwards-compatible.In other news, autoconf-2.70 is (finally) almost ready. After it's widely available, we can require it in configure.ac
to improve the @runstatedir@
user experience.
Having recently inherited the maintainership for Gentoo Linux's OpenDKIM package, I suggest adding our OpenRC service scripts.