104 lines
2.6 KiB
Diff
104 lines
2.6 KiB
Diff
|
|
From b93b67633676e4b9ae627532774c60661e3a1613 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Ondrej Kozina <okozina@redhat.com>
|
||
|
|
Date: Mon, 24 Sep 2018 14:58:16 +0200
|
||
|
|
Subject: [PATCH 041/324] Move blkid scan after device context initialization.
|
||
|
|
|
||
|
|
Fixes bug with misleading error message when target device
|
||
|
|
does not exist.
|
||
|
|
---
|
||
|
|
src/cryptsetup.c | 30 ++++++++++++++++--------------
|
||
|
|
src/integritysetup.c | 20 +++++++++++---------
|
||
|
|
2 files changed, 27 insertions(+), 23 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/src/cryptsetup.c b/src/cryptsetup.c
|
||
|
|
index cc3520c..371948f 100644
|
||
|
|
--- a/src/cryptsetup.c
|
||
|
|
+++ b/src/cryptsetup.c
|
||
|
|
@@ -987,20 +987,6 @@ static int action_luksFormat(void)
|
||
|
|
|
||
|
|
header_device = opt_header_device ?: action_argv[0];
|
||
|
|
|
||
|
|
- /* Print all present signatures in read-only mode */
|
||
|
|
- r = tools_detect_signatures(header_device, 0, &signatures);
|
||
|
|
- if (r < 0)
|
||
|
|
- return r;
|
||
|
|
-
|
||
|
|
- r = asprintf(&msg, _("This will overwrite data on %s irrevocably."), header_device);
|
||
|
|
- if (r == -1)
|
||
|
|
- return -ENOMEM;
|
||
|
|
-
|
||
|
|
- r = yesDialog(msg, _("Operation aborted.\n")) ? 0 : -EINVAL;
|
||
|
|
- free(msg);
|
||
|
|
- if (r < 0)
|
||
|
|
- return r;
|
||
|
|
-
|
||
|
|
r = crypt_parse_name_and_mode(opt_cipher ?: DEFAULT_CIPHER(LUKS1),
|
||
|
|
cipher, NULL, cipher_mode);
|
||
|
|
if (r < 0) {
|
||
|
|
@@ -1028,6 +1014,22 @@ static int action_luksFormat(void)
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ /* Print all present signatures in read-only mode */
|
||
|
|
+ r = tools_detect_signatures(header_device, 0, &signatures);
|
||
|
|
+ if (r < 0)
|
||
|
|
+ goto out;
|
||
|
|
+
|
||
|
|
+ r = asprintf(&msg, _("This will overwrite data on %s irrevocably."), header_device);
|
||
|
|
+ if (r == -1) {
|
||
|
|
+ r = -ENOMEM;
|
||
|
|
+ goto out;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ r = yesDialog(msg, _("Operation aborted.\n")) ? 0 : -EINVAL;
|
||
|
|
+ free(msg);
|
||
|
|
+ if (r < 0)
|
||
|
|
+ goto out;
|
||
|
|
+
|
||
|
|
keysize = (opt_key_size ?: DEFAULT_LUKS1_KEYBITS) / 8 + integrity_keysize;
|
||
|
|
|
||
|
|
if (opt_random)
|
||
|
|
diff --git a/src/integritysetup.c b/src/integritysetup.c
|
||
|
|
index c1c31ee..a3b382f 100644
|
||
|
|
--- a/src/integritysetup.c
|
||
|
|
+++ b/src/integritysetup.c
|
||
|
|
@@ -209,24 +209,26 @@ static int action_format(int arg)
|
||
|
|
params.journal_crypt = journal_crypt;
|
||
|
|
}
|
||
|
|
|
||
|
|
- r = tools_detect_signatures(action_argv[0], 0, &signatures);
|
||
|
|
+ r = _read_keys(&integrity_key, ¶ms);
|
||
|
|
+ if (r)
|
||
|
|
+ goto out;
|
||
|
|
+
|
||
|
|
+ r = crypt_init(&cd, action_argv[0]);
|
||
|
|
if (r < 0)
|
||
|
|
- return r;
|
||
|
|
+ goto out;
|
||
|
|
|
||
|
|
r = asprintf(&msg, _("This will overwrite data on %s irrevocably."), action_argv[0]);
|
||
|
|
- if (r == -1)
|
||
|
|
- return -ENOMEM;
|
||
|
|
+ if (r == -1) {
|
||
|
|
+ r = -ENOMEM;
|
||
|
|
+ goto out;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
r = yesDialog(msg, _("Operation aborted.\n")) ? 0 : -EINVAL;
|
||
|
|
free(msg);
|
||
|
|
if (r < 0)
|
||
|
|
- return r;
|
||
|
|
-
|
||
|
|
- r = _read_keys(&integrity_key, ¶ms);
|
||
|
|
- if (r)
|
||
|
|
goto out;
|
||
|
|
|
||
|
|
- r = crypt_init(&cd, action_argv[0]);
|
||
|
|
+ r = tools_detect_signatures(action_argv[0], 0, &signatures);
|
||
|
|
if (r < 0)
|
||
|
|
goto out;
|
||
|
|
|
||
|
|
--
|
||
|
|
2.19.1
|
||
|
|
|