From 8800efcb0bea5750f77f88a05ac9211a19cbc7a0 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Oct 03 2023 15:12:48 +0000 Subject: Do not preserve ownership or xattrs on copied files As noticed in https://bugzilla.redhat.com/show_bug.cgi?id=2239008#c16, when compiling a kernel as a user and doing 'sudo make install', and when using a non-vfat fs for the install destination, the file would end up owned by the user. This is not useful at all, so let's only preserve the timestamps on the copied file, no other attributes. Signed-off-by: Zbigniew Jędrzejewski-Szmek --- diff --git a/20-grub.install b/20-grub.install index 952322f..58a998e 100755 --- a/20-grub.install +++ b/20-grub.install @@ -56,7 +56,7 @@ case "$COMMAND" in if [[ "${KERNEL_DIR}" != "/boot" ]]; then # rename to match the name used in the pseudo-BLS snippet above rm -f "/boot/vmlinuz-${KERNEL_VERSION}" - cp -aT "${KERNEL_IMAGE}" "/boot/vmlinuz-${KERNEL_VERSION}" + cp --preserve=timestamps -T "${KERNEL_IMAGE}" "/boot/vmlinuz-${KERNEL_VERSION}" command -v restorecon &>/dev/null && \ restorecon -R "/boot/vmlinuz-${KERNEL_VERSION}" @@ -68,7 +68,7 @@ case "$COMMAND" in do [[ -e "$i" ]] || continue rm -f "/boot/${i##*/}-${KERNEL_VERSION}" - cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}" + cp --preserve=timestamps -T "$i" "/boot/${i##*/}-${KERNEL_VERSION}" command -v restorecon &>/dev/null && \ restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}" done @@ -76,7 +76,7 @@ case "$COMMAND" in i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac" if [[ -e "$i" ]]; then rm -f "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" - cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" + cp --preserve=timestamps "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" command -v restorecon &>/dev/null && \ restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" fi @@ -158,7 +158,7 @@ case "$COMMAND" in if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")" - cp -aT "${BLS_TARGET}" "${BLS_DEBUG}" + cp --preserve=timestamps -T "${BLS_TARGET}" "${BLS_DEBUG}" TITLE="$(grep '^title[ \t]' "${BLS_DEBUG}" | sed -e 's/^title[ \t]*//')" OPTIONS="$(echo "${BOOT_OPTIONS[*]} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')" sed -i -e "s/^title.*/title ${TITLE}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${BLS_DEBUG}"