Created
December 9, 2014 12:55
-
-
Save johnlane/31840508fdca094fac7e to your computer and use it in GitHub Desktop.
initrd support for crypt key file with offset and size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- encrypt_hook 2014-12-09 12:47:02.379911026 +0000 | |
+++ encrypt_hook 2014-12-09 12:47:41.416087076 +0000 | |
@@ -7,7 +7,7 @@ | |
# Get keyfile if specified | |
ckeyfile="/crypto_keyfile.bin" | |
if [ -n "$cryptkey" ]; then | |
- IFS=: read ckdev ckarg1 ckarg2 <<EOF | |
+ IFS=: read ckdev ckarg1 ckarg2 ckarg3 ckarg4 <<EOF | |
$cryptkey | |
EOF | |
@@ -18,9 +18,13 @@ | |
*[!0-9]*) | |
# Use a file on the device | |
# ckarg1 is not numeric: ckarg1=filesystem, ckarg2=path | |
+ # ckarg3=offset, ckarg4=length | |
mkdir /ckey | |
mount -r -t "$ckarg1" "$resolved" /ckey | |
- dd if="/ckey/$ckarg2" of="$ckeyfile" >/dev/null 2>&1 | |
+ [ -n "$ckarg3$ckarg4" ] && ckoffset="bs=1" | |
+ [ -n "$ckarg3" ] && ckoffset="$ckoffset skip=$ckarg3" | |
+ [ -n "$ckarg4" ] && ckoffset="$ckoffset count=$ckarg4" | |
+ dd if="/ckey/$ckarg2" of="$ckeyfile" $ckoffset >/dev/null 2>&1 | |
umount /ckey | |
;; | |
*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment