1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-22 22:03:43 +03:00

portable: reject root directories without an ID field in os-release

We always require at least ID to be set in os-release, reject
and propagate error to the caller instead of asserting later
This commit is contained in:
Luca Boccassi 2022-05-20 12:24:45 +01:00
parent a2cf73f0b6
commit 7b2e763242
2 changed files with 12 additions and 0 deletions

View File

@ -582,6 +582,8 @@ static int extract_image_and_extensions(
"PORTABLE_PREFIXES", &prefixes);
if (r < 0)
return r;
if (isempty(id))
return sd_bus_error_set_errnof(error, SYNTHETIC_ERRNO(ESTALE), "Image %s os-release metadata lacks the ID field", name_or_path);
if (prefixes) {
valid_prefixes = strv_split(prefixes, WHITESPACE);

View File

@ -152,6 +152,16 @@ umount /tmp/rootdir
umount /tmp/app0
umount /tmp/app1
# Lack of ID field in os-release should be rejected, but it caused a crash in the past instead
mkdir -p /tmp/emptyroot/usr/lib
mkdir -p /tmp/emptyext/usr/lib/extension-release.d
touch /tmp/emptyroot/usr/lib/os-release
touch /tmp/emptyext/usr/lib/extension-release.d/extension-release.emptyext
# Remote peer disconnected -> portabled crashed
res="$(! portablectl attach --extension /tmp/emptyext /tmp/emptyroot 2> >(grep "Remote peer disconnected"))"
test -z "${res}"
echo OK >/testok
exit 0