Package: cryptsetup
Version: 2:1.0.5-2
Severity: wishlist

Hi: it would be nice if there was a tool in cryptsetup to start a
mapping from the crypttab on demand (like how mount parses
/etc/crypttab). Here's my first stab at this (attached).

If you like the idea I can develop it a bit (different name, manpage,
etc.) and submit upstream.


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16.29-xen
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
#! /bin/sh /usr/share/dpatch/dpatch-run

## 06_add_cryptsetup_start.dpatch
## by Jon Dowland <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: add "cryptsetup_start"; parses /etc/cryptsetup and starts one entry
## DP: cryptdisks.functions: generalize the cryptsetup line-parsing code

@DPATCH@

--- cryptsetup-1.0.5.orig/cryptsetup_start
+++ cryptsetup-1.0.5/cryptsetup_start
@@ -0,0 +1,20 @@
+#!/bin/sh
+# set -u - cryptdisks.functions doesn't handle this
+set -e
+
+if [ $# -lt 1 ]; then
+       echo "usage: $0 crypt_name <name>" >&2
+       echo >&2
+       echo "reads /etc/crypttab and starts the mapping corresponding to 
<name>" >&2
+       exit 1
+fi
+
+. /lib/cryptsetup/cryptdisks.functions
+
+egrep -v "^[[:space:]]*(#|$)" "$TABFILE" | while read dst src key opts; do
+
+       if [ "$1" == "$dst" ]; then
+               handle_crypttab_line "$dst" "$src" "$key" "$opts"
+               exit
+       fi
+done
--- cryptsetup-1.0.5/debian/cryptdisks.functions        2007-10-18 
14:33:51.000000000 +0100
+++ /lib/cryptsetup/cryptdisks.functions        2007-10-18 14:34:50.000000000 
+0100
@@ -391,17 +391,12 @@
        return $?
 }
 
-# Sets up all entries in crypttab
-do_start () {
-       local dst src key opts result
-
-       modprobe -qb dm-mod || true
-       modprobe -qb dm-crypt || true
-       dmsetup mknodes > /dev/null 2>&1 || true
-       log_action_begin_msg "Starting $INITSTATE crypto disks"
-       mount_fs
-
-       egrep -v "^[[:space:]]*(#|$)" "$TABFILE" | while read dst src key opts; 
do
+# setup a line from the crypttab
+handle_crypttab_line() {
+               dst=$1
+               src=$2
+               key=$3
+               opts=$4
 
                # Make sure that all fields are present
                if [ -z "$dst" ]; then
@@ -453,6 +448,20 @@
                        do_tmp
                        log_progress_msg "$dst (started)"
                fi
+}
+
+# Sets up all entries in crypttab
+do_start () {
+       local dst src key opts result
+
+       modprobe -qb dm-mod || true
+       modprobe -qb dm-crypt || true
+       dmsetup mknodes > /dev/null 2>&1 || true
+       log_action_begin_msg "Starting $INITSTATE crypto disks"
+       mount_fs
+
+       egrep -v "^[[:space:]]*(#|$)" "$TABFILE" | while read dst src key opts; 
do
+               handle_crypttab_line "$dst" "$src" "$key" "$opts"
        done
 
        umount_fs
--- cryptsetup-1.0.5/debian/rules       2007-10-18 14:44:10.000000000 +0100
+++ cryptsetup-1.0.5/debian/rules       2007-10-18 14:44:27.000000000 +0100
@@ -100,6 +100,7 @@
 
        $(MAKE) DESTDIR=$(CURDIR)/debian/cryptsetup install
        cp src/cryptsetup.static $(CURDIR)/debian/cryptsetup/sbin/cryptsetup
+       cp cryptsetup_start $(CURDIR)/debian/cryptsetup/sbin/cryptsetup_start
 
        install -m 0644 debian/cryptdisks.functions 
$(CURDIR)/debian/cryptsetup/lib/cryptsetup/
        install -m 0755 debian/checks/* 
$(CURDIR)/debian/cryptsetup/lib/cryptsetup/checks/

Reply via email to