Blame SOURCES/0001-Do-not-try-to-use-keyring-on-systems-without-keyring-support.patch

22d3f2
From 2719ab3ee310a59ea64629852b507d63e3dbf0e5 Mon Sep 17 00:00:00 2001
22d3f2
From: Vojtech Trefny <vtrefny@redhat.com>
22d3f2
Date: Wed, 19 Dec 2018 11:04:51 +0100
22d3f2
Subject: [PATCH] crypto: Do not try to use keyring on systems without keyring
22d3f2
 support
22d3f2
22d3f2
Older kernels doesn't support storing keys in keyring. Fortunately
22d3f2
we can use 'crypt_active_device' to check if keyring is supported.
22d3f2
---
22d3f2
 src/plugins/crypto.c | 13 ++++++++++++-
22d3f2
 1 file changed, 12 insertions(+), 1 deletion(-)
22d3f2
22d3f2
diff --git a/src/plugins/crypto.c b/src/plugins/crypto.c
22d3f2
index 6b5be9d0..963ab457 100644
22d3f2
--- a/src/plugins/crypto.c
22d3f2
+++ b/src/plugins/crypto.c
22d3f2
@@ -1444,6 +1444,7 @@ gboolean bd_crypto_luks_change_key (const gchar *device, const gchar *pass, cons
22d3f2
 
22d3f2
 static gboolean luks_resize (const gchar *luks_device, guint64 size, const guint8 *pass_data, gsize data_len, const gchar *key_file, GError **error) {
22d3f2
     struct crypt_device *cd = NULL;
22d3f2
+    struct crypt_active_device cad;
22d3f2
     gint ret = 0;
22d3f2
     guint64 progress_id = 0;
22d3f2
     gchar *msg = NULL;
22d3f2
@@ -1463,6 +1464,16 @@ static gboolean luks_resize (const gchar *luks_device, guint64 size, const guint
22d3f2
         return FALSE;
22d3f2
     }
22d3f2
 
22d3f2
+    ret = crypt_get_active_device (cd, luks_device, &cad;;
22d3f2
+    if (ret != 0) {
22d3f2
+        g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_DEVICE,
22d3f2
+                     "Failed to get information about '%s': %s",
22d3f2
+                     luks_device, strerror_l(-ret, c_locale));
22d3f2
+        crypt_free (cd);
22d3f2
+        bd_utils_report_finished (progress_id, (*error)->message);
22d3f2
+        return FALSE;
22d3f2
+    }
22d3f2
+
22d3f2
     if (pass_data || key_file) {
22d3f2
         if (key_file) {
22d3f2
             success = g_file_get_contents (key_file, &key_buffer, &buf_len, error);
22d3f2
@@ -1478,7 +1489,7 @@ static gboolean luks_resize (const gchar *luks_device, guint64 size, const guint
22d3f2
 #ifdef LIBCRYPTSETUP_2
22d3f2
         ret = crypt_activate_by_passphrase (cd, NULL, CRYPT_ANY_SLOT,
22d3f2
                                             key_buffer ? key_buffer : (char*) pass_data,
22d3f2
-                                            buf_len, CRYPT_ACTIVATE_KEYRING_KEY);
22d3f2
+                                            buf_len, cad.flags & CRYPT_ACTIVATE_KEYRING_KEY);
22d3f2
 #else
22d3f2
         ret = crypt_activate_by_passphrase (cd, NULL, CRYPT_ANY_SLOT,
22d3f2
                                             key_buffer ? key_buffer : (char*) pass_data,