]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install/90-loaderentry: make ownership change optional
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 1 Jul 2022 10:50:17 +0000 (12:50 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Jul 2022 14:33:11 +0000 (16:33 +0200)
This can be useful when running as non-root, e.g. for tests or when
installing to a chroot.

src/kernel-install/90-loaderentry.install

index b700a7b2a603e9bccdd7d75889e0c130b44629df..d6b90a7b1d6277530ef49298cd019ae383fc6381 100644 (file)
@@ -105,10 +105,11 @@ if ! [ -d "$ENTRY_DIR_ABS" ]; then
     exit 1
 fi
 
-install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
+install -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || {
     echo "Error: could not copy '$KERNEL_IMAGE' to '$ENTRY_DIR_ABS/linux'." >&2
     exit 1
 }
+chown root.root "$ENTRY_DIR_ABS/linux" || :
 
 shift "$INITRD_OPTIONS_SHIFT"
 # All files listed as arguments, and staged files starting with "initrd" are installed as initrds.
@@ -121,10 +122,11 @@ for initrd in "$@" "${KERNEL_INSTALL_STAGING_AREA}"/initrd*; do
 
     initrd_basename="${initrd##*/}"
     [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Installing $ENTRY_DIR_ABS/$initrd_basename"
-    install -g root -o root -m 0644 "$initrd" "$ENTRY_DIR_ABS/$initrd_basename" || {
+    install -m 0644 "$initrd" "$ENTRY_DIR_ABS/$initrd_basename" || {
         echo "Error: could not copy '$initrd' to '$ENTRY_DIR_ABS/$initrd_basename'." >&2
         exit 1
     }
+    chown root.root "$ENTRY_DIR_ABS/$initrd_basename" || :
 done
 
 mkdir -p "${LOADER_ENTRY%/*}" || {