diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-03-07 18:54:50 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-03-29 16:17:56 +0200 |
commit | df78419d107662dd49892d76a745c294d7031d66 (patch) | |
tree | a4734e9dd7134b729e21dcde743fe8c7e5893bc7 /src | |
parent | man: clarify the descriptions of aliases and linked unit files (diff) | |
download | systemd-df78419d107662dd49892d76a745c294d7031d66.tar.xz systemd-df78419d107662dd49892d76a745c294d7031d66.zip |
basic: add new variable $SYSTEMD_OS_RELEASE to override location of os-release
The test for the variable is added in test-systemctl-enable because there we
can do it almost for free, and the variable is most likely to be used with
'systemctl enable --root' anyway.
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/os-util.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/basic/os-util.c b/src/basic/os-util.c index bf86f64348..acfff24319 100644 --- a/src/basic/os-util.c +++ b/src/basic/os-util.c @@ -170,13 +170,19 @@ int open_extension_release(const char *root, const char *extension, char **ret_p } } } else { - FOREACH_STRING(p, "/etc/os-release", "/usr/lib/os-release") { - r = chase_symlinks(p, root, CHASE_PREFIX_ROOT, + const char *var = secure_getenv("SYSTEMD_OS_RELEASE"); + if (var) + r = chase_symlinks(var, root, 0, ret_path ? &q : NULL, ret_fd ? &fd : NULL); - if (r != -ENOENT) - break; - } + else + FOREACH_STRING(path, "/etc/os-release", "/usr/lib/os-release") { + r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, + ret_path ? &q : NULL, + ret_fd ? &fd : NULL); + if (r != -ENOENT) + break; + } } if (r < 0) return r; |