[systemd-devel] [PATCH V2] cryptsetup: ask for password, if key file cannot be accessed

harald at redhat.com harald at redhat.com
Thu Apr 18 00:41:23 PDT 2013


From: Harald Hoyer <harald at redhat.com>

If the key file cannot be accessed, we can at least ask for the
password.
---

Remove access() call and check the return value of crypt_activate_by_keyfile_offset()

 src/cryptsetup/cryptsetup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 376f748..a24e61a 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -500,6 +500,11 @@ int main(int argc, char *argv[]) {
                         if (key_file)
                                 k = crypt_activate_by_keyfile_offset(cd, argv[2], CRYPT_ANY_SLOT, key_file, opt_keyfile_size,
                                             opt_keyfile_offset, flags);
+                                if (k < 0) {
+                                        log_error("Failed to activate with key file '%s': %s", key_file, strerror(-k));
+                                        key_file = NULL;
+                                        continue;
+                                }
                         else {
                                 char **p;
 
-- 
1.8.2



More information about the systemd-devel mailing list