1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#!/bin/sh
. /lib/partman/definitions.sh
# 1. Check if active encrypted devices exist
crypto=no
for dev in $DEVICES/*; do
[ -d "$dev" ] || continue
cd $dev
if [ -f crypt_realdev ]; then
crypto=yes
break
fi
done
if [ $crypto = no ]; then
exit 0
fi
# 2. Check if unencrypted swap has been configured
for dev in $DEVICES/*; do
[ -d "$dev" ] || continue
cd $dev
# Ignore swap on crypto
[ -f crypt_realdev ] && continue
# Ignore e.g. swap on lvm on crypto
device=$(cat $dev/device)
if $(echo $device | grep -q "^/dev/mapper/"); then
found=1
for majmin in $(dmsetup deps $device | cut -d ":" -f2 |\
tr -d " (" | tr ")" "\n"); do
maj=$(echo $majmin | sed 's/,.*//')
min=$(echo $majmin | sed 's/.*,//')
status=$(dmsetup status -j $maj -m $min 2> /dev/null |\
cut -d' ' -f3)
if [ $? -ne 0 ] || [ $status != "crypt" ]; then
found=0
fi
done
[ $found ] && continue
fi
partitions=
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
[ "$fs" != free ] || continue
partitions="$partitions $id"
done
close_dialog
for id in $partitions; do
[ -f $id/method ] || continue
method=$(cat $id/method)
if [ "$method" = swap ]; then
# Unsafe swap! Abort commit
db_fset partman-crypto/unsafe_swap seen false
db_input critical partman-crypto/unsafe_swap
db_go || true
exit 1
fi
done
done
|