libdevuansdk

common library for devuan's simple distro kits
git clone https://git.parazyd.org/libdevuansdk
Log | Files | Refs | Submodules | README | LICENSE

commit 25a86b7428eabe0ab7f3a45daa76ff84a07af450
parent 3cffb94e5cc47210ccb9177052e8b6c71d2c8cbb
Author: gryrmln <gryrmln@localhost>
Date:   Fri,  2 Apr 2021 12:00:46 +0100

Check no mounts prior to 'sudo rm -rf' (zlibs/{helpers,bootstrap})

Signed-off-by: gryrmln <gryrmln@localhost>

Diffstat:
Mzlibs/bootstrap | 12+++++++++++-
Mzlibs/helpers | 8++++++++
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/zlibs/bootstrap b/zlibs/bootstrap @@ -246,7 +246,17 @@ bootstrap_cpio_unpack() notice "Unpacking bootstrap cpio archive: $_bootstrap_cpio" silly - sudo rm -rf "${strapdir}"/* + # Danger Will Robinson + # Check for (bind) mounts as sudo rm -rf will trash the host + for m in sys proc dev; do + if [[ $(mountpoint -q "${strapdir}/$m") ]]; then + zerr + return 1 + fi + done + # remove everything, including .dotdirfiles + sudo rm -rf "$strapdir" + mkdir -p "$strapdir" pushd "$strapdir" || { zerr; return 1; } zcat "$_bootstrap_cpio" | sudo cpio -idmn --format=newc || { zerr; return 1; } diff --git a/zlibs/helpers b/zlibs/helpers @@ -113,6 +113,14 @@ clean_strapdir() notice "Cleaning strapdir" + # Danger Will Robinson + # Check for (bind) mounts as sudo rm -rf will trash the host + for m in sys proc dev; do + if [[ $(mountpoint -q "${strapdir}/$m") ]]; then + zerr + return 1 + fi + done sudo rm -rf "$strapdir" }