From 5cf69e709eb928662f03944ac4064157784b0d76 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 8 Apr 2023 22:33:40 +0900 Subject: [PATCH] os-util: make $SYSTEMD_OS_RELEASE prefixed with the root directory To make it consistent with other env vars, e.g. $SYSTEMD_ESP_PATH or $SYSTEMD_XBOOTLDR_PATH. This is useful when the root is specified by a file descriptor, instead of a path. --- docs/ENVIRONMENT.md | 3 +-- src/basic/os-util.c | 2 +- test/test-systemctl-enable.sh | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md index 292a0f1e0e1..445131b479b 100644 --- a/docs/ENVIRONMENT.md +++ b/docs/ENVIRONMENT.md @@ -45,8 +45,7 @@ All tools: * `$SYSTEMD_OS_RELEASE` — if set, use this path instead of `/etc/os-release` or `/usr/lib/os-release`. When operating under some root (e.g. `systemctl - --root=…`), the path is taken relative to the outside root. Only useful for - debugging. + --root=…`), the path is prefixed with the root. Only useful for debugging. * `$SYSTEMD_FSTAB` — if set, use this path instead of `/etc/fstab`. Only useful for debugging. diff --git a/src/basic/os-util.c b/src/basic/os-util.c index 16fe123ce64..0f123aaf829 100644 --- a/src/basic/os-util.c +++ b/src/basic/os-util.c @@ -128,7 +128,7 @@ int open_os_release(const char *root, char **ret_path, int *ret_fd) { e = secure_getenv("SYSTEMD_OS_RELEASE"); if (e) - return chase(e, root, 0, ret_path, ret_fd); + return chase(e, root, CHASE_PREFIX_ROOT, ret_path, ret_fd); FOREACH_STRING(path, "/etc/os-release", "/usr/lib/os-release") { r = chase(path, root, CHASE_PREFIX_ROOT, ret_path, ret_fd); diff --git a/test/test-systemctl-enable.sh b/test/test-systemctl-enable.sh index 7d5667f2975..e22a3ef628e 100644 --- a/test/test-systemctl-enable.sh +++ b/test/test-systemctl-enable.sh @@ -695,4 +695,4 @@ cat >"$root/etc/os-release2" <