summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-06-29 14:36:37 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-09 22:07:52 +0200
commit880a599e262b9193219e612d827b35bb0c292dae (patch)
treecc98a4cdfec0b535afd79786b45cb64d7a7f91c2 /src
parent2be7287b0eb88ec7ebc3117e59554c2f6e7ac9e4 (diff)
cryptsetup: add keyfile-offset= support
This is useful if your keyfile is a block device, and you want to use a specific part of it, such as an area between the MBR and the first partition. This feature is documented in the Arch wiki[0], and has been supported by the Arch initscripts, so would be nice to get this into systemd. This requires libcryptsetup >= 1.4.2 (released 12.4.2012). Acked-by: Paul Menzel <paulepanter@users.sourceforge.net> [0]: <https://wiki.archlinux.org/index.php/System_Encryption_with_LUKS# Storing_the_key_between_MBR_and_1st_partition>
Diffstat (limited to 'src')
-rw-r--r--src/cryptsetup/cryptsetup.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index b26fcca836..f570724b9d 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -37,6 +37,7 @@
static const char *opt_type = NULL; /* LUKS1 or PLAIN */
static char *opt_cipher = NULL;
static unsigned opt_key_size = 0;
+static unsigned opt_keyfile_offset = 0;
static char *opt_hash = NULL;
static unsigned opt_tries = 0;
static bool opt_readonly = false;
@@ -79,6 +80,13 @@ static int parse_one_option(const char *option) {
return 0;
}
+ } else if (startswith(option, "keyfile-offset=")) {
+
+ if (safe_atou(option+15, &opt_keyfile_offset) < 0) {
+ log_error("keyfile-offset= parse failure, ignoring.");
+ return 0;
+ }
+
} else if (startswith(option, "hash=")) {
char *t;
@@ -462,7 +470,8 @@ int main(int argc, char *argv[]) {
argv[3]);
if (key_file)
- k = crypt_activate_by_keyfile(cd, argv[2], CRYPT_ANY_SLOT, key_file, keyfile_size, flags);
+ k = crypt_activate_by_keyfile_offset(cd, argv[2], CRYPT_ANY_SLOT, key_file, keyfile_size,
+ opt_keyfile_offset, flags);
else {
char **p;