[systemd-devel] Formal syntax of unit file format

Lennart Poettering lennart at poettering.net
Fri Apr 1 09:05:27 UTC 2016


On Sun, 27.03.16 19:04, Damiano Albani (damiano.albani at gmail.com) wrote:

> Hello,
> 
> I've searched quite extensively but I haven't been able to find a *formal*
> description of the unit file format (e.g. via ABNF).

We never put that together really. And I am not sure we should put
together an ABNF that lists all currently known settings, simply
because we keep adding settings, and when deprecating settings we
simply drop them from the documentation, but keep them in the code for
compat reasons. I'd rather not have to list those compat settings in
an ABNF definition.

I'd be fine with adding an ABNF definition somewhere to the docs, that
does not declare the valid list of settings though. Happy to take a
patch for that. But note that even that would probably not match the
actually implemented algorithm fully, since we have some language
constructs (such as ".include") that we still support in the parser but
consider obsolete, and don't document anymore.

> There does exist a manual page
> <https://www.freedesktop.org/software/systemd/man/systemd.unit.html> but
> the syntax herein is broadly expressed in written form, i.e. not as a
> formal grammar.

> Wouldn't that be useful, in order to build a unit file validator / parser
> for example?

As mentioned, there's "systemd-analyze verify" which not only checks
the general formatting but also tries to parse the various settings.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list