Skip to content

Commit 62b0ee9

Browse files
blucapoettering
authored andcommitted
portabled: update host's os-release path
1 parent 98aac2a commit 62b0ee9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/portable/portable.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,17 +695,28 @@ static int install_chroot_dropin(
695695
if (!text)
696696
return -ENOMEM;
697697

698-
if (endswith(m->name, ".service"))
698+
if (endswith(m->name, ".service")) {
699+
const char *os_release_source;
700+
701+
if (access("/etc/os-release", F_OK) < 0) {
702+
if (errno != ENOENT)
703+
return log_debug_errno(errno, "Failed to check if /etc/os-release exists: %m");
704+
705+
os_release_source = "/usr/lib/os-release";
706+
} else
707+
os_release_source = "/etc/os-release";
708+
699709
if (!strextend(&text,
700710
"\n"
701711
"[Service]\n",
702712
IN_SET(type, IMAGE_DIRECTORY, IMAGE_SUBVOLUME) ? "RootDirectory=" : "RootImage=", image_path, "\n"
703713
"Environment=PORTABLE=", basename(image_path), "\n"
704-
"BindReadOnlyPaths=-/etc/os-release:/run/host/etc/os-release /usr/lib/os-release:/run/host/usr/lib/os-release\n"
714+
"BindReadOnlyPaths=", os_release_source, ":/run/host/os-release\n"
705715
"LogExtraFields=PORTABLE=", basename(image_path), "\n",
706716
NULL))
707717

708718
return -ENOMEM;
719+
}
709720

710721
r = write_string_file(dropin, text, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
711722
if (r < 0)

0 commit comments

Comments
 (0)