From 88a44d6deb1834832eb58c1819bc054d2970a729 Mon Sep 17 00:00:00 2001 From: Kim Hagen Date: Fri, 14 Jun 2019 10:57:02 +0200 Subject: do not mount unknown filesystems or raid slaves --- components/9990-misc-helpers.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'components/9990-misc-helpers.sh') diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index 605ee8a..9dd7ef5 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -712,6 +712,25 @@ mount_persistence_media () return 1 fi + fstype="$(get_fstype ${device})" + if [ "${fstype}" = "unknown" ] + return 1 + fi + + raid_drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' \ + | grep "md" | egrep -v "^$") + + disks=() + for raid_drive in $raid_drives; do + disks+=`ls /sys/block/$raid_drive/slaves` + done + + for disk in ${disks[@]}; do + if [ "/dev/${disk}" = "${device}" ] + return 1 + fi + done + backing="/live/persistence/" mkdir -p "${backing}" @@ -719,6 +738,10 @@ mount_persistence_media () if [ -z "${old_backing}" ] then fstype="$(get_fstype ${device})" + if [ "${fstype}" = "unknown" ] + return 1 + fi + mount_opts="rw,noatime" if [ -n "${PERSISTENCE_READONLY}" ] then -- cgit v1.2.3