valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0663-cryptsetup-generator-allow-whitespace-characters-in-.patch

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