|
|
923a60 |
From afcf3919f5db85a00352a9937c9a5cb9c7b30269 Mon Sep 17 00:00:00 2001
|
|
|
923a60 |
From: Michal Sekletar <msekleta@redhat.com>
|
|
|
923a60 |
Date: Tue, 4 Sep 2018 20:03:34 +0200
|
|
|
923a60 |
Subject: [PATCH] cryptsetup-generator: allow whitespace characters in keydev
|
|
|
923a60 |
specification
|
|
|
923a60 |
|
|
|
923a60 |
For example, <luks.uuid>=/keyfile:LABEL="KEYFILE FS" previously wouldn't
|
|
|
923a60 |
work, because we truncated label at the first whitespace character,
|
|
|
923a60 |
i.e. LABEL="KEYFILE".
|
|
|
923a60 |
|
|
|
923a60 |
Related: #1619743
|
|
|
923a60 |
---
|
|
|
923a60 |
src/cryptsetup/cryptsetup-generator.c | 21 +++++++++++++++------
|
|
|
923a60 |
1 file changed, 15 insertions(+), 6 deletions(-)
|
|
|
923a60 |
|
|
|
923a60 |
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
|
|
|
923a60 |
index a9598180c6..7b90d26156 100644
|
|
|
923a60 |
--- a/src/cryptsetup/cryptsetup-generator.c
|
|
|
923a60 |
+++ b/src/cryptsetup/cryptsetup-generator.c
|
|
|
923a60 |
@@ -421,27 +421,36 @@ static int parse_proc_cmdline_item(const char *key, const char *value) {
|
|
|
923a60 |
return log_oom();
|
|
|
923a60 |
|
|
|
923a60 |
} else if (STR_IN_SET(key, "luks.key", "rd.luks.key") && value) {
|
|
|
923a60 |
+ int n;
|
|
|
923a60 |
|
|
|
923a60 |
- r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
|
|
|
923a60 |
- if (r == 2) {
|
|
|
923a60 |
+ r = sscanf(value, "%m[0-9a-fA-F-]=%n", &uuid, &n);
|
|
|
923a60 |
+ if (r == 1) {
|
|
|
923a60 |
char *c;
|
|
|
923a60 |
+ const char *keyspec;
|
|
|
923a60 |
_cleanup_free_ char *keyfile = NULL, *keydev = NULL;
|
|
|
923a60 |
|
|
|
923a60 |
d = get_crypto_device(uuid);
|
|
|
923a60 |
if (!d)
|
|
|
923a60 |
return log_oom();
|
|
|
923a60 |
|
|
|
923a60 |
- c = strrchr(uuid_value, ':');
|
|
|
923a60 |
+ keyspec = value + n;
|
|
|
923a60 |
+
|
|
|
923a60 |
+ c = strrchr(keyspec, ':');
|
|
|
923a60 |
if (!c) {
|
|
|
923a60 |
+ /* No keydev specified */
|
|
|
923a60 |
+ keyfile = strdup(keyspec);
|
|
|
923a60 |
+ if (!keyfile)
|
|
|
923a60 |
+ return log_oom();
|
|
|
923a60 |
+
|
|
|
923a60 |
free(d->keyfile);
|
|
|
923a60 |
- d->keyfile = uuid_value;
|
|
|
923a60 |
- uuid_value = NULL;
|
|
|
923a60 |
+ d->keyfile = keyfile;
|
|
|
923a60 |
+ keyfile = NULL;
|
|
|
923a60 |
|
|
|
923a60 |
return 0;
|
|
|
923a60 |
}
|
|
|
923a60 |
|
|
|
923a60 |
*c = '\0';
|
|
|
923a60 |
- keyfile = strdup(uuid_value);
|
|
|
923a60 |
+ keyfile = strdup(keyspec);
|
|
|
923a60 |
keydev = strdup(++c);
|
|
|
923a60 |
|
|
|
923a60 |
if (!keyfile || !keydev)
|