dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
c2dfb7
From ed282d8d84fa32aaef21994d92d1d3dbfa281094 Mon Sep 17 00:00:00 2001
c2dfb7
From: Ryan Gonzalez <kirbyfan64@users.noreply.github.com>
c2dfb7
Date: Fri, 22 Feb 2019 23:45:03 -0600
c2dfb7
Subject: [PATCH] cryptsetup: Treat key file errors as a failed password
c2dfb7
 attempt
c2dfb7
c2dfb7
6f177c7dc092eb68762b4533d41b14244adb2a73 caused key file errors to immediately fail, which would make it hard to correct an issue due to e.g. a crypttab typo or a damaged key file.
c2dfb7
c2dfb7
Closes #11723.
c2dfb7
c2dfb7
(cherry picked from commit c20db3887569e0c0d9c0e2845c5286e7edf0133a)
c2dfb7
c2dfb7
Related: #1763155
c2dfb7
---
c2dfb7
 src/cryptsetup/cryptsetup.c | 4 ++++
c2dfb7
 1 file changed, 4 insertions(+)
c2dfb7
c2dfb7
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
c2dfb7
index 33c215eaa1..11162eb722 100644
c2dfb7
--- a/src/cryptsetup/cryptsetup.c
c2dfb7
+++ b/src/cryptsetup/cryptsetup.c
c2dfb7
@@ -558,6 +558,10 @@ static int attach_luks_or_plain(struct crypt_device *cd,
c2dfb7
                         log_error_errno(r, "Failed to activate with key file '%s'. (Key data incorrect?)", key_file);
c2dfb7
                         return -EAGAIN; /* Log actual error, but return EAGAIN */
c2dfb7
                 }
c2dfb7
+                if (r == -EINVAL) {
c2dfb7
+                        log_error_errno(r, "Failed to activate with key file '%s'. (Key file missing?)", key_file);
c2dfb7
+                        return -EAGAIN; /* Log actual error, but return EAGAIN */
c2dfb7
+                }
c2dfb7
                 if (r < 0)
c2dfb7
                         return log_error_errno(r, "Failed to activate with key file '%s': %m", key_file);
c2dfb7
         } else {