cryptoloop-source: init file to allow use of encrypted swap
Package: cryptoloop-source
Version: 0.0.0+0.0.1-pre1-8
Followup-For: Bug #203538
Hello,
Here is an init script which aims at providing encrypted swap support
via cryptoloop. It is largely inspired by current Mandrake scripts (so
credits need to be added). It assumes that aes support is in the kernel
(or loaded), it may be launched only as a start script. It could be
extended to support encrypted partition as well, but this needs to
modify /etc/init.d/mountall.sh.
I suggest to put it as S36 in /etc/rcS.d
#! /bin/sh
# Emacs ! This is a -*- sh -*- file
encrypted_swap=$(awk '($0 !~ /^#/ && $3 == "swap" && $4 == "encrypted") {print $1}' /etc/fstab)
if [[ -n $encrypted_swap ]];then
loop=NONE
modprobe loop
if [ $? == 0 ]; then
for (( s = 1; s <= 10; s++ )); do
if [ -b /dev/loop0 ]; then
loop=OK
s=11
else
sleep 1
fi
done
fi
if [ $loop == OK ]; then
for swdev in ${encrypted_swap}; do
loop=NONE
for l in $(echo /dev/loop[0-9]); do
if [ $loop == NONE ] && ! grep -q $l /proc/mounts && ! { losetup $l &> /dev/null; }; then
loop=$l
fi
done
if [ $loop != NONE ]; then
# echo "Found available loop device" $loop
swapoff $swdev > /dev/null 2>&1
dd if=$swdev bs=1024 count=40 2>/dev/null |\
mcookie -f /dev/stdin | losetup -p 0 -e aes -k 128 $loop $swdev
if [ $? == 0 ]; then
echo "Mounting" $swdev "on encrypted" $loop "with random key"
dd if=/dev/zero of=$loop bs=1024 count=40 > /dev/null 2>&1
if [ $? == 0 ]; then
echo "Activating encrypted swap on" $swdev "using" $loop
mkswap $loop
swapon -p 0 $loop
fi
else
echo "Failed to mount" $swdev "on encrypted" $loop "with random key"
fi
else
echo "Could not find any available loop device for encrypted swap!"
fi
done
fi
fi
-- System Information:
Debian Release: testing/unstable
Architecture: powerpc
Kernel: Linux guybrush 2.4.21-ben2-guybrush.45 #1 mer jui 30 19:55:47 CEST 2003 ppc
Locale: LANG=fr_FR@euro, LC_CTYPE=fr_FR@euro
Versions of packages cryptoloop-source depends on:
ii bash 2.05b-8.1 The GNU Bourne Again SHell
ii build-essential 9.4 informational list of build-essent
ii cryptoapi-core-source 0.1.0-3 CryptoAPI core kernel module
ii grep-dctrl 1.100 Grep Debian package information
ii kernel-patch-scripts 0.99.27 Scripts to help dealing with packa
ii patch 2.5.9-1 Apply a diff file to an original
-- no debconf information
Reply to: