From a67bb493af0c6e25cedcee1440a6904f9e80566e Mon Sep 17 00:00:00 2001 From: ading2210 <71154407+ading2210@users.noreply.github.com> Date: Fri, 3 May 2024 17:10:55 +0000 Subject: [PATCH] remount without nodev/noexec, fixes #16 --- build_rootfs.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build_rootfs.sh b/build_rootfs.sh index 9a05f6d..84af9f2 100755 --- a/build_rootfs.sh +++ b/build_rootfs.sh @@ -40,6 +40,22 @@ unmount_all() { done } +need_remount() { + local target="$1" + local mnt_options="$(findmnt -T "$target" | tail -n1 | rev | cut -f1 -d' '| rev)" + echo "$mnt_options" | grep -e "noexec" -e "nodev" +} + +do_remount() { + local target="$1" + local mountpoint="$(findmnt -T "$target" | tail -n1 | cut -f1 -d' ')" + mount -o remount,dev,exec "$mountpoint" +} + +if [ "$(need_remount "$rootfs_dir")" ]; then + do_remount "$rootfs_dir" +fi + debootstrap --arch amd64 $release_name $rootfs_dir http://deb.debian.org/debian/ cp -ar rootfs/* $rootfs_dir cp /etc/resolv.conf $rootfs_dir/etc/resolv.conf