diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-06-24 18:06:02 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-24 22:30:14 +0200 |
commit | de61a04b188f81a85cdb5c64ddb4987dcd9d30d3 (patch) | |
tree | b83ed81038b2f51d09f4d410a63fe2e259f83f11 /src/test/test-load-fragment.c | |
parent | 0c651d32d49e66ea0152eea5e65dd19fe01e7a06 (diff) | |
download | systemd-de61a04b188f81a85cdb5c64ddb4987dcd9d30d3.tar.gz |
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
Diffstat (limited to 'src/test/test-load-fragment.c')
-rw-r--r-- | src/test/test-load-fragment.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c index 50345b7b1e..b41a8abf7b 100644 --- a/src/test/test-load-fragment.c +++ b/src/test/test-load-fragment.c @@ -498,8 +498,8 @@ static void test_install_printf(void) { _cleanup_free_ char *mid = NULL, *bid = NULL, *host = NULL, *gid = NULL, *group = NULL, *uid = NULL, *user = NULL; - assert_se(specifier_machine_id('m', NULL, NULL, &mid) >= 0 && mid); - assert_se(specifier_boot_id('b', NULL, NULL, &bid) >= 0 && bid); + assert_se(specifier_machine_id('m', NULL, NULL, NULL, &mid) >= 0 && mid); + assert_se(specifier_boot_id('b', NULL, NULL, NULL, &bid) >= 0 && bid); assert_se(host = gethostname_malloc()); assert_se(group = gid_to_name(getgid())); assert_se(asprintf(&gid, UID_FMT, getgid()) >= 0); @@ -512,7 +512,7 @@ static void test_install_printf(void) { _cleanup_free_ char \ *d1 = strdup(i.name), \ *d2 = strdup(i.path); \ - assert_se(install_name_printf(&src, pattern, &t) >= 0 || !result); \ + assert_se(install_name_printf(&src, pattern, NULL, &t) >= 0 || !result); \ memzero(i.name, strlen(i.name)); \ memzero(i.path, strlen(i.path)); \ assert_se(d1 && d2); \ |