summaryrefslogtreecommitdiff
path: root/src/portable/portable.c
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2020-07-23 14:44:10 +0100
committerLennart Poettering <lennart@poettering.net>2020-07-23 18:47:38 +0200
commit62b0ee9eb1b488e96359fa9b3f225c80e92cd082 (patch)
tree1dc299c6fd522ddc36e2fad74fd6f6a08d45e860 /src/portable/portable.c
parent98aac2ad5a1cbea6af3e474f45da77f696c99bdd (diff)
downloadsystemd-62b0ee9eb1b488e96359fa9b3f225c80e92cd082.tar.gz
portabled: update host's os-release path
Diffstat (limited to 'src/portable/portable.c')
-rw-r--r--src/portable/portable.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 48294d4c49..3a1367ec2b 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -695,17 +695,28 @@ static int install_chroot_dropin(
if (!text)
return -ENOMEM;
- if (endswith(m->name, ".service"))
+ if (endswith(m->name, ".service")) {
+ const char *os_release_source;
+
+ if (access("/etc/os-release", F_OK) < 0) {
+ if (errno != ENOENT)
+ return log_debug_errno(errno, "Failed to check if /etc/os-release exists: %m");
+
+ os_release_source = "/usr/lib/os-release";
+ } else
+ os_release_source = "/etc/os-release";
+
if (!strextend(&text,
"\n"
"[Service]\n",
IN_SET(type, IMAGE_DIRECTORY, IMAGE_SUBVOLUME) ? "RootDirectory=" : "RootImage=", image_path, "\n"
"Environment=PORTABLE=", basename(image_path), "\n"
- "BindReadOnlyPaths=-/etc/os-release:/run/host/etc/os-release /usr/lib/os-release:/run/host/usr/lib/os-release\n"
+ "BindReadOnlyPaths=", os_release_source, ":/run/host/os-release\n"
"LogExtraFields=PORTABLE=", basename(image_path), "\n",
NULL))
return -ENOMEM;
+ }
r = write_string_file(dropin, text, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
if (r < 0)