]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut.sh): unfreeze /boot on exit
authorSergei Iudin <tsipa740@gmail.com>
Fri, 19 Feb 2021 21:06:03 +0000 (13:06 -0800)
committerHarald Hoyer <harald@hoyer.xyz>
Tue, 23 Feb 2021 08:25:08 +0000 (09:25 +0100)
If SIGWHATEVER will be processed after fsfreeze -f, but before fsfreeze
-u we will end up with /boot/ never unfrozen, let's try to minimize risk of this.

dracut.sh

index 800a67643a099a46e9b1e502ff448ab72d3b7f26..04581cdbc1baa2e216790461b81143fa6b273a4e 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1009,6 +1009,9 @@ readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
 trap '
     ret=$?;
     [[ $keep ]] && echo "Not removing $DRACUT_TMPDIR." >&2 || { [[ $DRACUT_TMPDIR ]] && rm -rf -- "$DRACUT_TMPDIR"; };
+    if [[ ${FSFROZEN} ]]; then
+      fsfreeze -u "${FSFROZEN}"
+    fi
     exit $ret;
     ' EXIT
 
@@ -2304,9 +2307,11 @@ if [[ -d $dracutsysrootdir/run/systemd/system ]]; then
 
     # use fsfreeze only if we're not writing to /
     if [[ "$(stat -c %m -- "$outfile")" != "/" ]] && freeze_ok_for_fstype "$outfile"; then
-        if ! (fsfreeze -f "$(dirname "$outfile")" 2>/dev/null && fsfreeze -u "$(dirname "$outfile")" 2>/dev/null); then
+        FSFROZEN="$(dirname "$outfile")"
+        if ! (fsfreeze -f "${FSFROZEN}" 2>/dev/null && fsfreeze -u "${FSFROZEN}" 2>/dev/null); then
             dinfo "dracut: warning: could not fsfreeze $(dirname "$outfile")"
         fi
+        unset FSFROZEN
     fi
 fi