[systemd-devel] Binary changed since start

Lennart Poettering lennart at poettering.net
Tue Dec 10 11:32:34 UTC 2019


On Di, 10.12.19 10:38, Ulrich Windl (Ulrich.Windl at rz.uni-regensburg.de) wrote:

> Hi!
>
> Two questions (In Linux it's possible to replace the image of the binary that is executed on disk):
>
> 1) It seems my version of systemd (228) does not detect that a
> binary has changed since the service was started. In case it's still
> true in the current version, is it difficult to indicate that fact
> in "systemctl status .."?

We don't, no. It has been requested before that we deal with that, but
it's not realistic to do this correctly. Thing is, binaries are
generally not statically compiled, they link against other libraries
which might also be updated, and which would have to be checked
too. And they do so via module loading (i.e. dlopen()) and explicitly,
we'd have to check both, which already is harder, since you cannot
just look at the ELF headers of binaries to determine deps
anymore. But they also keep other resources mapped, for example l10n
and i18n data, and a lot of other stuff. We'd have to check that
too. And then, there are the invisible dependencies too: some file
changed that some library a program opens and reads, but only
sometimes: how would you ever figure out you need to restart the
service? And then, there's also the fact that C is just one
programming language and others work very differently, and require
other schemes for updating, i.e. Python does something very very
different.

So in the end: implementing something like that could at best be a
heuristic, that works sometimes but not generally. I know that some
distros implemented a checker for this in their package manager. But I
am very sure this has no place in systemd, since it's black magic and
you never could rely on the correctness for that.

> 2) Given 1), would it make sense to allow an option like
> "RestartIfBinary Changed"?

Binding control flow to such a heuristic sounds even more dangerous to
me.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list