diff -ru rc-scripts-1.5.1.orig/etc/conf.d/cryptfs rc-scripts-1.5.1/etc/conf.d/cryptfs --- rc-scripts-1.5.1.orig/etc/conf.d/cryptfs 2004-07-30 12:40:03.314561848 +0000 +++ rc-scripts-1.5.1/etc/conf.d/cryptfs 2004-07-30 12:42:27.163693456 +0000 @@ -1,19 +1,9 @@ -# Encryped file systems are configured here -# Syntax: -# Each line must be either: -# swap= source= [options=] [pre_mount=] -# or: -# mount= source= [options=] [pre_mount=] [post_mount=] - -# Swap partitions. These should come first in this file so that no keys make their way into unencrypted swap +# Swap partitions. These should come first so that no keys make their way into unencrypted swap # If no options are given, they will default to: -c aes -h sha1 -d /dev/urandom # If no makefs is given then mkswap will be assumed -# The post_mount command is ignored for swap - -# swap=crypt-swap source='/dev/main/swap' +swap=crypt-swap source='/dev/main/swap' # Mounts # If no options are given, they will default to: -c aes -h sha1 # No mkfs is run unless you specify a makefs option - -# mount=crypt-tmp options='-d /dev/urandom' source='/dev/main/tmp' pre_mount='/sbin/mkreiserfs -f -f ${dev}' post_mount='chown root:root ${mount_point}; chmod 1777 ${mount_point}' +mount=crypt-tmp options='-d /dev/urandom' source='/dev/main/tmp' pre_mount='/sbin/mkreiserfs -f -f ${dev}' post_mount='chown root:root ${mount_point}; chmod 1777 ${mount_point}' diff -ru rc-scripts-1.5.1.orig/init.d/checkfs rc-scripts-1.5.1/init.d/checkfs --- rc-scripts-1.5.1.orig/init.d/checkfs 2004-06-15 21:03:10.000000000 +0000 +++ rc-scripts-1.5.1/init.d/checkfs 2004-07-30 12:42:08.700500288 +0000 @@ -179,6 +179,70 @@ eend $? "Failed to setup the LVM" fi + + ebegin 'Setting up dm-crypt mappings' + + if [ -f /etc/conf.d/cryptfs ] + then + cryptfs_status=0 + + /bin/egrep '^(mount|swap)' /etc/conf.d/cryptfs | \ + while read mountline + do + mount= + swap= + options= + pre_mount= + + eval ${mountline} + + if [ -n "${mount}" ] + then + target=${mount} + [ -z "${options}" ] && options='-c aes -h sha1' + elif [ -n "${swap}" ] + then + target=${swap} + [ -z "${options}" ] && options='-c aes -h sha1 -d /dev/urandom' + else + ewarn "Invalid line in /etc/conf.d/cryptomount: ${mountline}" + fi + + ! /bin/cryptsetup status ${target}|egrep '\ /dev/null + configured=$? + + if [ ${configured} -eq 0 ] + then + einfo "dm-crypt map ${target}" + if ! /bin/cryptsetup ${options} create ${target} ${source} >/dev/console /dev/null + then + ewarn "Failed to run pre_mount commands on: ${target}" + cryptfs_status=1 + fi + fi + fi + else + ewarn "dm-crypt mapping ${target} is already configured" + cryptfs_status=1 + fi + done + fi + ewend ${cryptfs_status} 'Failed to setup a mapping or swap device.' + if [ -f /fastboot -o -n "${CDBOOT}" ] then rm -f /fastboot diff -ru rc-scripts-1.5.1.orig/init.d/halt.sh rc-scripts-1.5.1/init.d/halt.sh --- rc-scripts-1.5.1.orig/init.d/halt.sh 2004-06-15 16:32:24.000000000 +0000 +++ rc-scripts-1.5.1/init.d/halt.sh 2004-07-30 12:42:14.635598016 +0000 @@ -123,6 +123,39 @@ done eend 0 +# Try to remove any dm-crypt mappings + +if [ -f /etc/conf.d/cryptfs ] +then + ebegin "Removing dm-crypt mappings" + + /bin/egrep "^(mount|swap)" /etc/conf.d/cryptfs | \ + while read mountline + do + mount= + swap= + target= + + eval ${mountline} + + if [ -n "${mount}" ] + then + target=${mount} + elif [ -n "${swap}" ] + then + target=${swap} + else + ewarn "Invalid line in /etc/conf.d/cryptfs: ${mountline}" + fi + + einfo "Removing dm-crypt mapping for: ${target}" + if ! /bin/cryptsetup remove ${target} + then + ewarn "Failed to remove dm-crypt mapping for: ${target}" + fi + done +fi + # Stop LVM if [ -x /sbin/vgchange ] && [ -f /etc/lvmtab -o -d /etc/lvm ] && \ [ -d /proc/lvm -o "`grep device-mapper /proc/misc 2>/dev/null`" ] diff -ru rc-scripts-1.5.1.orig/init.d/localmount rc-scripts-1.5.1/init.d/localmount --- rc-scripts-1.5.1.orig/init.d/localmount 2004-06-15 16:32:24.000000000 +0000 +++ rc-scripts-1.5.1/init.d/localmount 2004-07-30 12:42:02.832392376 +0000 @@ -41,6 +41,48 @@ ebegin "Activating (possibly) more swap" /sbin/swapon -a &>/dev/null eend 0 + + # Run any post_mount commands for cryptfs + + if [ -f /etc/conf.d/cryptfs ] + then + ebegin "Running post_mount commands for cryptfs" + + /bin/egrep "^mount" /etc/conf.d/cryptfs | \ + while read mountline + do + mount= + mount_point= + post_mount= + + eval ${mountline} + + target=${mount} + + ! /bin/cryptsetup status ${target}|egrep '\ /dev/null + configured=$? + + if [ ${configured} -eq 1 ] + then + mount_point=`/bin/awk "/\/dev\/mapper\/${target}/ { print \\$2 }" /proc/mounts` + if [ -n "${mount_point}" ] + then + if [ -n "${post_mount}" ] + then + if ! eval "${post_mount}" > /dev/null + then + ewarn "Failed to run post_mount commands on: ${target}" + fi + fi + else + ewarn "Failed to find mount point to ${target}. Skipping" + fi + else + ewarn "Target ${target} wasn't mapped, skipping" + fi + + done + fi }