]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/shared/install.h
tree-wide: make specifier expansion --root= aware
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Jun 2021 16:06:02 +0000 (18:06 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 24 Jun 2021 20:30:14 +0000 (22:30 +0200)
commitde61a04b188f81a85cdb5c64ddb4987dcd9d30d3
treeb83ed81038b2f51d09f4d410a63fe2e259f83f11
parent0c651d32d49e66ea0152eea5e65dd19fe01e7a06
tree-wide: make specifier expansion --root= aware

This fixes repart's, systemctl's, sysusers' and tmpfiles' specifier
expansion to honour the root dir specified with --root=. This is
relevant for specifiers such as %m, %o, … which are directly sourced
from files on disk.

This doesn't try to be overly smart: specifiers referring to runtime
concepts (i.e. boot ID, architecture, hostname) rather than files on the
medium are left as is. There's certainly a point to be made that they
should fail in case --root= is specified, but I am not entirely convinced
about that, and it's certainly something we can look into later if
there's reason to.

I wondered for a while how to hook this up best, but given that quite a
large number of specifiers resolve to data from files on disks, and most
of our tools needs this, I ultimately decided to make the root dir a
first class parameter to specifier_printf().

Replaces: #16187
Fixes: #16183
16 files changed:
src/core/load-fragment.c
src/core/unit-printf.c
src/partition/repart.c
src/resolve/resolved-conf.c
src/resolve/resolved-dnssd.c
src/shared/install-printf.c
src/shared/install-printf.h
src/shared/install.c
src/shared/install.h
src/shared/specifier.c
src/shared/specifier.h
src/sysusers/sysusers.c
src/test/test-load-fragment.c
src/test/test-specifier.c
src/test/test-unit-name.c
src/tmpfiles/tmpfiles.c