Alright, here's my first stab at it.  Please let me know whether this
method is acceptable; if it is, I'll clean stuff up, update
documentation, and submit a new patch.


-- 
Andres Salomon <[EMAIL PROTECTED]>
* looking for [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--base-0 to compare with
* comparing to [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--base-0
..............

* modified files

--- orig/changelog
+++ mod/changelog
@@ -1,3 +1,11 @@
+cryptsetup (20050111-3.1) unstable; urgency=low
+
+  * NMU
+  * Break cryptdisks init script out into two pieces; one that mounts devices
+    that require a password (cryptdisks), and one that doesn't (cryptsetup).
+
+ -- Andres Salomon <[EMAIL PROTECTED]>  Sun, 10 Apr 2005 12:24:51 -0400
+
 cryptsetup (20050111-3) unstable; urgency=low
 
   * Switch to using automake-1.8 (closes: #298325, #291500)


--- orig/cryptdisks.default
+++ mod/cryptdisks.default
@@ -1,2 +1,5 @@
 # Run cryptdisks at startup ?
 CRYPTDISKS_ENABLE=Yes
+
+# Mount disks that require a password prompt?
+CRYPTDISKS_PROMPT=Yes


--- orig/cryptdisks
+++ mod/cryptdisks.prompt
@@ -1,7 +1,7 @@
 #! /bin/sh
 #
-# cryptodisks	Now that all block devices should be available, setup
-#		encrypted block devices
+# cryptodisks.prompt	Now that all block devices should be available, setup
+#		encrypted block devices that require passwords
 
 CRYPTCMD=/sbin/cryptsetup
 DEVMAPCMD=/sbin/dmsetup
@@ -24,35 +24,19 @@
 
 case "$1" in
 start)
-	echo -n "Starting crypto disks:"
+	echo -n "Starting crypto disks that need passwords:"
 	egrep -v "^[[:space:]]*(#|$)" $TABFILE | while read dst src key opt; do
+		if [ "x$key" != "x" ] && [ "x$key" != "xnone" ]; then
+			# Only process entries that require a password
+			continue
+		fi
+
 		echo -n " $dst"
 		if test -b $MAPPER/$dst; then
 			echo -n "(running)"
 		else
 			echo -n "(starting)"
-			if [ "x$key" != "x" ] && [ "x$key" != "xnone" ]; then
-				INTERACTIVE="no"
-				if test -e "$key" ; then
-					MODE=`ls -l $key | sed 's/^....\(......\).*/\1/'`
-					OWNER=`ls -l $key | sed 's/^[^ ]* *[^ ]* *\([^ ]*\).*/\1/'`
-					if test "$MODE" != "------" && \
-					   test "$key" != "/dev/urandom"  && \
-					   test "$key" != "/dev/hwrandom" && \
-					   test "$key" != "/dev/random"; then
-						echo " - INSECURE MODE FOR $key" >&2
-					fi
-					if test $OWNER != root; then
-						echo " - INSECURE OWNER FOR $key" >&2
-					fi
-				else
-					echo " - Keyfile for $dst not found, skipping" >&2
-					continue
-				fi
-			else
-				INTERACTIVE="yes"
-				echo "..."
-			fi
+			echo "..."
 			
 			PARAMS=""
 			MAKESWAP=""
@@ -133,12 +117,7 @@
 				continue
 			fi
 
-			if test "x$INTERACTIVE" = "xyes" ; then
-				$CRYPTCMD $PARAMS create $dst $src <&1
-			else
-				$CRYPTCMD $PARAMS -d $key create $dst $src
-			fi
-
+			$CRYPTCMD $PARAMS create $dst $src <&1
 			if test "x$MAKESWAP" = "xyes" && test -b $MAPPER/$dst; then
 				mkswap $MAPPER/$dst 2>/dev/null >/dev/null
 			fi
@@ -151,8 +130,13 @@
 	echo "."
 	;;
 stop)
-	echo -n "Stopping crypto disks:"
+	echo -n "Stopping crypto disks that need passwords:"
 	egrep -v "^[[:space:]]*(#|$)" $TABFILE | while read dst src key; do
+		if [ "x$key" != "x" ] && [ "x$key" != "xnone" ]; then
+			# Only process entries that require a password
+			continue
+		fi
+
 		echo -n " $dst"
 		if test -b $MAPPER/$dst; then
 			if $DEVMAPCMD info $dst | grep -q '^Open count: *0$'; then


--- orig/rules
+++ mod/rules
@@ -77,6 +77,7 @@
 	cp src/cryptsetup.static $(CURDIR)/debian/cryptsetup/sbin/cryptsetup
 
 	install debian/cryptdisks $(CURDIR)/debian/cryptsetup/etc/init.d
+	install debian/cryptdisks.prompt $(CURDIR)/debian/cryptsetup/etc/init.d
 	install -m 0644 debian/cryptdisks.default $(CURDIR)/debian/cryptsetup/etc/default/cryptdisks
 	install -m 0644 debian/cryptsetup.8 $(CURDIR)/debian/cryptsetup/usr/share/man/man8
 	install -m 0644 debian/crypttab.5 $(CURDIR)/debian/cryptsetup/usr/share/man/man5



* added files

--- /dev/null
+++ mod/cryptdisks
@@ -0,0 +1,208 @@
+#! /bin/sh
+#
+# cryptodisks	Now that all block devices should be available, setup
+#		encrypted block devices that don't require passwords
+
+CRYPTCMD=/sbin/cryptsetup
+DEVMAPCMD=/sbin/dmsetup
+TABFILE=/etc/crypttab
+MAPPER=/dev/mapper
+PROMPTINIT=/etc/init.d/cryptdisks.prompt
+
+test -x $CRYPTCMD  || exit 0
+test -x $DEVMAPCMD || exit 0
+test -f $TABFILE   || exit 0             
+
+[ -r /etc/default/cryptdisks ] && . /etc/default/cryptdisks
+
+case "$CRYPTDISKS_ENABLE" in
+        [Nn]*)
+                exit 0
+                ;;
+esac
+
+case "$CRYPTDISKS_PROMPT" in
+	[Nn]*)
+		INTERACTIVE=no
+		;;
+	*)
+		INTERACTIVE=yes
+		;;
+esac
+test -x $PROMPTINIT || INTERACTIVE=no
+
+$DEVMAPCMD mknodes
+
+case "$1" in
+start)
+	echo -n "Starting crypto disks:"
+	egrep -v "^[[:space:]]*(#|$)" $TABFILE | while read dst src key opt; do
+		if [ "x$key" = "x" ] || [ "x$key" = "xnone" ]; then
+			# Only process entries that don't require a password
+			continue
+		fi
+
+		echo -n " $dst"
+		if test -b $MAPPER/$dst; then
+			echo -n "(running)"
+		else
+			echo -n "(starting)"
+			if test -e "$key" ; then
+				MODE=`ls -l $key | sed 's/^....\(......\).*/\1/'`
+				OWNER=`ls -l $key | sed 's/^[^ ]* *[^ ]* *\([^ ]*\).*/\1/'`
+				if test "$MODE" != "------" && \
+				   test "$key" != "/dev/urandom"  && \
+				   test "$key" != "/dev/hwrandom" && \
+				   test "$key" != "/dev/random"; then
+					echo " - INSECURE MODE FOR $key" >&2
+				fi
+				if test $OWNER != root; then
+					echo " - INSECURE OWNER FOR $key" >&2
+				fi
+			else
+				echo " - Keyfile for $dst not found, skipping" >&2
+				continue
+			fi
+			
+			PARAMS=""
+			MAKESWAP=""
+			MAKETMP=""
+			SKIP=""
+
+			# Parse the options field, convert to cryptsetup parameters
+                        # and contruct the command line
+			while test "x$opt" != "x" ; do
+				ARG=`echo $opt | sed "s/,.*//"`
+				opt=${opt##$ARG}
+				opt=${opt##,}
+				PARAM=`echo $ARG | sed "s/=.*//"`
+				VALUE=${ARG##$PARAM=}
+				
+				case "$PARAM" in 
+					readonly)
+						PARAM=-r
+						VALUE=""
+						;;
+					cipher)
+						PARAM=-c
+						if test "x$VALUE" = "x" ; then
+							echo " - no value for cipher option, skipping" >&2
+							SKIP="yes"
+						fi
+						;;
+					size)
+						PARAM=-s
+						if test "x$VALUE" = "x" ; then
+							echo " - no value for size option, skipping" >&2
+							SKIP="yes"
+						fi
+						;;
+					hash)
+						PARAM=-h
+						if test "x$VALUE" = "x" ; then
+							echo " - no value for hash option, skipping" >&2
+							SKIP=yes
+						fi
+						;;
+					verify)
+						PARAM=-y
+						VALUE=""
+						;;
+					swap)
+						MAKESWAP=yes
+						PARAM=""
+						VALUE=""
+						;;
+					tmp)
+						MAKETMP=yes
+						PARAM=""
+						VALUE=""
+				esac
+				PARAMS="$PARAMS $PARAM $VALUE"
+			done
+
+			# Set up loopback devices
+			if test -f "$src" ; then
+				test -d /sys/block/loop0 || modprobe loop || SKIP=yes
+				LOOP_ID=
+				for i in 0 1 2 3 4 5 6 7 ; do
+					if test "x`cat /sys/block/loop$i/size`" = "x0" ; then
+						LOOP_ID=$i
+						break
+					fi
+				done
+				if test "x$LOOP_ID" = "x" ; then
+					SKIP=yes
+				else
+					losetup /dev/loop$LOOP_ID $src || SKIP=yes
+					src=/dev/loop$LOOP_ID
+				fi
+			fi
+
+			if test "x$SKIP" = "xyes" ; then
+				continue
+			fi
+
+			$CRYPTCMD $PARAMS -d $key create $dst $src
+			if test "x$MAKESWAP" = "xyes" && test -b $MAPPER/$dst; then
+				mkswap $MAPPER/$dst 2>/dev/null >/dev/null
+			fi
+
+			if test "x$MAKETMP" = "xyes" && test -b $MAPPER/$dst; then
+				mke2fs $MAPPER/$dst 2>/dev/null >/dev/null
+			fi
+		fi
+	done
+
+	echo "."
+
+	# Start up password prompting devices, if desired.
+	if [ "x$INTERACTIVE" = "xyes" ]; then
+		$PROMPTINIT "$1"
+	fi
+	;;
+stop)
+	echo -n "Stopping crypto disks:"
+	egrep -v "^[[:space:]]*(#|$)" $TABFILE | while read dst src key; do
+		if [ "x$key" = "x" ] || [ "x$key" = "xnone" ]; then
+			# Only process entries that don't require a password
+			continue
+		fi
+
+		echo -n " $dst"
+		if test -b $MAPPER/$dst; then
+			if $DEVMAPCMD info $dst | grep -q '^Open count: *0$'; then
+				dev=`$DEVMAPCMD table $dst | sed 's/^.* \([0-9]*:[0-9]*\) .*/\1/'`
+				major=`echo $dev | sed 's/:.*//'`
+				minor=`echo $dev | sed 's/.*://'`
+				
+				echo -n "(stopping)"
+				$CRYPTCMD remove $dst
+				
+				# Detach loopback device, if attached
+				if test -f $src -a $major -eq 7; then
+					losetup -d /dev/loop$minor
+				fi
+			else
+				echo -n "(busy)"
+			fi
+		else
+			echo -n "(stopped)"
+		fi
+	done
+
+	echo "."
+
+	# Shut down password prompting devices, if desired.
+	if [ "x$INTERACTIVE" = "xyes" ]; then
+		$PROMPTINIT "$1"
+	fi
+	;;
+restart|reload|force-reload)
+	$0 stop
+	$0 start
+	;;
+*)
+	echo "Usage: $0 {start|stop|restart|reload|force-reload}"
+	;;
+esac
--- /dev/null
+++ mod/{arch}/cryptsetup/cryptsetup--debian-noprompt/cryptsetup--debian-noprompt--0/[EMAIL PROTECTED]/patch-log/patch-1
@@ -0,0 +1,13 @@
+Revision: cryptsetup--debian-noprompt--0--patch-1
+Archive: [EMAIL PROTECTED]
+Creator: Andres Salomon <[EMAIL PROTECTED]>
+Date: Sun Apr 10 12:48:38 EDT 2005
+Standard-date: 2005-04-10 16:48:38 GMT
+New-files: .arch-ids/cryptsetup.id cryptsetup
+Modified-files: changelog cryptdisks.default rules
+New-patches: [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--patch-1
+Summary: create cryptsetup init script, add CRYPTDISKS_PROMPT (default to yes)
+Keywords: 
+
+
+
--- /dev/null
+++ mod/{arch}/cryptsetup/cryptsetup--debian-noprompt/cryptsetup--debian-noprompt--0/[EMAIL PROTECTED]/patch-log/patch-2
@@ -0,0 +1,12 @@
+Revision: cryptsetup--debian-noprompt--0--patch-2
+Archive: [EMAIL PROTECTED]
+Creator: Andres Salomon <[EMAIL PROTECTED]>
+Date: Sun Apr 10 13:21:56 EDT 2005
+Standard-date: 2005-04-10 17:21:56 GMT
+Modified-files: cryptdisks cryptsetup
+New-patches: [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--patch-2
+Summary: make cryptdisks and cryptsetup each do their respective thing
+Keywords: 
+
+
+
--- /dev/null
+++ mod/{arch}/cryptsetup/cryptsetup--debian-noprompt/cryptsetup--debian-noprompt--0/[EMAIL PROTECTED]/patch-log/patch-3
@@ -0,0 +1,12 @@
+Revision: cryptsetup--debian-noprompt--0--patch-3
+Archive: [EMAIL PROTECTED]
+Creator: Andres Salomon <[EMAIL PROTECTED]>
+Date: Sun Apr 10 13:27:35 EDT 2005
+Standard-date: 2005-04-10 17:27:35 GMT
+Modified-files: cryptsetup
+New-patches: [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--patch-3
+Summary: ensure the prompting init script actually exists
+Keywords: 
+
+
+
--- /dev/null
+++ mod/{arch}/cryptsetup/cryptsetup--debian-noprompt/cryptsetup--debian-noprompt--0/[EMAIL PROTECTED]/patch-log/patch-4
@@ -0,0 +1,16 @@
+Revision: cryptsetup--debian-noprompt--0--patch-4
+Archive: [EMAIL PROTECTED]
+Creator: Andres Salomon <[EMAIL PROTECTED]>
+Date: Sun Apr 10 13:33:13 EDT 2005
+Standard-date: 2005-04-10 17:33:13 GMT
+Renamed-files: .arch-ids/cryptdisks.id .arch-ids/cryptdisks.prompt.id
+    .arch-ids/cryptsetup.id .arch-ids/cryptdisks.id
+    cryptdisks cryptdisks.prompt
+    cryptsetup cryptdisks
+Modified-files: cryptdisks cryptdisks.prompt rules
+New-patches: [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--patch-4
+Summary: rename crypt init scripts to cryptdisks and cryptdisks.prompt
+Keywords: 
+
+
+
--- /dev/null
+++ mod/{arch}/cryptsetup/cryptsetup--debian-noprompt/cryptsetup--debian-noprompt--0/[EMAIL PROTECTED]/patch-log/patch-5
@@ -0,0 +1,12 @@
+Revision: cryptsetup--debian-noprompt--0--patch-5
+Archive: [EMAIL PROTECTED]
+Creator: Andres Salomon <[EMAIL PROTECTED]>
+Date: Sun Apr 10 13:35:22 EDT 2005
+Standard-date: 2005-04-10 17:35:22 GMT
+Modified-files: cryptdisks
+New-patches: [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--patch-5
+Summary: typo fix; s/text/test/
+Keywords: 
+
+
+
--- /dev/null
+++ mod/{arch}/cryptsetup/cryptsetup--debian-noprompt/cryptsetup--debian-noprompt--0/[EMAIL PROTECTED]/patch-log/patch-6
@@ -0,0 +1,12 @@
+Revision: cryptsetup--debian-noprompt--0--patch-6
+Archive: [EMAIL PROTECTED]
+Creator: Andres Salomon <[EMAIL PROTECTED]>
+Date: Sun Apr 10 13:37:40 EDT 2005
+Standard-date: 2005-04-10 17:37:40 GMT
+Modified-files: cryptdisks cryptdisks.prompt
+New-patches: [EMAIL PROTECTED]/cryptsetup--debian-noprompt--0--patch-6
+Summary: update wording
+Keywords: 
+
+
+

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to