From 87c674055316c2938d37e92789a6041824844c0d Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Tue, 8 Jun 2010 12:38:33 +0200 Subject: mkinitramfs: warn if TMPDIR is mounted noexec + fall back to not cache run scripts then If the TMPDIR (/tmp by default) is mounted with noexec the user will notify several lines like: /usr/sbin/mkinitramfs: 276: /tmp/mkinitramfs_Ck5cpl/scripts/init-top/all_generic_ide: Permission denied To get rid of that the user can either point $TMPDIR to a filesystem that's mounted with exec permission or otherwise the cache_run_scripts() feature won't be used. Notify user accordingly with a warning message. [Closes: #576678] Signed-off-by: Michael Prokop --- mkinitramfs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mkinitramfs b/mkinitramfs index 04eae42..baf69dd 100755 --- a/mkinitramfs +++ b/mkinitramfs @@ -164,6 +164,14 @@ fi DESTDIR="$(mktemp -d ${TMPDIR:-/tmp}/mkinitramfs_XXXXXX)" || exit 1 chmod 755 "${DESTDIR}" + +# do not execute cache_run_scripts() if mounted with noexec +NOEXEC="" +fs=$(df $DESTDIR | tail -1 | awk '{print $6}') +if [ -n "$fs" ] && mount | grep -q "on $fs .*noexec" ; then + NOEXEC=1 +fi + __TMPCPIOGZ="$(mktemp ${TMPDIR:-/tmp}/mkinitramfs-OL_XXXXXX)" || exit 1 DPKG_ARCH=`dpkg --print-architecture` @@ -277,9 +285,13 @@ run_scripts /usr/share/initramfs-tools/hooks run_scripts "${CONFDIR}"/hooks # cache boot run order -for b in $(cd "${DESTDIR}/scripts" && find . -mindepth 1 -type d); do - cache_run_scripts "${DESTDIR}" "/scripts/${b#./}" -done +if [ -n "$NOEXEC" ]; then + echo "Warning: TMPDIR is mounted noexec, will not cache run scripts." +else + for b in $(cd "${DESTDIR}/scripts" && find . -mindepth 1 -type d); do + cache_run_scripts "${DESTDIR}" "/scripts/${b#./}" + done +fi # generate module deps depmod -a -b "${DESTDIR}" ${version} -- cgit v1.2.3