Skip to content

Instantly share code, notes, and snippets.

@ryancdotorg
Created December 25, 2011 02:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryancdotorg/1518656 to your computer and use it in GitHub Desktop.
Save ryancdotorg/1518656 to your computer and use it in GitHub Desktop.
patch to the cryptroot hook that comes with cryptsetup on debian/ubuntu
--- cryptroot.dist 2011-12-24 16:50:11.000000000 -0800
+++ cryptroot 2011-12-24 17:07:33.000000000 -0800
@@ -211,7 +211,7 @@
fi
# We have all the basic options, let's go trough them
- OPTIONS="target=$target,source=$source,key=$key"
+ OPTIONS="target=$target,source=$source"
local IFS=", "
unset HASH_FOUND
unset LUKS_FOUND
@@ -262,10 +262,23 @@
echo " the correct hash option to your /etc/crypttab." >&2
fi
- # If keyscript is set, the "key" is just an argument to the script
- if [ "$key" != "none" ] && [ -z "$KEYSCRIPT" ]; then
- echo "cryptsetup: WARNING: target $target uses a key file, skipped" >&2
- return 1
+ # A "key" is only supported if it is being used with a keyscript
+ if [ "$key" != "none" ]; then
+ if [ -n "$KEYSCRIPT" ]; then
+ # Include the "key" if it is a regular file
+ if [ -f "$key" ]; then
+ KEYFILE=$key
+ key="/lib/cryptsetup/keys/$(basename "$key")"
+ elif [ "$(echo $key | cut -c 1)" = "/" ]; then
+ # Not sure if this should be fatal
+ echo "cryptsetup: WARNING: key file $key for target $target cannot be copied" >&2
+ fi
+ OPTIONS="$OPTIONS,key=$key"
+ else
+ OPTIONS="$OPTIONS,key=$key"
+ echo "cryptsetup: WARNING: target $target uses a key file, skipped" >&2
+ return 1
+ fi
fi
}
@@ -408,6 +421,12 @@
echo "cryptsetup: WARNING: failed to find keyscript $KEYSCRIPT" >&2
continue
fi
+ if [ -n "$KEYFILE" ]; then
+ if [ ! -d "$DESTDIR/lib/cryptsetup/keys" ]; then
+ mkdir -p "$DESTDIR/lib/cryptsetup/keys"
+ fi
+ cp "$KEYFILE" "$DESTDIR/lib/cryptsetup/keys"
+ fi
fi
# Calculate needed modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment