[Pkg-loop-aes-commits] r1416 - in /trunk/loop-aes-utils: ./ debian/initramfs/hook debian/initramfs/script

xam at users.alioth.debian.org xam at users.alioth.debian.org
Sat Aug 11 14:21:39 UTC 2007


Author: xam
Date: Sat Aug 11 14:21:38 2007
New Revision: 1416

URL: http://svn.debian.org/wsvn/pkg-loop-aes/?sc=1&rev=1416
Log:
Small simplification

Added:
    trunk/loop-aes-utils/debian/initramfs/script
Modified:
    trunk/loop-aes-utils/   (props changed)
    trunk/loop-aes-utils/debian/initramfs/hook

Propchange: trunk/loop-aes-utils/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Sat Aug 11 14:21:38 2007
@@ -1,4 +1,4 @@
-02a4734a-7125-4a10-a2dd-ccf7f6155d04:/local/pkg-loop-aes/trunk/loop-aes-utils:9929
+02a4734a-7125-4a10-a2dd-ccf7f6155d04:/local/pkg-loop-aes/trunk/loop-aes-utils:9930
 53348a03-e5de-0310-b097-96e6f85ea926:/import/loop-aes-utils/branches/2.12-alternative:120
 53348a03-e5de-0310-b097-96e6f85ea926:/import/loop-aes-utils/branches/2.12-dpatch:196
 53348a03-e5de-0310-b097-96e6f85ea926:/import/loop-aes-utils/trunk/current:338

Modified: trunk/loop-aes-utils/debian/initramfs/hook
URL: http://svn.debian.org/wsvn/pkg-loop-aes/trunk/loop-aes-utils/debian/initramfs/hook?rev=1416&op=diff
==============================================================================
--- trunk/loop-aes-utils/debian/initramfs/hook (original)
+++ trunk/loop-aes-utils/debian/initramfs/hook Sat Aug 11 14:21:38 2007
@@ -30,26 +30,24 @@
 	done )
 }
 
-decode_cipher() {
-    local cipher
-
+cipher_modname() {
     # When changing this, don't forget to update the list of all known
     # cipher modules in the iterate_cipher_module call near the end
     # of this file. Also update the copy in initramfs-tools-script
     case "$1" in
+	NONE|XOR|AES*)
+	    ;;
 	twofish*)
-	    echo twofish
+	    echo loop_twofish
 	    ;;
 	blowfish*)
-	    echo blowfish
+	    echo loop_blowfish
 	    ;;
 	serpent*)
-	    echo serpent
+	    echo loop_serpent
 	    ;;
 	mars*|rc6*|tripleDES)
 	    echo "WARNING| (loop-aes) Don't know how to handle encryption type $1" 1>&2
-	    ;;
-	NONE|XOR|AES*)
 	    ;;
 	*)
 	    echo "WARNING| (loop-aes) Unknown encryption type $1" 1>&2
@@ -73,9 +71,9 @@
     for opt in $rootoptions; do
 	case "$opt" in
 	    encryption=*)
