]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/dbus-socket.c
core: add proper escaping to writing of drop-ins/transient unit files
authorLennart Poettering <lennart@poettering.net>
Wed, 22 Nov 2017 14:03:51 +0000 (15:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 29 Nov 2017 11:34:12 +0000 (12:34 +0100)
commit2e59b241ca86b8338c706a7a704d301fde908581
tree4f83e31ad02c6c691ff712a8a4499533c63dd720
parentddd59d0c7ffc77158ab2d6f52f08812670bb9160
core: add proper escaping to writing of drop-ins/transient unit files

This majorly refactors the transient unit file and drop-in writing
logic, so that we properly C-escape and specifier-escape (% → %%)
everything we write out, so that when we read it back again, specifiers
are parsed that aren't supposed to be parsed.

This renames unit_write_drop_in() and friends by unit_write_setting().
The name change is supposed to clarify that the functions are not only
used to write drop-in files, but also transient unit files.

The previous "mode" parameter to this function is replaced by a more
generic "flags", which knows additional flags for implicit C-style and
specifier escaping before writing things out. This can cover most
properties where either form of escaping is defined. For the cases where
this isn't sufficient, we add helpers unit_escape_setting() and
unit_concat_strv() for escaping individual strings or strvs properly.

While we are at it, we also prettify generation of transient unit files:
we try to reduce the number of section headers written out: previously
we'd write the right section header our for each setting. With this
change we do so only if the setting lives in a different section than
the one before.

(This should also be considered preparation for when we add proper APIs
to systemd to write normal, persistant unit files through the bus API)
26 files changed:
src/core/dbus-automount.c
src/core/dbus-automount.h
src/core/dbus-cgroup.c
src/core/dbus-cgroup.h
src/core/dbus-execute.c
src/core/dbus-execute.h
src/core/dbus-kill.c
src/core/dbus-kill.h
src/core/dbus-mount.c
src/core/dbus-mount.h
src/core/dbus-scope.c
src/core/dbus-scope.h
src/core/dbus-service.c
src/core/dbus-service.h
src/core/dbus-slice.c
src/core/dbus-slice.h
src/core/dbus-socket.c
src/core/dbus-socket.h
src/core/dbus-swap.c
src/core/dbus-swap.h
src/core/dbus-timer.c
src/core/dbus-timer.h
src/core/dbus-unit.c
src/core/dbus-unit.h
src/core/unit.c
src/core/unit.h