]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
portable: honor --force for directory extensions 43033/head
authordongshengyuan <545258830@qq.com>
Wed, 15 Jul 2026 08:50:12 +0000 (16:50 +0800)
committerdongshengyuan <545258830@qq.com>
Thu, 16 Jul 2026 02:03:19 +0000 (10:03 +0800)
Pass relax_extension_release_check through the directory extraction
path instead of hardcoding false. Directory extensions now honor the
same --force relaxation as dissected images.

Reproducer:
  cp -a /tmp/app0 /tmp/app10
  sudo portablectl attach --force --runtime \
      --extension /tmp/app10 /tmp/rootdir app0

Before:
  directory image extraction always used strict extension-release name
  checks. --force relaxed other extension paths but still rejected a
  renamed directory extension with matching metadata.

Follow-up: 06768b90a32ac0d36252ebc5f426ad471bf29fce

src/portable/portable.c
test/units/TEST-29-PORTABLE.directory.sh

index f0af728d4877bc512636400efb8593222b7168a7..e95f6604b4a2d292489da3aa189c927efb9d7ef4 100644 (file)
@@ -541,7 +541,7 @@ static int portable_extract_by_path(
                                                 matches,
                                                 image_name,
                                                 path_is_extension,
-                                                /* relax_extension_release_check= */ false,
+                                                relax_extension_release_check,
                                                 seq[1],
                                                 /* ret_os_release= */ NULL,
                                                 /* ret_unit_files= */ NULL);
@@ -571,7 +571,7 @@ static int portable_extract_by_path(
                                         matches,
                                         image_name,
                                         path_is_extension,
-                                        /* relax_extension_release_check= */ false,
+                                        relax_extension_release_check,
                                         /* socket_fd= */ -EBADF,
                                         &os_release,
                                         &unit_files);
index a1951ee6e1fa3bebea5eb8ff8d68188f6e426a4f..998e6ce40eb8abee21a7b2e8136e08b3b4b3ac39 100755 (executable)
@@ -157,6 +157,13 @@ grep -q -F "ExtensionDirectories=" /run/systemd/system.attached/app0.service.d/2
 
 portablectl detach --now --runtime --extension /tmp/app0 /tmp/rootdir app0
 
+rm -rf /tmp/app10
+cp -a /tmp/app0 /tmp/app10
+portablectl "${ARGS[@]}" attach --force --copy=symlink --runtime --extension /tmp/app10 /tmp/rootdir app0
+portablectl inspect --force --cat --extension /tmp/app10 /tmp/rootdir app0 | grep -f /tmp/app10/usr/lib/extension-release.d/extension-release.app0 >/dev/null
+portablectl detach --runtime --extension /tmp/app10 /tmp/rootdir app0
+rm -rf /tmp/app10
+
 # Attempt to disable the app unit during detaching. Requires --copy=symlink to reproduce.
 # Provides coverage for https://github.com/systemd/systemd/issues/23481
 portablectl "${ARGS[@]}" attach --copy=symlink --now --runtime /tmp/rootdir minimal-app0