summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-09-30 01:35:24 +0000
committerMike Frysinger <vapier@gentoo.org>2010-09-30 01:35:24 +0000
commit0f1d0360a31bbe0e9d036949f5cc12e8668ea448 (patch)
treeae4cf3dbece5a96140ea58ef15f9b22162571699 /sys-fs/cryptsetup
parentMarking ruby-romkan-0.4-r2 ppc64 for bug 329265 (diff)
downloadhistorical-0f1d0360a31bbe0e9d036949f5cc12e8668ea448.tar.gz
historical-0f1d0360a31bbe0e9d036949f5cc12e8668ea448.tar.bz2
historical-0f1d0360a31bbe0e9d036949f5cc12e8668ea448.zip
Update by Wolfram to let the init.d scripts be multiplexed #338876.
Package-Manager: portage-2.2_rc86/cvs/Linux x86_64
Diffstat (limited to 'sys-fs/cryptsetup')
-rw-r--r--sys-fs/cryptsetup/ChangeLog9
-rw-r--r--sys-fs/cryptsetup/Manifest15
-rw-r--r--sys-fs/cryptsetup/cryptsetup-1.1.3-r1.ebuild91
-rw-r--r--sys-fs/cryptsetup/files/1.1.3-dm-crypt-start.sh292
-rw-r--r--sys-fs/cryptsetup/files/1.1.3-dm-crypt-stop.sh43
5 files changed, 448 insertions, 2 deletions
diff --git a/sys-fs/cryptsetup/ChangeLog b/sys-fs/cryptsetup/ChangeLog
index 88525528edbe..cce2ba9979f3 100644
--- a/sys-fs/cryptsetup/ChangeLog
+++ b/sys-fs/cryptsetup/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for sys-fs/cryptsetup
# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-fs/cryptsetup/ChangeLog,v 1.94 2010/08/28 19:13:14 armin76 Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/cryptsetup/ChangeLog,v 1.95 2010/09/30 01:35:24 vapier Exp $
+
+*cryptsetup-1.1.3-r1 (30 Sep 2010)
+
+ 30 Sep 2010; Mike Frysinger <vapier@gentoo.org>
+ +files/1.1.3-dm-crypt-start.sh, +cryptsetup-1.1.3-r1.ebuild,
+ +files/1.1.3-dm-crypt-stop.sh:
+ Update by Wolfram to let the init.d scripts be multiplexed #338876.
28 Aug 2010; Raúl Porcel <armin76@gentoo.org> cryptsetup-1.1.2.ebuild:
ia64/s390/sh/sparc stable wrt #327689
diff --git a/sys-fs/cryptsetup/Manifest b/sys-fs/cryptsetup/Manifest
index 4037b2f89210..14c9cc88319c 100644
--- a/sys-fs/cryptsetup/Manifest
+++ b/sys-fs/cryptsetup/Manifest
@@ -1,3 +1,6 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA256
+
AUX 1.0.5-dm-crypt-start.sh 8298 RMD160 858f607fe1a2036430f972dbbc643c178baf96f7 SHA1 00c7380894d30842c01ef18ed3e14114cf1da36b SHA256 8c9f4a502dfb20e1a6c656a9563da539dbe8d1aeeb3517bc34bf14a7d301f201
AUX 1.0.5-dm-crypt-stop.sh 1022 RMD160 c74d4fffec325378bb008b28c4225b67577c1d1b SHA1 d7b18d4d4845540baecdde373942cc8966c3d5e3 SHA256 42015047c708aa73eae615559ff76c9c8948a5d01fba68f64c5432e30ec799a4
AUX 1.0.5-dmcrypt.confd 3029 RMD160 c84d92a58923ce88a60ab1e8fcc88910b0689df6 SHA1 b006d7f31773842e7247b2df0fe1735aac87ec59 SHA256 b5ea27a1034dda22b287422097e30e99a0673bd6a3148e38b1c2310bdcc28280
@@ -6,6 +9,8 @@ AUX 1.0.6-dmcrypt.confd 3309 RMD160 23a1a91ae2b2fd4d743bf8e0427cf40e4b24ecd8 SHA
AUX 1.0.6-r2-dm-crypt-start.sh 8092 RMD160 d61f1cf13e75c105065f8ca6c6a9afe12eedbcaa SHA1 fc4b6580063cd3758ada2d1ddfced3e005c8fabf SHA256 56004bef91b8fad57fe67fec19427dd7c48e01c8e1ba7ff60f8c370295775fdc
AUX 1.1.0-libudev.patch 964 RMD160 362e8bf35a2f6c022404f515811befa80121e779 SHA1 fd70e437a50a04ee6b37e8c36cee75aa9fa59e8c SHA256 02529608ee3743ada736ae3a6205c363cb1777ca5d72c5824287ec99fe9fe5f7
AUX 1.1.0_rc3-static-no-selinux.patch 813 RMD160 a9e476edd9bfe12e4663962198e3ed28f43877a3 SHA1 f26e3e356848d098c70f0857a04945fb264ae844 SHA256 7ec5067c5b05b478f45cdd35953827e4696011104f533b3339d18c4becc1985a
+AUX 1.1.3-dm-crypt-start.sh 8056 RMD160 abde93caba4baa0c19f2b06f56124267f1e45d2f SHA1 cd95a1babad12d2e33ede83ad9fb8f473fed8978 SHA256 848d6ebbf4b66b5b11cc7e0485f4ff0bfb6386fcf1042fa598f682471d92aad1
+AUX 1.1.3-dm-crypt-stop.sh 1107 RMD160 6920a2f701f7c80adafa6a10918e51d896867faa SHA1 81ece35ca41bae4d1737c706de1b07cc8a530773 SHA256 497c381871d38de1d47052c08c89e42b9489784c5f878472303a4bdaf402e450
AUX cryptfs.confd 1337 RMD160 f98acce860d95d69e8e95d9bab32ba5bb5bef421 SHA1 5e7b239e549b6def07af968d02b300ec36d8aac1 SHA256 8c8e815297eb20140ae7d4d555d3bfdd373ad368adf179841516430da370505c
AUX cryptsetup-1.0.6-udevsettle.patch 561 RMD160 613da67876c1c20c3ea3687ec425b31551ae57d1 SHA1 cd0177fa53f4d6f605522f53a98c57286162859f SHA256 80c4914071769dedc20198425b4ea528ec22264ff4c54516a9e5722a8e671f60
AUX cryptsetup-libmapper.patch 297 RMD160 1f5a19f125147797db69f4fb75d6abe36743d52b SHA1 e198368263d1635d30d27c87ed45deb23fac2f06 SHA256 c66c178fe949ceccd82d64f5acc8288e0486014dcfbc4fc6f4a0bf6c62bf4cc8
@@ -18,6 +23,14 @@ DIST cryptsetup-1.1.3.tar.bz2 499276 RMD160 bf2e724779174a3cd6ce9d592e17c70979f2
EBUILD cryptsetup-0.1-r3.ebuild 1882 RMD160 cba167af414ab6349b172c5c8d6449ba7228458a SHA1 f9a70a151fdd2cb7e3591514f583c066e4899c0b SHA256 ffee91a66e88d879e3f6bfee3ab97e97b6735315e0d9c81d8b2ec005dcf8d473
EBUILD cryptsetup-1.0.6-r2.ebuild 3150 RMD160 997496f32ffb972a4d21efb80cb0ccedf2a53197 SHA1 8cbe4f6a69a72faf4916f1992a4ee3febd04114e SHA256 cad92c053518bb11a2acd9e806e471117c462187c8a02f5258e933e093ab2a66
EBUILD cryptsetup-1.1.2.ebuild 3387 RMD160 85af8bf703ba0de8e0d551e13d38ea50c8ffe0ee SHA1 84cb3dda0a0171cf8521def6553c41244268d12e SHA256 c35b0a8a6f8ec3d6269d9d5f187811bcb5d336719b28566a53829c9adeeaeb37
+EBUILD cryptsetup-1.1.3-r1.ebuild 3153 RMD160 85b5644a340943d6a3c35698ea16c4852ab1220b SHA1 995b80ae8fca61d0fac9cba0fe78afba405505b4 SHA256 041645e8c23e7f0f5defbcb38f3de8da8467561c63b0adb269cbddfabc8aa936
EBUILD cryptsetup-1.1.3.ebuild 3397 RMD160 40eab87e9d566cf807d7d7c1d274cb82a3f19812 SHA1 0bcbb75cf10c9221432b8aae34d67993bbe74ea3 SHA256 1270c0f6df14ffb46cb97760863743160ae1520e18c133a2969661e9a3b1d1e4
-MISC ChangeLog 13535 RMD160 5493c0194f6a472de71cd6e58b86f4db46801f3e SHA1 91b718a7c6a8199f1f10f2f9a23ffe83a3a6d4ce SHA256 cde60d87f4c7c5d2fe7e3fee9f2a3077f13449fa523eb832a26b9538b6eadf19
+MISC ChangeLog 13787 RMD160 3405f94fe4c89e0af838e931a259615f164d46b1 SHA1 ff6d52a5619c132811ec705e4ed6528a188d318a SHA256 59fd9de5794f7f1ed6614e4d0597b8e2b1f18b0673c32c396bf221a8593811e4
MISC metadata.xml 239 RMD160 81512c49e64b6e70c7b746ba09d3e6fce4c7bc89 SHA1 c4085a72e46fe6bcea5bdff780007791eae6db4b SHA256 aebd5282fb892100f348eba1ed27edd27e7296356897c6f5314674f8abb4b51a
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2.0.16 (GNU/Linux)
+
+iF4EAREIAAYFAkyj6UQACgkQTwhj9JtAlp5dDwD+KYybzvDsNrqYXyy2KTHDSdeI
+l/BjtQqG6Ee2ga5MCdsBALRDr7b4idamYUFCoZzlYEKkEUpngYRwtnLp+39g2VqN
+=JrE7
+-----END PGP SIGNATURE-----
diff --git a/sys-fs/cryptsetup/cryptsetup-1.1.3-r1.ebuild b/sys-fs/cryptsetup/cryptsetup-1.1.3-r1.ebuild
new file mode 100644
index 000000000000..ce7607c0f0cb
--- /dev/null
+++ b/sys-fs/cryptsetup/cryptsetup-1.1.3-r1.ebuild
@@ -0,0 +1,91 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/cryptsetup/cryptsetup-1.1.3-r1.ebuild,v 1.1 2010/09/30 01:35:24 vapier Exp $
+
+EAPI="2"
+
+inherit linux-info eutils multilib libtool
+
+MY_P=${P/_rc/-rc}
+DESCRIPTION="Tool to setup encrypted devices with dm-crypt"
+HOMEPAGE="http://code.google.com/p/cryptsetup/"
+SRC_URI="http://cryptsetup.googlecode.com/files/${MY_P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
+IUSE="dynamic nls selinux"
+
+S=${WORKDIR}/${MY_P}
+
+DEPEND=">=sys-fs/lvm2-2.02.64
+ >=dev-libs/libgcrypt-1.1.42
+ >=dev-libs/libgpg-error-1.0-r1
+ >=dev-libs/popt-1.7
+ >=sys-fs/udev-124
+ || ( >=sys-libs/e2fsprogs-libs-1.41 <sys-fs/e2fsprogs-1.41 )
+ selinux? ( sys-libs/libselinux )
+ !sys-fs/cryptsetup-luks"
+
+pkg_setup() {
+ local CONFIG_CHECK="~DM_CRYPT ~CRYPTO ~CRYPTO_CBC"
+ local WARNING_DM_CRYPT="CONFIG_DM_CRYPT:\tis not set (required for cryptsetup)\n"
+ local WARNING_CRYPTO_CBC="CONFIG_CRYPTO_CBC:\tis not set (required for kernel 2.6.19)\n"
+ local WARNING_CRYPTO="CONFIG_CRYPTO:\tis not set (required for cryptsetup)\n"
+ check_extra_config
+
+ if use dynamic ; then
+ ewarn "If you need cryptsetup for an initrd or initramfs then you"
+ ewarn "should NOT use the dynamic USE flag"
+ epause 5
+ fi
+}
+
+src_prepare() {
+ elibtoolize
+}
+
+src_configure() {
+ econf \
+ --sbindir=/sbin \
+ --enable-shared \
+ $(use_enable !dynamic static) \
+ --libdir=/usr/$(get_libdir) \
+ $(use_enable nls) \
+ $(use_enable selinux)
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die
+ dodoc TODO ChangeLog # README NEWS # last ones are empty
+
+ insinto /$(get_libdir)/rcscripts/addons
+ newins "${FILESDIR}"/1.1.3-dm-crypt-start.sh dm-crypt-start.sh || die
+ newins "${FILESDIR}"/1.1.3-dm-crypt-stop.sh dm-crypt-stop.sh || die
+ newconfd "${FILESDIR}"/1.0.6-dmcrypt.confd dmcrypt || die
+ newinitd "${FILESDIR}"/1.0.5-dmcrypt.rc dmcrypt || die
+}
+
+pkg_postinst() {
+ ewarn "This ebuild introduces a new set of scripts and configuration"
+ ewarn "than the last version. If you are currently using /etc/conf.d/cryptfs"
+ ewarn "then you *MUST* copy your old file to:"
+ ewarn "/etc/conf.d/dmcrypt"
+ ewarn "Or your encrypted partitions will *NOT* work."
+ elog "Please see the example for configuring a LUKS mountpoint"
+ elog "in /etc/conf.d/dmcrypt"
+ elog
+ elog "If you are using baselayout-2 then please do:"
+ elog "rc-update add dmcrypt boot"
+ elog "This version introduces a command line arguement 'key_timeout'."
+ elog "If you want the search for the removable key device to timeout"
+ elog "after 10 seconds add the following to your bootloader config:"
+ elog "key_timeout=10"
+ elog "A timeout of 0 will mean it will wait indefinitely."
+ elog
+ elog "Users using cryptsetup-1.0.x (dm-crypt plain) volumes must use"
+ elog "a compatibility mode when using cryptsetup-1.1.x. This can be"
+ elog "done by specifying the cipher (-c), key size (-s) and hash (-h)."
+ elog "For more info, see http://code.google.com/p/cryptsetup/wiki/FrequentlyAskedQuestions#6._Issues_with_Specific_Versions_of_cryptsetup"
+
+}
diff --git a/sys-fs/cryptsetup/files/1.1.3-dm-crypt-start.sh b/sys-fs/cryptsetup/files/1.1.3-dm-crypt-start.sh
new file mode 100644
index 000000000000..084701c33750
--- /dev/null
+++ b/sys-fs/cryptsetup/files/1.1.3-dm-crypt-start.sh
@@ -0,0 +1,292 @@
+# /lib/rcscripts/addons/dm-crypt-start.sh
+
+# For backwards compatability with baselayout < 1.13.0
+: ${SVCNAME:=${myservice}} #174256
+dm_crypt_execute_checkfs() {
+ dm_crypt_execute_dmcrypt
+}
+
+dm_crypt_execute_volumes() {
+ dm_crypt_execute_dmcrypt
+}
+
+# Setup mappings for an individual target/swap
+# Note: This relies on variables localized in the main body below.
+dm_crypt_execute_dmcrypt() {
+ local dev ret mode foo
+ # some colors
+ local red='\x1b[31;01m' green='\x1b[32;01m' off='\x1b[0;0m'
+
+ if [ -n "$target" ]; then
+ # let user set options, otherwise leave empty
+ : ${options:=' '}
+ elif [ -n "$swap" ]; then
+ einfo "Checking swap is not LUKS"
+ cryptsetup isLuks ${source} 2>/dev/null
+ foo="$?"
+ if [ "${foo}" -eq 0 ]; then
+ ewarn "The swap you have defined is a LUKS partition. Aborting crypt-swap setup."
+ return
+ fi
+ target=${swap}
+ # swap contents do not need to be preserved between boots, luks not required.
+ # suspend2 users should have initramfs's init handling their swap partition either way.
+ : ${options:='-c aes -h sha1 -d /dev/urandom'}
+ : ${pre_mount:='mkswap ${dev}'}
+ else
+ return
+ fi
+ if [ -z "$source" ] && [ ! -e "$source" ]; then
+ ewarn "source \"${source}\" for ${target} missing, skipping..."
+ return
+ fi
+
+ if [[ -n ${loop_file} ]] ; then
+ dev="/dev/mapper/${target}"
+ ebegin " Setting up loop device ${source}"
+ /sbin/losetup ${source} ${loop_file}
+ fi
+
+ # cryptsetup:
+ # luksOpen <device> <name> # <device> is $source
+ # create <name> <device> # <name> is $target
+ local arg1="create" arg2="$target" arg3="$source" luks=0
+
+ cryptsetup isLuks ${source} 2>/dev/null && { arg1="luksOpen"; arg2="$source"; arg3="$target"; luks=1; }
+
+ if /sbin/cryptsetup status ${target} | egrep -q '\<active:' ; then
+ einfo "dm-crypt mapping ${target} is already configured"
+ return
+ fi
+ splash svc_input_begin ${SVCNAME} >/dev/null 2>&1
+
+ # Handle keys
+ if [ -n "$key" ]; then
+ read_abort() {
+ local ans
+ local prompt=" ${green}*${off} $1? (${red}yes${off}/${green}No${off}) "
+ shift
+ echo -n -e "${prompt}"
+ if ! read -n 1 $* ans ; then
+ local back=${prompt//?/\\b}
+ echo -n -e "${back}"
+ else
+ echo
+ fi
+ case $ans in
+ [yY]|[yY][eE][sS]) return 0;;
+ *) return 1;;
+ esac
+ }
+
+ # Notes: sed not used to avoid case where /usr partition is encrypted.
+ mode=${key/*:/} && ( [ "$mode" == "$key" ] || [ -z "$mode" ] ) && mode=reg
+ key=${key/:*/}
+ case "$mode" in
+ gpg|reg)
+ # handle key on removable device
+ if [ -n "$remdev" ]; then
+ # temp directory to mount removable device
+ local mntrem="${RC_SVCDIR}/dm-crypt-remdev.$$"
+ if [ ! -d "${mntrem}" ] ; then
+ if ! mkdir -p "${mntrem}" ; then
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: Unable to create temporary mount point '${mntrem}'"
+ return
+ fi
+ fi
+ i=0
+ einfo "Please insert removable device for ${target}"
+ while [ ${i} -lt ${dmcrypt_max_timeout:-120} ] ; do
+ foo=""
+ if mount -n -o ro "${remdev}" "${mntrem}" 2>/dev/null >/dev/null ; then
+ # keyfile exists?
+ if [ ! -e "${mntrem}${key}" ]; then
+ umount -n "${mntrem}"
+ rmdir "${mntrem}"
+ einfo "Cannot find ${key} on removable media."
+ read_abort "Abort" ${read_timeout:--t 1} && return
+ else
+ key="${mntrem}${key}"
+ break
+ fi
+ else
+ [ -e "${remdev}" ] \
+ && foo="mount failed" \
+ || foo="mount source not found"
+ fi
+ ((++i))
+ read_abort "Stop waiting after $i attempts (${foo})" -t 1 && return
+ done
+ else # keyfile ! on removable device
+ if [ ! -e "$key" ]; then
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: keyfile ${key} does not exist."
+ return
+ fi
+ fi
+ ;;
+ *)
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: mode ${mode} is invalid."
+ return
+ ;;
+ esac
+ else
+ mode=none
+ fi
+ ebegin "dm-crypt map ${target}"
+ einfo "cryptsetup will be called with : ${options} ${arg1} ${arg2} ${arg3}"
+ if [ "$mode" == "gpg" ]; then
+ : ${gpg_options:='-q -d'}
+ # gpg available ?
+ if type -p gpg >/dev/null ; then
+ for (( i = 0 ; i < 3 ; i++ ))
+ do
+ # paranoid, don't store key in a variable, pipe it so it stays very little in ram unprotected.
+ # save stdin stdout stderr "values"
+ gpg ${gpg_options} ${key} 2>/dev/null | cryptsetup ${options} ${arg1} ${arg2} ${arg3}
+ ret="$?"
+ [ "$ret" -eq 0 ] && break
+ done
+ eend "${ret}" "failure running cryptsetup"
+ else
+ ewarn "${source} will not be decrypted ..."
+ einfo "Reason: cannot find gpg application."
+ einfo "You have to install app-crypt/gnupg first."
+ einfo "If you have /usr on its own partition, try copying gpg to /bin ."
+ fi
+ else
+ if [ "$mode" == "reg" ]; then
+ cryptsetup ${options} -d ${key} ${arg1} ${arg2} ${arg3}
+ ret="$?"
+ eend "${ret}" "failure running cryptsetup"
+ else
+ cryptsetup ${options} ${arg1} ${arg2} ${arg3}
+ ret="$?"
+ eend "${ret}" "failure running cryptsetup"
+ fi
+ fi
+ if [ -d "$mntrem" ]; then
+ umount -n ${mntrem} 2>/dev/null >/dev/null
+ rmdir ${mntrem} 2>/dev/null >/dev/null
+ fi
+ splash svc_input_end ${SVCNAME} >/dev/null 2>&1
+
+ if [[ ${ret} != 0 ]] ; then
+ cryptfs_status=1
+ else
+ if [[ -n ${pre_mount} ]] ; then
+ dev="/dev/mapper/${target}"
+ ebegin " Running pre_mount commands for ${target}"
+ eval "${pre_mount}" > /dev/null
+ ewend $? || cryptfs_status=1
+ fi
+ fi
+}
+
+# Run any post_mount commands for an individual mount
+#
+# Note: This relies on variables localized in the main body below.
+dm_crypt_execute_localmount() {
+ local mount_point
+
+ [ -z "$target" ] && [ -z "$post_mount" ] && return
+
+ if ! /sbin/cryptsetup status ${target} | egrep -q '\<active:' ; then
+ ewarn "Skipping unmapped target ${target}"
+ cryptfs_status=1
+ return
+ fi
+
+ mount_point=$(grep "/dev/mapper/${target}" /proc/mounts | cut -d' ' -f2)
+ if [[ -z ${mount_point} ]] ; then
+ ewarn "Failed to find mount point for ${target}, skipping"
+ cryptfs_status=1
+ fi
+
+ if [[ -n ${post_mount} ]] ; then
+ ebegin "Running post_mount commands for target ${target}"
+ eval "${post_mount}" >/dev/null
+ eend $? || cryptfs_status=1
+ fi
+}
+
+# Determine string lengths
+strlen() {
+ if [ -z "$1" ]
+ then
+ echo "usage: strlen <variable_name>"
+ die
+ fi
+ eval echo "\${#${1}}"
+}
+
+# Lookup optional bootparams
+parse_opt() {
+ case "$1" in
+ *\=*)
+ local key_name="`echo "$1" | cut -f1 -d=`"
+ local key_len=`strlen key_name`
+ local value_start=$((key_len+2))
+ echo "$1" | cut -c ${value_start}-
+ ;;
+ esac
+}
+
+local cryptfs_status=0
+local gpg_options key loop_file target targetline options pre_mount post_mount source swap remdev
+
+CMDLINE="`cat /proc/cmdline`"
+for x in ${CMDLINE}
+do
+ case "${x}" in
+ key_timeout\=*)
+ KEY_TIMEOUT=`parse_opt "${x}"`
+ if [ ${KEY_TIMEOUT} -gt 0 ]; then
+ read_timeout="-t ${KEY_TIMEOUT}"
+ fi
+ ;;
+ esac
+done
+
+if [[ -f /etc/conf.d/${SVCNAME} ]] && [[ -x /sbin/cryptsetup ]] ; then
+ ebegin "Setting up dm-crypt mappings"
+
+ while read -u 3 targetline ; do
+ # skip comments and blank lines
+ [[ ${targetline}\# == \#* ]] && continue
+
+ # check for the start of a new target/swap
+ case ${targetline} in
+ target=*|swap=*)
+ # If we have a target queued up, then execute it
+ dm_crypt_execute_${SVCNAME%.*}
+
+ # Prepare for the next target/swap by resetting variables
+ unset gpg_options key loop_file target options pre_mount post_mount source swap remdev
+ ;;
+
+ gpg_options=*|remdev=*|key=*|loop_file=*|options=*|pre_mount=*|post_mount=*|source=*)
+ if [[ -z ${target} && -z ${swap} ]] ; then
+ ewarn "Ignoring setting outside target/swap section: ${targetline}"
+ continue
+ fi
+ ;;
+
+ *)
+ ewarn "Skipping invalid line in /etc/conf.d/${SVCNAME}: ${targetline}"
+ ;;
+ esac
+
+ # Queue this setting for the next call to dm_crypt_execute_${SVCNAME%.*}
+ eval "${targetline}"
+ done 3< /etc/conf.d/${SVCNAME}
+
+ # If we have a target queued up, then execute it
+ dm_crypt_execute_${SVCNAME%.*}
+
+ ewend ${cryptfs_status} "Failed to setup dm-crypt devices"
+fi
+
+# vim:ts=4
diff --git a/sys-fs/cryptsetup/files/1.1.3-dm-crypt-stop.sh b/sys-fs/cryptsetup/files/1.1.3-dm-crypt-stop.sh
new file mode 100644
index 000000000000..138688bced2e
--- /dev/null
+++ b/sys-fs/cryptsetup/files/1.1.3-dm-crypt-stop.sh
@@ -0,0 +1,43 @@
+# /lib/rcscripts/addons/dm-crypt-stop.sh
+
+# Fix for baselayout-1.12.10 (bug 174256)
+: ${SVCNAME:=${myservice}}
+
+# Try to remove any dm-crypt mappings
+csetup=/sbin/cryptsetup
+if [ -f /etc/conf.d/${SVCNAME} ] && [ -x "$csetup" ]
+then
+ einfo "Removing dm-crypt mappings"
+
+ /bin/egrep "^(target|swap)" /etc/conf.d/${SVCNAME} | \
+ while read targetline
+ do
+ target=
+ swap=
+
+ eval ${targetline}
+
+ [ -n "${swap}" ] && target=${swap}
+ [ -z "${target}" ] && ewarn "Invalid line in /etc/conf.d/${SVCNAME}: ${targetline}"
+
+ ebegin "Removing dm-crypt mapping for: ${target}"
+ ${csetup} remove ${target}
+ eend $? "Failed to remove dm-crypt mapping for: ${target}"
+ done
+
+ if [[ -n $(/bin/egrep -e "^(source=)./dev/loop*" /etc/conf.d/${SVCNAME}) ]] ; then
+ einfo "Taking down any dm-crypt loop devices"
+ /bin/egrep -e "^(source)" /etc/conf.d/${SVCNAME} | while read sourceline
+ do
+ source=
+ eval ${sourceline}
+ if [[ -n $(echo ${source} | grep /dev/loop) ]] ; then
+ ebegin " Taking down ${source}"
+ /sbin/losetup -d ${source}
+ eend $? " Failed to remove loop"
+ fi
+ done
+ fi
+fi
+
+# vim:ts=4