diff options
author | Justin Boffemmyer | 2018-02-21 12:27:23 +0900 |
---|---|---|
committer | Justin Boffemmyer | 2018-02-21 12:27:23 +0900 |
commit | 07047b4387c0d2fff909d6a816fdac0b1d24e8b0 (patch) | |
tree | 4a15db7cc059a8f1acba5e8c0ffa2b5145d3fbcc | |
parent | 402116d48b063bcb80aaf7bbf8d25749bee62e40 (diff) |
There were some (logic) typos in the chroot close functions that prevented them
from working correctly. Namely, the file to grep (/proc/mounts) was missing
from the grep command, leaving it stuck in an endless loop. Also, there were
copy-paste errors in the enchant function that referenced cauldron
functions/variables.
-rw-r--r-- | cauldron/lib/lib.chroot | 11 | ||||
-rw-r--r-- | enchantment/lib/lib.chroot | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/cauldron/lib/lib.chroot b/cauldron/lib/lib.chroot index ad9698f..66855d0 100644 --- a/cauldron/lib/lib.chroot +++ b/cauldron/lib/lib.chroot @@ -125,16 +125,17 @@ function cauldron_chroot_close() { for target in "${chroot[@]}" do - local mounts=( $(grep -o "$target[^[:space:]]*" | sort -r) ) - [[ -n "$mounts" ]] || mounts=( sys run dev/pts dev proc ) - cauldron_verbose "closing chroot mounts: ${mounts[@]}" + # get a list of all mounted subdirs in the target in reverse order to ensure + # that subdirs are unmounted before their parents + local mounts=( $(grep -o "$target[^[:space:]]*" "/proc/mounts" | sort -r) ) # unmount the chroot mount points for mnt in "${mounts[@]}" do - if grep -q "$mnt" "$target/proc/mounts" + if grep -q "$mnt" "/proc/mounts" then - "${CAULDRON_CMD_UNMOUNT[@]}" "$target/$mnt" || + cauldron_verbose "umounting in chroot: ${mnt#$target/}" + "${CAULDRON_CMD_UNMOUNT[@]}" "$mnt" || return $ERR_CHROOT_DONE fi done diff --git a/enchantment/lib/lib.chroot b/enchantment/lib/lib.chroot index de61ff1..0391e69 100644 --- a/enchantment/lib/lib.chroot +++ b/enchantment/lib/lib.chroot @@ -125,16 +125,17 @@ function enchant_chroot_close() { for target in "${chroot[@]}" do - local mounts=( $(grep -o "$target[^[:space:]]*" | sort -r) ) - [[ -n "$mounts" ]] || mounts=( sys run dev/pts dev proc ) - cauldron_verbose "closing chroot mounts: ${mounts[@]}" + # get a list of all mounted subdirs in the target in reverse order to ensure + # that subdirs are unmounted before their parents + local mounts=( $(grep -o "$target[^[:space:]]*" "/proc/mounts" | sort -r) ) # unmount the chroot mount points for mnt in "${mounts[@]}" do - if grep -q "$mnt" "$target/proc/mounts" + if grep -q "$mnt" "/proc/mounts" then - "${CAULDRON_CMD_UNMOUNT[@]}" "$target/$mnt" || + enchant_verbose "umounting in chroot: ${mnt#$target/}" + "${ENCHANT_CMD_UNMOUNT[@]}" "$mnt" || return $ERR_CHROOT_DONE fi done |