-		cipher="$(decode_cipher "${opt#encryption=}")"
-		if [ -n "$cipher" ]; then
-		    rootencryption="${rootencryption}${rootencryption:+:}${cipher}"
+		module="$(cipher_modname "${opt#encryption=}")"
+		if [ -n "$module" ]; then
+		    rootencryption="${rootencryption}${rootencryption:+:}${module}"
 		fi
 		loopaes_opts="${loopaes_opts},${opt}"
 		;;
@@ -214,9 +212,11 @@
 
 manual_add_modules loop
 if [ "${forced}" = no ]; then
-    iterate_cipher_module "manual_add_modules" "$rootencryption"
+    manual_add_modules $rootencryption
 else
-    iterate_cipher_module "manual_add_modules" "serpent:blowfish:twofish"
+    for mod in loop_serpent loop_blowfish loop_twofish; do
+        manual_add_modules $mod
+    done
 fi
 
 # Done

Added: trunk/loop-aes-utils/debian/initramfs/script
URL: http://svn.debian.org/wsvn/pkg-loop-aes/trunk/loop-aes-utils/debian/initramfs/script?rev=1416&op=file
==============================================================================
--- trunk/loop-aes-utils/debian/initramfs/script (added)
+++ trunk/loop-aes-utils/debian/initramfs/script Sat Aug 11 14:21:38 2007
@@ -1,0 +1,149 @@
+#!/bin/sh
+
+#
+# Standard initramfs preamble
+#
+prereqs()
+{
+    echo ""
+}
+
+case $1 in
+prereqs)
+	prereqs
+	exit 0
+	;;
+esac
+
+#
+# Helper functions
+#
+cipher_modname() {
+    # When changing this, don't forget to update the copy in
+    # initramfs-tools-hook, as well as the list of all known cipher
+    # modules in the iterate_cipher_module call near the end of
+    # initramfs-tools-hook.
+    case "$1" in
+	NONE|XOR|AES*)
+	    ;;
+	twofish*)
+	    echo loop_twofish
+	    ;;
+	blowfish*)
+	    echo loop_blowfish
+	    ;;
+	serpent*)
+	    echo loop_serpent
+	    ;;
+	mars*|rc6*|tripleDES)
+	    echo "WARNING| (loop-aes) Don't know how to handle encryption type $1" 1>&2
+	    ;;
+	*)
+	    echo "WARNING| (loop-aes) Unknown encryption type $1" 1>&2
+	    ;;
+    esac
+}
+
+get_options()
+{
+    # Do we have any settings from the /conf/conf.d/loopaes file?
+    [ -r /conf/conf.d/loopaes ] && . /conf/conf.d/loopaes
+    loopaes_opts="${LOOPAESOPTS}"
+
+    # Does the kernel boot command line override them?
+    for x in $(cat /proc/cmdline); do
+	case $x in
+	    loopaesopts=*)
+		loopaes_opts=${x#loopaesopts=}
+		;;
+	esac
+    done
+
+    # Sanity check
+    if [ -z "${loopaes_opts}" ]; then
+	# Apparently the root partition isn't encrypted
+	echo "No root-on-loop configured, skipping"
+	exit 0
+    fi
+
+    # If you change this, keep the version in initramfs-tools-script
+    # in sync.
+    local opt module
+    local IFS=", "
+    for opt in $loopaes_opts; do
+	case $opt in
+	    encryption=*)
+		module="$(cipher_modname "${opt#encryption=}")"
+		if [ -n "$module" ]; then
+		    rootencryption="${rootencryption}${rootencryption:+:}${module}"
+		fi
+		losetup_opts="${losetup_opts} -e ${opt#encryption=}"
+		;;
+	    offset=*)
+		losetup_opts="${losetup_opts} -o ${opt#offset=}"
+		;;
+	    sizelimit=*)
+		losetup_opts="${losetup_opts} -s ${opt#sizelimit=}"
+		;;
+	    pseed=*)
+		losetup_opts="${losetup_opts} -S ${opt#pseed=}"
+		;;
+	    phash=*)
+		losetup_opts="${losetup_opts} -H ${opt#phash=}"
+		;;
+	    loinit=*)
+		losetup_opts="${losetup_opts} -I ${opt#loinit=}"
+		;;
+	    itercountk=*)
+		losetup_opts="${losetup_opts} -C ${opt#itercountk=}"
+		;;
+	    gpgkey=*)
+		losetup_opts="${losetup_opts} -K ${opt#gpgkey=}"
+		;;
+	    gpghome=*)
+		rootgpghome=${opt#gpghome=}
+		;;
+	    loop=*)
+		rootloop=${opt#loop=}
+		;;
+	    *)
+		# Presumably a non-supported or filesystem option
+		;;
+	esac
+    done
+}
+
+#
+# Begin real processing
+#
+
+# define crypto variables
+get_options
+
+if [ -z "${rootgpghome}" ]; then
+    rootgpghome=/.gnupg
+fi
+losetup_opts="${losetup_opts} -G ${rootgpghome}"
+
+if [ -z "${rootloop}" ]; then
+    echo "root on loop enabled, but not loop device given"
+    exit 1
+fi
+
+modprobe -q 
+for x in "$rootencryption"; do
+    modprobe -q "$mod"
+done
+
+while ! [ -b "${rootloop}" ]; do
+      sleep 1
+done
+
+# Use /sbin/losetup to make sure that we get the loopaes modified one,
+# not the busybox one.
+/sbin/losetup ${losetup_opts} "${rootloop}" "$ROOT"
+
+# init can now pick up new FSTYPE, FSSIZE and ROOT
+echo "ROOT=\"${rootloop}\"" >> /conf/param.conf
+exit 0
+




More information about the Pkg-loop-aes-commits mailing list