Compare commits
No commits in common. 'i10cs' and 'c9' have entirely different histories.
@ -1 +1 @@
|
|||||||
SOURCES/udisks-2.10.90.tar.bz2
|
SOURCES/udisks-2.9.4.tar.bz2
|
||||||
|
@ -1 +1 @@
|
|||||||
2bf20a2af65362ddea79211788bd20f3ff23a3e1 SOURCES/udisks-2.10.90.tar.bz2
|
e6f21e90456360723d80265c4d3372eb88ef7a6e SOURCES/udisks-2.9.4.tar.bz2
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
From b9863c11601e199420a375e13505e2b795de77c5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Frederick Grose <4335897+FGrose@users.noreply.github.com>
|
||||||
|
Date: Tue, 9 Feb 2021 19:02:01 -0500
|
||||||
|
Subject: [PATCH] 80-udisks2.rules: Ignore Apple boot partition from
|
||||||
|
livecd-tools
|
||||||
|
|
||||||
|
https://github.com/livecd-tools/livecd-tools/pull/176 creates a new boot
|
||||||
|
partition with livecd-iso-to-disk from Fedora Live .iso files that UDISKS
|
||||||
|
should ignore.
|
||||||
|
---
|
||||||
|
data/80-udisks2.rules | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/data/80-udisks2.rules b/data/80-udisks2.rules
|
||||||
|
index fb50f48a0..d6fa072fd 100644
|
||||||
|
--- a/data/80-udisks2.rules
|
||||||
|
+++ b/data/80-udisks2.rules
|
||||||
|
@@ -122,6 +122,7 @@ ENV{ID_PART_ENTRY_SCHEME}=="mac", ENV{ID_PART_ENTRY_TYPE}=="Apple_Bootstrap", EN
|
||||||
|
|
||||||
|
# Apple Boot partitions
|
||||||
|
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_TYPE}=="426f6f74-0000-11aa-aa11-00306543ecac", ENV{UDISKS_IGNORE}="1"
|
||||||
|
+ENV{ID_FS_LABEL}=="ANACONDA", ENV{ID_PART_ENTRY_TYPE}=="48465300-0000-11aa-aa11-00306543ecac|0xaf", ENV{UDISKS_IGNORE}="1"
|
||||||
|
|
||||||
|
# special DOS partition types (EFI, hidden, etc.) and RAID/LVM
|
||||||
|
# see http://www.win.tue.nl/~aeb/partitions/partition_types-1.html
|
@ -0,0 +1,60 @@
|
|||||||
|
From eb917d346bc8592924c5f6566b01841176c53c8c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Mon, 22 Aug 2022 16:27:11 +0200
|
||||||
|
Subject: [PATCH] udiskslinuxblock: Only permit ATA Secure Erase during
|
||||||
|
Format() on a whole block device
|
||||||
|
|
||||||
|
ATA Secure Erase requested as an option to the Format() method call used
|
||||||
|
to perform the actual erase on a whole drive object it looked up. When
|
||||||
|
Format() was called on a partition, this led to data loss on a whole drive.
|
||||||
|
This commit adds a safeguard to check that the Format() is requested
|
||||||
|
on a whole block device.
|
||||||
|
|
||||||
|
Severity of this issue was slightly lowered by a failure to submit
|
||||||
|
the ATA Secure erase command in case some filesystem was mounted
|
||||||
|
at that point.
|
||||||
|
---
|
||||||
|
src/udiskslinuxblock.c | 16 ++++++++++++++++
|
||||||
|
1 file changed, 16 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c
|
||||||
|
index d1da94edf..db0ed2bf6 100644
|
||||||
|
--- a/src/udiskslinuxblock.c
|
||||||
|
+++ b/src/udiskslinuxblock.c
|
||||||
|
@@ -2354,6 +2354,7 @@ erase_ata_device (UDisksBlock *block,
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
UDisksObject *drive_object = NULL;
|
||||||
|
+ UDisksLinuxBlockObject *block_object = NULL;
|
||||||
|
UDisksDriveAta *ata = NULL;
|
||||||
|
|
||||||
|
drive_object = udisks_daemon_find_object (daemon, udisks_block_get_drive (block));
|
||||||
|
@@ -2369,6 +2370,20 @@ erase_ata_device (UDisksBlock *block,
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* Reverse check to ensure we're erasing whole block device and not a partition */
|
||||||
|
+ block_object = udisks_linux_drive_object_get_block (UDISKS_LINUX_DRIVE_OBJECT (drive_object), FALSE /* get_hw */);
|
||||||
|
+ if (block_object == NULL)
|
||||||
|
+ {
|
||||||
|
+ g_set_error (error, UDISKS_ERROR, UDISKS_ERROR_FAILED, "Couldn't find a block device for the drive to erase");
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+ if (g_strcmp0 (g_dbus_object_get_object_path (G_DBUS_OBJECT (object)),
|
||||||
|
+ g_dbus_object_get_object_path (G_DBUS_OBJECT (block_object))) != 0)
|
||||||
|
+ {
|
||||||
|
+ g_set_error (error, UDISKS_ERROR, UDISKS_ERROR_FAILED, "ATA secure erase needs to be performed on a whole block device");
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/* sleep a tiny bit here to avoid the secure erase code racing with
|
||||||
|
* programs spawned by udev
|
||||||
|
*/
|
||||||
|
@@ -2382,6 +2397,7 @@ erase_ata_device (UDisksBlock *block,
|
||||||
|
out:
|
||||||
|
g_clear_object (&ata);
|
||||||
|
g_clear_object (&drive_object);
|
||||||
|
+ g_clear_object (&block_object);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
From def82f87dcc0b21e4890e12d82e6007f98551dcb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Tue, 30 May 2023 18:23:08 +0200
|
||||||
|
Subject: [PATCH] tests: Forcefully set scsi_debug cd drive as read-only
|
||||||
|
|
||||||
|
There's something fishy in newer kernels and read-only detection
|
||||||
|
doesn't seem to work properly. As suggested in
|
||||||
|
https://github.com/util-linux/util-linux/issues/18#issuecomment-8453739
|
||||||
|
setting device ro by `blockdev --setro` seems to fix the issue.
|
||||||
|
---
|
||||||
|
src/tests/integration-test | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/tests/integration-test b/src/tests/integration-test
|
||||||
|
index 5f68217e0..10cdff85e 100755
|
||||||
|
--- a/src/tests/integration-test
|
||||||
|
+++ b/src/tests/integration-test
|
||||||
|
@@ -1096,6 +1096,7 @@ class FS(UDisksTestCase):
|
||||||
|
time.sleep(5)
|
||||||
|
self.sync()
|
||||||
|
cd_fs = self.udisks_filesystem(cd=True)
|
||||||
|
+ subprocess.call(['blockdev', '--setro', self.cd_device])
|
||||||
|
|
||||||
|
# forcing mount CD drive as 'rw' should fail
|
||||||
|
try:
|
||||||
|
@@ -1748,6 +1749,7 @@ class Polkit(UDisksTestCase, test_polkitd.PolkitTestCase):
|
||||||
|
try:
|
||||||
|
fs = self.udisks_filesystem(cd=True)
|
||||||
|
self.assertNotEqual(fs, None)
|
||||||
|
+ subprocess.call(['blockdev', '--setro', self.cd_device])
|
||||||
|
mount_path = fs.call_mount_sync(no_options, None)
|
||||||
|
self.assertIn('/media/', mount_path)
|
||||||
|
|
@ -0,0 +1,161 @@
|
|||||||
|
From 26fcef727d68af97b1187d2ac3cad19acc3d97c8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Tue, 16 May 2023 18:33:59 +0200
|
||||||
|
Subject: [PATCH 1/2] iscsi: Set node parameters before the Login/Logout action
|
||||||
|
|
||||||
|
This allows to properly pass required arguments like the CHAP
|
||||||
|
auth algorithms, etc.
|
||||||
|
---
|
||||||
|
modules/iscsi/udisksiscsiutil.c | 54 ++++++++++++++++++---------------
|
||||||
|
1 file changed, 29 insertions(+), 25 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modules/iscsi/udisksiscsiutil.c b/modules/iscsi/udisksiscsiutil.c
|
||||||
|
index 78890106f0..b279442876 100644
|
||||||
|
--- a/modules/iscsi/udisksiscsiutil.c
|
||||||
|
+++ b/modules/iscsi/udisksiscsiutil.c
|
||||||
|
@@ -186,9 +186,10 @@ iscsi_perform_login_action (UDisksLinuxModuleISCSI *module,
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
-iscsi_node_set_parameters (struct libiscsi_context *ctx,
|
||||||
|
- struct libiscsi_node *node,
|
||||||
|
- GVariant *params)
|
||||||
|
+iscsi_node_set_parameters (struct libiscsi_context *ctx,
|
||||||
|
+ struct libiscsi_node *node,
|
||||||
|
+ GVariant *params,
|
||||||
|
+ gchar **errorstr)
|
||||||
|
{
|
||||||
|
GVariantIter iter;
|
||||||
|
GVariant *value;
|
||||||
|
@@ -207,9 +208,11 @@ iscsi_node_set_parameters (struct libiscsi_context *ctx,
|
||||||
|
|
||||||
|
/* Update the node parameter value. */
|
||||||
|
err = libiscsi_node_set_parameter (ctx, node, key, param_value);
|
||||||
|
+ if (errorstr && err != 0)
|
||||||
|
+ *errorstr = g_strdup (libiscsi_get_error_string (ctx));
|
||||||
|
|
||||||
|
g_variant_unref (value);
|
||||||
|
- g_free ((gpointer) key);
|
||||||
|
+ g_free (key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
@@ -279,7 +282,7 @@ iscsi_login (UDisksLinuxModuleISCSI *module,
|
||||||
|
const gchar *password = NULL;
|
||||||
|
const gchar *reverse_username = NULL;
|
||||||
|
const gchar *reverse_password = NULL;
|
||||||
|
- gint err;
|
||||||
|
+ gint err = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (UDISKS_IS_LINUX_MODULE_ISCSI (module), 1);
|
||||||
|
|
||||||
|
@@ -304,17 +307,18 @@ iscsi_login (UDisksLinuxModuleISCSI *module,
|
||||||
|
/* Get iscsi context. */
|
||||||
|
ctx = udisks_linux_module_iscsi_get_libiscsi_context (module);
|
||||||
|
|
||||||
|
- /* Login */
|
||||||
|
- err = iscsi_perform_login_action (module,
|
||||||
|
- ACTION_LOGIN,
|
||||||
|
- &node,
|
||||||
|
- &auth_info,
|
||||||
|
- errorstr);
|
||||||
|
+ /* Update node parameters. */
|
||||||
|
+ if (params)
|
||||||
|
+ err = iscsi_node_set_parameters (ctx, &node, params_without_chap, errorstr);
|
||||||
|
|
||||||
|
- if (err == 0 && params)
|
||||||
|
+ /* Login */
|
||||||
|
+ if (err == 0)
|
||||||
|
{
|
||||||
|
- /* Update node parameters. */
|
||||||
|
- err = iscsi_node_set_parameters (ctx, &node, params_without_chap);
|
||||||
|
+ err = iscsi_perform_login_action (module,
|
||||||
|
+ ACTION_LOGIN,
|
||||||
|
+ &node,
|
||||||
|
+ &auth_info,
|
||||||
|
+ errorstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_variant_unref (params_without_chap);
|
||||||
|
@@ -334,7 +338,7 @@ iscsi_logout (UDisksLinuxModuleISCSI *module,
|
||||||
|
{
|
||||||
|
struct libiscsi_context *ctx;
|
||||||
|
struct libiscsi_node node = {0,};
|
||||||
|
- gint err;
|
||||||
|
+ gint err = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (UDISKS_IS_LINUX_MODULE_ISCSI (module), 1);
|
||||||
|
|
||||||
|
@@ -344,18 +348,18 @@ iscsi_logout (UDisksLinuxModuleISCSI *module,
|
||||||
|
/* Get iscsi context. */
|
||||||
|
ctx = udisks_linux_module_iscsi_get_libiscsi_context (module);
|
||||||
|
|
||||||
|
- /* Logout */
|
||||||
|
- err = iscsi_perform_login_action (module,
|
||||||
|
- ACTION_LOGOUT,
|
||||||
|
- &node,
|
||||||
|
- NULL,
|
||||||
|
- errorstr);
|
||||||
|
+ /* Update node parameters. */
|
||||||
|
+ if (params)
|
||||||
|
+ err = iscsi_node_set_parameters (ctx, &node, params, errorstr);
|
||||||
|
|
||||||
|
- if (err == 0 && params)
|
||||||
|
+ /* Logout */
|
||||||
|
+ if (err == 0)
|
||||||
|
{
|
||||||
|
- /* Update node parameters. */
|
||||||
|
- err = iscsi_node_set_parameters (ctx, &node, params);
|
||||||
|
-
|
||||||
|
+ err = iscsi_perform_login_action (module,
|
||||||
|
+ ACTION_LOGOUT,
|
||||||
|
+ &node,
|
||||||
|
+ NULL,
|
||||||
|
+ errorstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
|
||||||
|
From 749812784abcc4c0492bda0703bff5d3dae052f9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Tue, 16 May 2023 18:35:42 +0200
|
||||||
|
Subject: [PATCH 2/2] tests: Disallow MD5 for iscsi CHAP login
|
||||||
|
|
||||||
|
MD5 is unavailable in FIPS mode:
|
||||||
|
|
||||||
|
iscsid[82167]: iscsid: Ignoring CHAP algorthm request for MD5 due to crypto lib configuration
|
||||||
|
iscsid[82167]: iscsid: Couldn't set CHAP algorithm list
|
||||||
|
kernel: rx_data returned 0, expecting 48.
|
||||||
|
kernel: iSCSI Login negotiation failed.
|
||||||
|
---
|
||||||
|
src/tests/dbus-tests/test_30_iscsi.py | 3 +++
|
||||||
|
1 file changed, 3 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
index 09e975f30c..02ba6c92b0 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
@@ -161,6 +161,7 @@ def test_login_chap_auth(self):
|
||||||
|
self.assertEqual(port, self.port)
|
||||||
|
|
||||||
|
options = dbus.Dictionary(signature='sv')
|
||||||
|
+ options['node.session.auth.chap_algs'] = 'SHA3-256,SHA256,SHA1' # disallow MD5
|
||||||
|
options['username'] = self.initiator
|
||||||
|
|
||||||
|
msg = 'Login failed: initiator reported error \(24 - iSCSI login failed due to authorization failure\)'
|
||||||
|
@@ -227,6 +228,7 @@ def test_login_mutual_auth(self):
|
||||||
|
self.assertEqual(port, self.port)
|
||||||
|
|
||||||
|
options = dbus.Dictionary(signature='sv')
|
||||||
|
+ options['node.session.auth.chap_algs'] = 'SHA3-256,SHA256,SHA1' # disallow MD5
|
||||||
|
options['username'] = self.initiator
|
||||||
|
options['password'] = self.password
|
||||||
|
options['reverse-username'] = self.mutual_iqn
|
||||||
|
@@ -335,6 +337,7 @@ def test_login_noauth_badauth(self):
|
||||||
|
|
||||||
|
# first attempt - wrong password
|
||||||
|
options = dbus.Dictionary(signature='sv')
|
||||||
|
+ options['node.session.auth.chap_algs'] = 'SHA3-256,SHA256,SHA1' # disallow MD5
|
||||||
|
options['username'] = self.initiator
|
||||||
|
msg = r'Login failed: initiator reported error \((19 - encountered non-retryable iSCSI login failure|24 - iSCSI login failed due to authorization failure)\)'
|
||||||
|
with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
@ -0,0 +1,29 @@
|
|||||||
|
From 9a6e6b700b19539465ab6b241f04b94d4b3769c4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Mon, 10 Oct 2022 13:55:29 +0200
|
||||||
|
Subject: [PATCH] iscsi: Always set auth info
|
||||||
|
|
||||||
|
In case of reusing a context auth info needs to be
|
||||||
|
always set to override previous data.
|
||||||
|
---
|
||||||
|
modules/iscsi/udisksiscsiutil.c | 7 ++-----
|
||||||
|
1 file changed, 2 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modules/iscsi/udisksiscsiutil.c b/modules/iscsi/udisksiscsiutil.c
|
||||||
|
index 8fdae889c7..78890106f0 100644
|
||||||
|
--- a/modules/iscsi/udisksiscsiutil.c
|
||||||
|
+++ b/modules/iscsi/udisksiscsiutil.c
|
||||||
|
@@ -171,11 +171,8 @@ iscsi_perform_login_action (UDisksLinuxModuleISCSI *module,
|
||||||
|
/* Get a libiscsi context. */
|
||||||
|
ctx = udisks_linux_module_iscsi_get_libiscsi_context (module);
|
||||||
|
|
||||||
|
- if (action == ACTION_LOGIN &&
|
||||||
|
- auth_info && auth_info->method == libiscsi_auth_chap)
|
||||||
|
- {
|
||||||
|
- libiscsi_node_set_auth (ctx, node, auth_info);
|
||||||
|
- }
|
||||||
|
+ if (action == ACTION_LOGIN && auth_info)
|
||||||
|
+ libiscsi_node_set_auth (ctx, node, auth_info);
|
||||||
|
|
||||||
|
/* Login or Logout */
|
||||||
|
err = action == ACTION_LOGIN ?
|
@ -0,0 +1,73 @@
|
|||||||
|
From 0441d0f93788b617a38b75e4a44744406976c822 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Mon, 31 Jul 2023 16:48:28 +0200
|
||||||
|
Subject: [PATCH] iscsi: Fix login on firmware-discovered nodes
|
||||||
|
|
||||||
|
There's currently no way to distinguish between force-no-auth and
|
||||||
|
use-fw-discovered-auth-info scenarios from the D-Bus API so let's
|
||||||
|
assume that the caller wants to retain the firmware-discovered auth
|
||||||
|
info unless overriden with specific CHAP credentials.
|
||||||
|
---
|
||||||
|
.../data/org.freedesktop.UDisks2.iscsi.xml | 3 +++
|
||||||
|
modules/iscsi/udisksiscsiutil.c | 27 ++++++++++++++++++-
|
||||||
|
2 files changed, 29 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/modules/iscsi/data/org.freedesktop.UDisks2.iscsi.xml b/modules/iscsi/data/org.freedesktop.UDisks2.iscsi.xml
|
||||||
|
index cf262deb68..e8a717ff1d 100644
|
||||||
|
--- a/modules/iscsi/data/org.freedesktop.UDisks2.iscsi.xml
|
||||||
|
+++ b/modules/iscsi/data/org.freedesktop.UDisks2.iscsi.xml
|
||||||
|
@@ -162,6 +162,9 @@
|
||||||
|
<parameter>reverse-password</parameter> will be used for CHAP
|
||||||
|
authentication.
|
||||||
|
|
||||||
|
+ Firmware-discovered nodes retain their authentication info unless
|
||||||
|
+ overriden with specified credentials (see above).
|
||||||
|
+
|
||||||
|
All the additional options are transformed into the interface
|
||||||
|
parameters. For example, if an automatic node startup is desired, the
|
||||||
|
<parameter>node.startup</parameter> needs to be set to
|
||||||
|
diff --git a/modules/iscsi/udisksiscsiutil.c b/modules/iscsi/udisksiscsiutil.c
|
||||||
|
index b279442876..fb4f5ea167 100644
|
||||||
|
--- a/modules/iscsi/udisksiscsiutil.c
|
||||||
|
+++ b/modules/iscsi/udisksiscsiutil.c
|
||||||
|
@@ -264,6 +264,31 @@ iscsi_params_pop_chap_data (GVariant *params,
|
||||||
|
return g_variant_dict_end (&dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static gboolean
|
||||||
|
+is_auth_required (struct libiscsi_context *ctx,
|
||||||
|
+ struct libiscsi_node *node,
|
||||||
|
+ struct libiscsi_auth_info *auth_info)
|
||||||
|
+{
|
||||||
|
+ char val[LIBISCSI_VALUE_MAXLEN + 1] = {'\0',};
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ /* TODO: No way to distinguish between the "no auth requested" and
|
||||||
|
+ * "retain discovered auth info" scenarios from the D-Bus API.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ /* In case CHAP auth is requested, let's use it unconditionally */
|
||||||
|
+ if (auth_info->method != libiscsi_auth_none)
|
||||||
|
+ return TRUE;
|
||||||
|
+
|
||||||
|
+ /* Avoid auth override on firmware-discovered nodes */
|
||||||
|
+ ret = libiscsi_node_get_parameter (ctx, node, "node.discovery_type", val);
|
||||||
|
+ if (ret == 0 && g_strcmp0 (val, "fw") == 0)
|
||||||
|
+ return FALSE;
|
||||||
|
+
|
||||||
|
+ /* Not a firmware-discovered node, maintain legacy rules */
|
||||||
|
+ return TRUE;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
gint
|
||||||
|
iscsi_login (UDisksLinuxModuleISCSI *module,
|
||||||
|
const gchar *name,
|
||||||
|
@@ -317,7 +342,7 @@ iscsi_login (UDisksLinuxModuleISCSI *module,
|
||||||
|
err = iscsi_perform_login_action (module,
|
||||||
|
ACTION_LOGIN,
|
||||||
|
&node,
|
||||||
|
- &auth_info,
|
||||||
|
+ is_auth_required (ctx, &node, &auth_info) ? &auth_info : NULL,
|
||||||
|
errorstr);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
|||||||
|
commit fab797fcf5e4c8e09e4cde45647951acd764415e
|
||||||
|
Author: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Mon Oct 10 13:58:15 2022 +0200
|
||||||
|
|
||||||
|
tests: Add bad auth test for iscsi
|
||||||
|
|
||||||
|
This tests that the auth info is properly set for each login call,
|
||||||
|
overriding previously set auth info with no trace.
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
index 34bdfc4b..6ac8386b 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
@@ -284,3 +284,61 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
# make sure the session object is no longer on dbus
|
||||||
|
objects = udisks.GetManagedObjects(dbus_interface='org.freedesktop.DBus.ObjectManager')
|
||||||
|
self.assertNotIn(session_path, objects.keys())
|
||||||
|
+
|
||||||
|
+ def test_login_noauth_badauth(self):
|
||||||
|
+ """
|
||||||
|
+ Test auth info override
|
||||||
|
+ """
|
||||||
|
+ manager = self.get_object('/Manager')
|
||||||
|
+ nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
||||||
|
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
+ timeout=self.iscsi_timeout)
|
||||||
|
+
|
||||||
|
+ node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
||||||
|
+ self.assertIsNotNone(node)
|
||||||
|
+
|
||||||
|
+ (iqn, tpg, host, port, iface) = node
|
||||||
|
+ self.assertEqual(iqn, self.noauth_iqn)
|
||||||
|
+ self.assertEqual(host, self.address)
|
||||||
|
+ self.assertEqual(port, self.port)
|
||||||
|
+
|
||||||
|
+ self.addCleanup(self._force_lougout, self.noauth_iqn)
|
||||||
|
+
|
||||||
|
+ # first attempt - wrong password
|
||||||
|
+ options = dbus.Dictionary(signature='sv')
|
||||||
|
+ options['username'] = self.initiator
|
||||||
|
+ msg = 'Login failed: initiator reported error'
|
||||||
|
+ with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
+ options['password'] = '12345'
|
||||||
|
+ manager.Login(iqn, tpg, host, port, iface, options,
|
||||||
|
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
+ timeout=self.iscsi_timeout)
|
||||||
|
+
|
||||||
|
+ # second atttempt - no password
|
||||||
|
+ manager.Login(iqn, tpg, host, port, iface, self.no_options,
|
||||||
|
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
+ timeout=self.iscsi_timeout)
|
||||||
|
+
|
||||||
|
+ devs = glob.glob('/dev/disk/by-path/*%s*' % iqn)
|
||||||
|
+ self.assertEqual(len(devs), 1)
|
||||||
|
+
|
||||||
|
+ # check if the block device have 'Symlinks' property updated
|
||||||
|
+ disk_name = os.path.realpath(devs[0]).split('/')[-1]
|
||||||
|
+ disk_obj = self.get_object('/block_devices/' + disk_name)
|
||||||
|
+ dbus_path = str(disk_obj.object_path)
|
||||||
|
+ self.assertIsNotNone(disk_obj)
|
||||||
|
+
|
||||||
|
+ symlinks = self.get_property_raw(disk_obj, '.Block', 'Symlinks')
|
||||||
|
+ self.assertIn(self.str_to_ay(devs[0]), symlinks)
|
||||||
|
+
|
||||||
|
+ manager.Logout(iqn, tpg, host, port, iface, self.no_options,
|
||||||
|
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
+ timeout=self.iscsi_timeout)
|
||||||
|
+
|
||||||
|
+ devs = glob.glob('/dev/disk/by-path/*%s*' % iqn)
|
||||||
|
+ self.assertEqual(len(devs), 0)
|
||||||
|
+
|
||||||
|
+ # make sure the disk is no longer on dbus
|
||||||
|
+ udisks = self.get_object('')
|
||||||
|
+ objects = udisks.GetManagedObjects(dbus_interface='org.freedesktop.DBus.ObjectManager')
|
||||||
|
+ self.assertNotIn(dbus_path, objects.keys())
|
@ -0,0 +1,51 @@
|
|||||||
|
commit 13a6a27eecdd1fb527b9151309366970b182a58d
|
||||||
|
Author: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Thu Oct 20 17:17:10 2022 +0200
|
||||||
|
|
||||||
|
tests: Fix LIO target config auth
|
||||||
|
|
||||||
|
Linux kernel 6.0 brought number of the LIO target changes related to authentication
|
||||||
|
that made our tests fail. Turned out our target config was incorrect, e.g.
|
||||||
|
not requiring auth for CHAP tests, etc. The kernel 6.0 looks to be more strict
|
||||||
|
in this regard.
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/targetcli_config.json b/src/tests/dbus-tests/targetcli_config.json
|
||||||
|
index 25d506b6..3be9eac2 100644
|
||||||
|
--- a/src/tests/dbus-tests/targetcli_config.json
|
||||||
|
+++ b/src/tests/dbus-tests/targetcli_config.json
|
||||||
|
@@ -385,7 +385,7 @@
|
||||||
|
"tpgs": [
|
||||||
|
{
|
||||||
|
"attributes": {
|
||||||
|
- "authentication": 0,
|
||||||
|
+ "authentication": 1,
|
||||||
|
"cache_dynamic_acls": 0,
|
||||||
|
"default_cmdsn_depth": 64,
|
||||||
|
"default_erl": 0,
|
||||||
|
@@ -432,7 +432,7 @@
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
- "AuthMethod": "CHAP,None",
|
||||||
|
+ "AuthMethod": "CHAP",
|
||||||
|
"DataDigest": "CRC32C,None",
|
||||||
|
"DataPDUInOrder": "Yes",
|
||||||
|
"DataSequenceInOrder": "Yes",
|
||||||
|
@@ -471,7 +471,7 @@
|
||||||
|
"tpgs": [
|
||||||
|
{
|
||||||
|
"attributes": {
|
||||||
|
- "authentication": 0,
|
||||||
|
+ "authentication": 1,
|
||||||
|
"cache_dynamic_acls": 0,
|
||||||
|
"default_cmdsn_depth": 64,
|
||||||
|
"default_erl": 0,
|
||||||
|
@@ -520,7 +520,7 @@
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
- "AuthMethod": "CHAP,None",
|
||||||
|
+ "AuthMethod": "CHAP",
|
||||||
|
"DataDigest": "CRC32C,None",
|
||||||
|
"DataPDUInOrder": "Yes",
|
||||||
|
"DataSequenceInOrder": "Yes",
|
@ -0,0 +1,84 @@
|
|||||||
|
commit 68115b16181db7a38f852b101ec965b9fc3e59cb
|
||||||
|
Author: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Thu Oct 20 17:32:29 2022 +0200
|
||||||
|
|
||||||
|
tests: Clean the discovered test target iscsid node cache
|
||||||
|
|
||||||
|
After each DiscoverSendTargets() and Login() calls iscsid caches
|
||||||
|
the node info in /var/lib/iscsi/nodes. That includes auth info and
|
||||||
|
passwords in plaintext. This might potentially lead to lingering
|
||||||
|
attributes sneaking into subsequent tests, affecting the results.
|
||||||
|
|
||||||
|
Let's clean that after each test run.
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
index 6ac8386b..2b75462a 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
@@ -6,6 +6,7 @@ import os
|
||||||
|
import re
|
||||||
|
import six
|
||||||
|
import time
|
||||||
|
+import shutil
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,6 +27,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
chap_iqn = 'iqn.2003-01.udisks.test:iscsi-test-chap'
|
||||||
|
mutual_iqn = 'iqn.2003-01.udisks.test:iscsi-test-mutual'
|
||||||
|
|
||||||
|
+
|
||||||
|
# Define common D-Bus method call timeout that needs to be slightly longer
|
||||||
|
# than the corresponding timeout defined in libiscsi:
|
||||||
|
# #define ISCSID_REQ_TIMEOUT 1000
|
||||||
|
@@ -61,6 +63,10 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
initiator = bytearray(data)
|
||||||
|
return initiator.strip().split(b"InitiatorName=")[1]
|
||||||
|
|
||||||
|
+ def _clean_iscsid_node_dir(self):
|
||||||
|
+ for iqn in [self.noauth_iqn, self.chap_iqn, self.mutual_iqn]:
|
||||||
|
+ shutil.rmtree(os.path.join('/var/lib/iscsi/nodes/', iqn), ignore_errors=True)
|
||||||
|
+
|
||||||
|
def test__manager_interface(self):
|
||||||
|
'''Test for module D-Bus Manager interface presence'''
|
||||||
|
|
||||||
|
@@ -86,6 +92,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
timeout=self.iscsi_timeout)
|
||||||
|
+ self.addCleanup(self._clean_iscsid_node_dir)
|
||||||
|
|
||||||
|
node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
||||||
|
self.assertIsNotNone(node)
|
||||||
|
@@ -131,6 +138,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
timeout=self.iscsi_timeout)
|
||||||
|
+ self.addCleanup(self._clean_iscsid_node_dir)
|
||||||
|
|
||||||
|
node = next((node for node in nodes if node[0] == self.chap_iqn), None)
|
||||||
|
self.assertIsNotNone(node)
|
||||||
|
@@ -190,6 +198,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
timeout=self.iscsi_timeout)
|
||||||
|
+ self.addCleanup(self._clean_iscsid_node_dir)
|
||||||
|
|
||||||
|
node = next((node for node in nodes if node[0] == self.mutual_iqn), None)
|
||||||
|
self.assertIsNotNone(node)
|
||||||
|
@@ -246,6 +255,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
timeout=self.iscsi_timeout)
|
||||||
|
+ self.addCleanup(self._clean_iscsid_node_dir)
|
||||||
|
|
||||||
|
node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
||||||
|
self.assertIsNotNone(node)
|
||||||
|
@@ -293,6 +303,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
timeout=self.iscsi_timeout)
|
||||||
|
+ self.addCleanup(self._clean_iscsid_node_dir)
|
||||||
|
|
||||||
|
node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
||||||
|
self.assertIsNotNone(node)
|
@ -0,0 +1,37 @@
|
|||||||
|
commit 1bf172603e4cc77da70d8fd13b6ba6c8b8c91600
|
||||||
|
Author: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Thu Oct 20 17:53:20 2022 +0200
|
||||||
|
|
||||||
|
tests: Test iscsi noauth in test_login_chap_auth
|
||||||
|
|
||||||
|
The other way is already tested in test_login_noauth_badauth.
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
index 2b75462a..f2594d99 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
@@ -151,8 +151,14 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
options = dbus.Dictionary(signature='sv')
|
||||||
|
options['username'] = self.initiator
|
||||||
|
|
||||||
|
+ msg = 'Login failed: initiator reported error \(24 - iSCSI login failed due to authorization failure\)'
|
||||||
|
+ # missing auth info
|
||||||
|
+ with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
+ manager.Login(iqn, tpg, host, port, iface, self.no_options,
|
||||||
|
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
||||||
|
+ timeout=self.iscsi_timeout)
|
||||||
|
+
|
||||||
|
# wrong password
|
||||||
|
- msg = 'Login failed: initiator reported error'
|
||||||
|
with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
options['password'] = '12345'
|
||||||
|
manager.Login(iqn, tpg, host, port, iface, options,
|
||||||
|
@@ -318,7 +324,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
||||||
|
# first attempt - wrong password
|
||||||
|
options = dbus.Dictionary(signature='sv')
|
||||||
|
options['username'] = self.initiator
|
||||||
|
- msg = 'Login failed: initiator reported error'
|
||||||
|
+ msg = r'Login failed: initiator reported error \((19 - encountered non-retryable iSCSI login failure|24 - iSCSI login failed due to authorization failure)\)'
|
||||||
|
with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
options['password'] = '12345'
|
||||||
|
manager.Login(iqn, tpg, host, port, iface, options,
|
@ -0,0 +1,42 @@
|
|||||||
|
From fbe970add68e6d9d998fb7f78377368c403e200d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Mon, 31 Oct 2022 15:15:31 +0100
|
||||||
|
Subject: [PATCH] tests: Restart iscsid on every InitiatorName change
|
||||||
|
|
||||||
|
The test LIO target config expects a specific initiator name as set
|
||||||
|
by the ACLs. However the iscsid daemon only seems to be reading
|
||||||
|
the InitiatorName string on startup and in case the service is running
|
||||||
|
with a different name, the auth tests will fail.
|
||||||
|
|
||||||
|
As a workaround, restart the iscsid service after each change.
|
||||||
|
A proper way through libiscsi or libopeniscsiusr would be nice -> TODO.
|
||||||
|
---
|
||||||
|
src/tests/dbus-tests/test_30_iscsi.py | 12 ++++++++++++
|
||||||
|
1 file changed, 12 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
index f2594d992..09e975f30 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
||||||
|
@@ -48,9 +48,21 @@ def _force_lougout(self, target):
|
||||||
|
def _set_initiator_name(self):
|
||||||
|
manager = self.get_object('/Manager')
|
||||||
|
|
||||||
|
+ # make backup of INITIATOR_FILE and restore it at the end
|
||||||
|
+ try:
|
||||||
|
+ initiatorname_backup = self.read_file(INITIATOR_FILE)
|
||||||
|
+ self.addCleanup(self.write_file, INITIATOR_FILE, initiatorname_backup)
|
||||||
|
+ except FileNotFoundError as e:
|
||||||
|
+ # no existing file, simply remove it once finished
|
||||||
|
+ self.addCleanup(self.remove_file, INITIATOR_FILE, True)
|
||||||
|
+
|
||||||
|
manager.SetInitiatorName(self.initiator, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator')
|
||||||
|
|
||||||
|
+ # running iscsid needs to be restarted to reflect the change
|
||||||
|
+ self.run_command('systemctl try-reload-or-restart iscsid.service')
|
||||||
|
+ # ignore the return code in case of non-systemd distros
|
||||||
|
+
|
||||||
|
init = manager.GetInitiatorName(self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator')
|
||||||
|
self.assertEqual(init, self.initiator)
|
@ -0,0 +1,182 @@
|
|||||||
|
From dd6ef8393a8f27fefad66cce136e52f13350f0df Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Fri, 1 Oct 2021 18:23:10 +0200
|
||||||
|
Subject: [PATCH] tests: Add LVM2 teardown object existence checks
|
||||||
|
|
||||||
|
This adds a check for the created stack objects presence after the teardown.
|
||||||
|
|
||||||
|
Due to the nature of the global lvm2 module update some objects may still
|
||||||
|
hang around after the org.freedesktop.UDisks2.VolumeGroup.Delete(options='tear-down')
|
||||||
|
method call has returned. Until this is properly fixed an explicit timeout
|
||||||
|
had to be added.
|
||||||
|
---
|
||||||
|
src/tests/dbus-tests/test_20_LVM.py | 80 +++++++++++++++++------------
|
||||||
|
1 file changed, 46 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_20_LVM.py b/src/tests/dbus-tests/test_20_LVM.py
|
||||||
|
index 56915e580..7fbff0434 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_20_LVM.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_20_LVM.py
|
||||||
|
@@ -3,6 +3,7 @@
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
|
+import six
|
||||||
|
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
|
@@ -637,7 +638,8 @@ def _remove_luks(self, device, name, close=True):
|
||||||
|
device.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
except dbus.exceptions.DBusException as e:
|
||||||
|
# ignore when luks is actually already locked
|
||||||
|
- if not str(e).endswith('is not unlocked') and not 'No such interface' in str(e):
|
||||||
|
+ if not str(e).endswith('is not unlocked') and not 'No such interface' in str(e) and \
|
||||||
|
+ not 'Object does not exist at path' in str(e):
|
||||||
|
raise e
|
||||||
|
|
||||||
|
try:
|
||||||
|
@@ -645,7 +647,7 @@ def _remove_luks(self, device, name, close=True):
|
||||||
|
d['erase'] = True
|
||||||
|
device.Format('empty', d, dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
except dbus.exceptions.DBusException as e:
|
||||||
|
- if not 'No such interface' in str(e):
|
||||||
|
+ if not 'No such interface' in str(e) and not 'Object does not exist at path' in str(e):
|
||||||
|
raise e
|
||||||
|
|
||||||
|
def _init_stack(self, name):
|
||||||
|
@@ -663,18 +665,19 @@ def _init_stack(self, name):
|
||||||
|
self.assertIsNotNone(self.pv)
|
||||||
|
|
||||||
|
self.vg = self._create_vg(vgname, dbus.Array([self.pv]))
|
||||||
|
+ self.vg_path = self.vg.object_path
|
||||||
|
self.addCleanup(self._remove_vg, self.vg, tear_down=True, ignore_removed=True)
|
||||||
|
|
||||||
|
# create an LV on it
|
||||||
|
- lv_path = self.vg.CreatePlainVolume(lvname, dbus.UInt64(200 * 1024**2), self.no_options,
|
||||||
|
- dbus_interface=self.iface_prefix + '.VolumeGroup')
|
||||||
|
- self.lv = self.bus.get_object(self.iface_prefix, lv_path)
|
||||||
|
+ self.lv_path = self.vg.CreatePlainVolume(lvname, dbus.UInt64(200 * 1024**2), self.no_options,
|
||||||
|
+ dbus_interface=self.iface_prefix + '.VolumeGroup')
|
||||||
|
+ self.lv = self.bus.get_object(self.iface_prefix, self.lv_path)
|
||||||
|
self.assertIsNotNone(self.lv)
|
||||||
|
|
||||||
|
- lv_block_path = self.lv.Activate(self.no_options, dbus_interface=self.iface_prefix + '.LogicalVolume')
|
||||||
|
- self.assertIsNotNone(lv_block_path)
|
||||||
|
+ self.lv_block_path = self.lv.Activate(self.no_options, dbus_interface=self.iface_prefix + '.LogicalVolume')
|
||||||
|
+ self.assertIsNotNone(self.lv_block_path)
|
||||||
|
|
||||||
|
- self.lv_block = self.get_object(lv_block_path)
|
||||||
|
+ self.lv_block = self.get_object(self.lv_block_path)
|
||||||
|
self.assertIsNotNone(self.lv_block)
|
||||||
|
|
||||||
|
# create LUKS on the LV
|
||||||
|
@@ -702,10 +705,10 @@ def _init_stack(self, name):
|
||||||
|
self.addCleanup(self._remove_luks, self.lv_block, vgname)
|
||||||
|
self.luks_uuid = self.get_property_raw(self.lv_block, '.Block', 'IdUUID')
|
||||||
|
|
||||||
|
- luks_block_path = self.get_property(self.lv_block, '.Encrypted', 'CleartextDevice')
|
||||||
|
- self.luks_block = self.get_object(luks_block_path.value)
|
||||||
|
- self.assertIsNotNone(self.luks_block)
|
||||||
|
- self.fs_uuid = self.get_property_raw(self.luks_block, '.Block', 'IdUUID')
|
||||||
|
+ self.luks_block_path = self.get_property_raw(self.lv_block, '.Encrypted', 'CleartextDevice')
|
||||||
|
+ luks_block = self.get_object(self.luks_block_path)
|
||||||
|
+ self.assertIsNotNone(luks_block)
|
||||||
|
+ self.fs_uuid = self.get_property_raw(luks_block, '.Block', 'IdUUID')
|
||||||
|
|
||||||
|
# check for present crypttab configuration item
|
||||||
|
conf = self.get_property(self.lv_block, '.Block', 'Configuration')
|
||||||
|
@@ -713,7 +716,7 @@ def _init_stack(self, name):
|
||||||
|
self.assertEqual(conf.value[0][0], 'crypttab')
|
||||||
|
|
||||||
|
# check for present fstab configuration item on a cleartext block device
|
||||||
|
- conf = self.get_property(self.luks_block, '.Block', 'Configuration')
|
||||||
|
+ conf = self.get_property(luks_block, '.Block', 'Configuration')
|
||||||
|
conf.assertTrue()
|
||||||
|
self.assertEqual(conf.value[0][0], 'fstab')
|
||||||
|
|
||||||
|
@@ -730,6 +733,32 @@ def _init_stack(self, name):
|
||||||
|
self.assertIn(vgname, fstab)
|
||||||
|
self.assertIn(self.fs_uuid, fstab)
|
||||||
|
|
||||||
|
+ def _check_torn_down_stack(self, name):
|
||||||
|
+ # check that all created objects don't exist anymore
|
||||||
|
+ msg = r'Object does not exist at path|No such interface'
|
||||||
|
+ with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
+ luks_block = self.get_object(self.luks_block_path)
|
||||||
|
+ self.get_property_raw(luks_block, '.Block', 'DeviceNumber')
|
||||||
|
+ with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
+ lv_block = self.get_object(self.lv_block_path)
|
||||||
|
+ self.get_property_raw(lv_block, '.Block', 'DeviceNumber')
|
||||||
|
+ with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
+ # the lvm2 udisks module is not fully synchronous, see https://github.com/storaged-project/udisks/pull/814
|
||||||
|
+ time.sleep(2)
|
||||||
|
+ lv = self.get_object(self.lv_path)
|
||||||
|
+ self.get_property_raw(lv, '.LogicalVolume', 'Name')
|
||||||
|
+ with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
+ vg = self.get_object(self.vg_path)
|
||||||
|
+ self.get_property_raw(vg, '.VolumeGroup', 'Name')
|
||||||
|
+
|
||||||
|
+ # check that fstab and crypttab records have been removed
|
||||||
|
+ crypttab = self.read_file('/etc/crypttab')
|
||||||
|
+ self.assertNotIn(name, crypttab)
|
||||||
|
+ self.assertNotIn(self.luks_uuid, crypttab)
|
||||||
|
+ fstab = self.read_file('/etc/fstab')
|
||||||
|
+ self.assertNotIn(name, fstab)
|
||||||
|
+ self.assertNotIn(self.fs_uuid, fstab)
|
||||||
|
+
|
||||||
|
|
||||||
|
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSAFE)
|
||||||
|
def test_teardown_active_vg_unlocked(self):
|
||||||
|
@@ -741,13 +770,7 @@ def test_teardown_active_vg_unlocked(self):
|
||||||
|
|
||||||
|
self._remove_vg(self.vg, tear_down=True, ignore_removed=False)
|
||||||
|
|
||||||
|
- # check that fstab and crypttab records have been removed
|
||||||
|
- crypttab = self.read_file('/etc/crypttab')
|
||||||
|
- self.assertNotIn(name, crypttab)
|
||||||
|
- self.assertNotIn(self.luks_uuid, crypttab)
|
||||||
|
- fstab = self.read_file('/etc/fstab')
|
||||||
|
- self.assertNotIn(name, fstab)
|
||||||
|
- self.assertNotIn(self.fs_uuid, fstab)
|
||||||
|
+ self._check_torn_down_stack(name)
|
||||||
|
|
||||||
|
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSAFE)
|
||||||
|
def test_teardown_active_vg_locked(self):
|
||||||
|
@@ -760,13 +783,7 @@ def test_teardown_active_vg_locked(self):
|
||||||
|
self.lv_block.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
self._remove_vg(self.vg, tear_down=True, ignore_removed=False)
|
||||||
|
|
||||||
|
- # check that fstab and crypttab records have been removed
|
||||||
|
- crypttab = self.read_file('/etc/crypttab')
|
||||||
|
- self.assertNotIn(name, crypttab)
|
||||||
|
- self.assertNotIn(self.luks_uuid, crypttab)
|
||||||
|
- fstab = self.read_file('/etc/fstab')
|
||||||
|
- self.assertNotIn(name, fstab)
|
||||||
|
- self.assertNotIn(self.fs_uuid, fstab)
|
||||||
|
+ self._check_torn_down_stack(name)
|
||||||
|
|
||||||
|
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSAFE)
|
||||||
|
def test_teardown_inactive_vg_locked(self):
|
||||||
|
@@ -780,13 +797,7 @@ def test_teardown_inactive_vg_locked(self):
|
||||||
|
self.lv.Deactivate(self.no_options, dbus_interface=self.iface_prefix + '.LogicalVolume')
|
||||||
|
self._remove_vg(self.vg, tear_down=True, ignore_removed=False)
|
||||||
|
|
||||||
|
- # check that fstab and crypttab records have been removed
|
||||||
|
- crypttab = self.read_file('/etc/crypttab')
|
||||||
|
- self.assertNotIn(name, crypttab)
|
||||||
|
- self.assertNotIn(self.luks_uuid, crypttab)
|
||||||
|
- fstab = self.read_file('/etc/fstab')
|
||||||
|
- self.assertNotIn(name, fstab)
|
||||||
|
- self.assertNotIn(self.fs_uuid, fstab)
|
||||||
|
+ self._check_torn_down_stack(name)
|
||||||
|
|
||||||
|
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSAFE)
|
||||||
|
def test_reformat_inactive_vg_locked(self):
|
||||||
|
@@ -812,6 +823,7 @@ def test_reformat_inactive_vg_locked(self):
|
||||||
|
|
||||||
|
# check that fstab and crypttab records have been removed
|
||||||
|
# TODO: these checks are the opposite - record shouldn't be present, once this is fixed
|
||||||
|
+ # self._check_torn_down_stack(name)
|
||||||
|
crypttab = self.read_file('/etc/crypttab')
|
||||||
|
self.assertIn(name, crypttab)
|
||||||
|
self.assertIn(self.luks_uuid, crypttab)
|
@ -0,0 +1,113 @@
|
|||||||
|
From 28c39786927ad683f56c031d80a5c06f5b5b9aea Mon Sep 17 00:00:00 2001
|
||||||
|
From: Marius Vollmer <mvollmer@redhat.com>
|
||||||
|
Date: Tue, 5 Apr 2022 11:23:23 +0300
|
||||||
|
Subject: [PATCH] lvm2: Only install results of most recently started udpates
|
||||||
|
|
||||||
|
Fixes #966
|
||||||
|
---
|
||||||
|
modules/lvm2/udiskslinuxmodulelvm2.c | 13 ++++++++++++-
|
||||||
|
modules/lvm2/udiskslinuxvolumegroupobject.c | 12 ++++++++++++
|
||||||
|
2 files changed, 24 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/modules/lvm2/udiskslinuxmodulelvm2.c b/modules/lvm2/udiskslinuxmodulelvm2.c
|
||||||
|
index 8e1ea13aec..77ecf94a6d 100644
|
||||||
|
--- a/modules/lvm2/udiskslinuxmodulelvm2.c
|
||||||
|
+++ b/modules/lvm2/udiskslinuxmodulelvm2.c
|
||||||
|
@@ -59,6 +59,8 @@ struct _UDisksLinuxModuleLVM2 {
|
||||||
|
|
||||||
|
gint delayed_update_id;
|
||||||
|
gboolean coldplug_done;
|
||||||
|
+
|
||||||
|
+ guint32 update_epoch;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _UDisksLinuxModuleLVM2Class UDisksLinuxModuleLVM2Class;
|
||||||
|
@@ -86,6 +88,7 @@ udisks_linux_module_lvm2_constructed (GObject *object)
|
||||||
|
|
||||||
|
module->name_to_volume_group = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref);
|
||||||
|
module->coldplug_done = FALSE;
|
||||||
|
+ module->update_epoch = 0;
|
||||||
|
|
||||||
|
if (G_OBJECT_CLASS (udisks_linux_module_lvm2_parent_class)->constructed)
|
||||||
|
G_OBJECT_CLASS (udisks_linux_module_lvm2_parent_class)->constructed (object);
|
||||||
|
@@ -221,6 +224,12 @@ lvm_update_vgs (GObject *source_obj,
|
||||||
|
gpointer key, value;
|
||||||
|
const gchar *vg_name;
|
||||||
|
|
||||||
|
+ if (GPOINTER_TO_UINT (user_data) != module->update_epoch)
|
||||||
|
+ {
|
||||||
|
+ vgs_pvs_data_free (data);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (! data)
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
|
@@ -303,11 +312,13 @@ lvm_update (UDisksLinuxModuleLVM2 *module)
|
||||||
|
{
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
|
+ module->update_epoch++;
|
||||||
|
+
|
||||||
|
/* the callback (lvm_update_vgs) is called in the default main loop (context) */
|
||||||
|
task = g_task_new (module,
|
||||||
|
NULL /* cancellable */,
|
||||||
|
lvm_update_vgs,
|
||||||
|
- NULL /* callback_data */);
|
||||||
|
+ GUINT_TO_POINTER (module->update_epoch));
|
||||||
|
|
||||||
|
/* holds a reference to 'task' until it is finished */
|
||||||
|
g_task_run_in_thread (task, (GTaskThreadFunc) vgs_task_func);
|
||||||
|
diff --git a/modules/lvm2/udiskslinuxvolumegroupobject.c b/modules/lvm2/udiskslinuxvolumegroupobject.c
|
||||||
|
index ce941cb250..ead08de7b1 100644
|
||||||
|
--- a/modules/lvm2/udiskslinuxvolumegroupobject.c
|
||||||
|
+++ b/modules/lvm2/udiskslinuxvolumegroupobject.c
|
||||||
|
@@ -66,6 +66,7 @@ struct _UDisksLinuxVolumeGroupObject
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
GHashTable *logical_volumes;
|
||||||
|
+ guint32 update_epoch;
|
||||||
|
guint32 poll_epoch;
|
||||||
|
guint poll_timeout_id;
|
||||||
|
gboolean poll_requested;
|
||||||
|
@@ -99,6 +100,7 @@ static void crypttab_changed (UDisksCrypttabMonitor *monitor,
|
||||||
|
typedef struct {
|
||||||
|
BDLVMVGdata *vg_info;
|
||||||
|
GSList *vg_pvs;
|
||||||
|
+ guint32 epoch;
|
||||||
|
} VGUpdateData;
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -183,6 +185,7 @@ udisks_linux_volume_group_object_set_property (GObject *__object,
|
||||||
|
static void
|
||||||
|
udisks_linux_volume_group_object_init (UDisksLinuxVolumeGroupObject *object)
|
||||||
|
{
|
||||||
|
+ object->update_epoch = 0;
|
||||||
|
object->poll_epoch = 0;
|
||||||
|
object->poll_timeout_id = 0;
|
||||||
|
object->poll_requested = FALSE;
|
||||||
|
@@ -575,6 +578,12 @@ update_vg (GObject *source_obj,
|
||||||
|
BDLVMVGdata *vg_info = data->vg_info;
|
||||||
|
GSList *vg_pvs = data->vg_pvs;
|
||||||
|
|
||||||
|
+ if (data->epoch != object->update_epoch)
|
||||||
|
+ {
|
||||||
|
+ lv_list_free (lvs);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/* free the data container (but not 'vg_info' and 'vg_pvs') */
|
||||||
|
g_free (data);
|
||||||
|
|
||||||
|
@@ -711,8 +720,11 @@ udisks_linux_volume_group_object_update (UDisksLinuxVolumeGroupObject *object, B
|
||||||
|
gchar *vg_name = g_strdup (vg_info->name);
|
||||||
|
GTask *task = NULL;
|
||||||
|
|
||||||
|
+ object->update_epoch++;
|
||||||
|
+
|
||||||
|
data->vg_info = vg_info;
|
||||||
|
data->vg_pvs = pvs;
|
||||||
|
+ data->epoch = object->update_epoch;
|
||||||
|
|
||||||
|
/* the callback (update_vg) is called in the default main loop (context) */
|
||||||
|
task = g_task_new (g_object_ref (object), NULL /* cancellable */, update_vg, data /* callback_data */);
|
@ -0,0 +1,26 @@
|
|||||||
|
From f24601b1d1302350fff15f326bfe3cfabde05f4c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Fri, 19 May 2023 17:17:56 +0200
|
||||||
|
Subject: [PATCH] lvm2: Trigger uevent sync on block devices when creating new
|
||||||
|
VG
|
||||||
|
|
||||||
|
This will likely slow down processing with the hope that
|
||||||
|
more objects have their properties updated properly.
|
||||||
|
---
|
||||||
|
modules/lvm2/udiskslinuxmanagerlvm2.c | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/modules/lvm2/udiskslinuxmanagerlvm2.c b/modules/lvm2/udiskslinuxmanagerlvm2.c
|
||||||
|
index b0c62fdcd6..5c06b921df 100644
|
||||||
|
--- a/modules/lvm2/udiskslinuxmanagerlvm2.c
|
||||||
|
+++ b/modules/lvm2/udiskslinuxmanagerlvm2.c
|
||||||
|
@@ -384,7 +384,8 @@ handle_volume_group_create (UDisksManagerLVM2 *_object,
|
||||||
|
UDisksObject *object_for_block;
|
||||||
|
object_for_block = udisks_daemon_util_dup_object (block, &error);
|
||||||
|
if (object_for_block != NULL)
|
||||||
|
- udisks_linux_block_object_trigger_uevent (UDISKS_LINUX_BLOCK_OBJECT (object_for_block));
|
||||||
|
+ udisks_linux_block_object_trigger_uevent_sync (UDISKS_LINUX_BLOCK_OBJECT (object_for_block),
|
||||||
|
+ UDISKS_DEFAULT_WAIT_TIMEOUT);
|
||||||
|
g_object_unref (object_for_block);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
|||||||
|
From d205057296957d6064825252a3d3377e809d6fed Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Wed, 6 Oct 2021 17:12:13 +0200
|
||||||
|
Subject: [PATCH] udiskslinuxmountoptions: Do not free static daemon resources
|
||||||
|
|
||||||
|
The GResource instance returned from udisks_daemon_resources_get_resource()
|
||||||
|
that calls g_static_resource_get_resource() internally is marked as
|
||||||
|
'(transfer none)' and should not be freed. In fact that causes double
|
||||||
|
free inside the g_static_resource_fini() atexit handler leading
|
||||||
|
to memory corruption causing random failures of further atexit
|
||||||
|
handlers such as cryptsetup and openssl destructors.
|
||||||
|
|
||||||
|
Invalid read of size 4
|
||||||
|
at 0x4BB03A4: g_resource_unref (gresource.c:527)
|
||||||
|
by 0x4BB2150: g_static_resource_fini (gresource.c:1449)
|
||||||
|
by 0x4010ADB: _dl_fini (dl-fini.c:139)
|
||||||
|
by 0x4EF0DF4: __run_exit_handlers (exit.c:113)
|
||||||
|
by 0x4EF0F6F: exit (exit.c:143)
|
||||||
|
by 0x4ED9566: __libc_start_call_main (libc_start_call_main.h:74)
|
||||||
|
by 0x4ED960B: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
|
||||||
|
by 0x128774: (below main) (in udisks/src/.libs/udisksd)
|
||||||
|
Address 0x5cc5fc0 is 0 bytes inside a block of size 16 free'd
|
||||||
|
at 0x48430E4: free (vg_replace_malloc.c:755)
|
||||||
|
by 0x4DB10BC: g_free (gmem.c:199)
|
||||||
|
by 0x4BB2148: g_static_resource_fini (gresource.c:1448)
|
||||||
|
by 0x4010ADB: _dl_fini (dl-fini.c:139)
|
||||||
|
by 0x4EF0DF4: __run_exit_handlers (exit.c:113)
|
||||||
|
by 0x4EF0F6F: exit (exit.c:143)
|
||||||
|
by 0x4ED9566: __libc_start_call_main (libc_start_call_main.h:74)
|
||||||
|
by 0x4ED960B: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
|
||||||
|
by 0x128774: (below main) (in udisks/src/.libs/udisksd)
|
||||||
|
Block was alloc'd at
|
||||||
|
at 0x484086F: malloc (vg_replace_malloc.c:380)
|
||||||
|
by 0x4DB47A8: g_malloc (gmem.c:106)
|
||||||
|
by 0x4BB19C7: UnknownInlinedFun (gresource.c:545)
|
||||||
|
by 0x4BB19C7: g_resource_new_from_data (gresource.c:613)
|
||||||
|
by 0x4BB1A88: register_lazy_static_resources_unlocked (gresource.c:1374)
|
||||||
|
by 0x4BB218C: UnknownInlinedFun (gresource.c:1393)
|
||||||
|
by 0x4BB218C: UnknownInlinedFun (gresource.c:1387)
|
||||||
|
by 0x4BB218C: g_static_resource_get_resource (gresource.c:1472)
|
||||||
|
by 0x14F6A3: UnknownInlinedFun (udisks-daemon-resources.c:284)
|
||||||
|
by 0x14F6A3: udisks_linux_mount_options_get_builtin (udiskslinuxmountoptions.c:612)
|
||||||
|
by 0x12CC6E: udisks_daemon_constructed (udisksdaemon.c:441)
|
||||||
|
by 0x4D1ED96: g_object_new_internal (gobject.c:1985)
|
||||||
|
by 0x4D20227: g_object_new_valist (gobject.c:2288)
|
||||||
|
by 0x4D2075C: g_object_new (gobject.c:1788)
|
||||||
|
by 0x129A5F: udisks_daemon_new (udisksdaemon.c:619)
|
||||||
|
by 0x129AD5: on_bus_acquired (main.c:63)
|
||||||
|
by 0x4C35C95: connection_get_cb.lto_priv.0 (gdbusnameowning.c:504)
|
||||||
|
by 0x4BD3F99: g_task_return_now (gtask.c:1219)
|
||||||
|
by 0x4BD419A: UnknownInlinedFun (gtask.c:1289)
|
||||||
|
by 0x4BD419A: g_task_return (gtask.c:1245)
|
||||||
|
by 0x4C31D51: bus_get_async_initable_cb (gdbusconnection.c:7433)
|
||||||
|
by 0x4BD3F99: g_task_return_now (gtask.c:1219)
|
||||||
|
by 0x4BD3FDC: complete_in_idle_cb (gtask.c:1233)
|
||||||
|
by 0x4DA852A: g_idle_dispatch (gmain.c:5897)
|
||||||
|
by 0x4DAC33E: UnknownInlinedFun (gmain.c:3381)
|
||||||
|
by 0x4DAC33E: g_main_context_dispatch (gmain.c:4099)
|
||||||
|
---
|
||||||
|
src/udiskslinuxmountoptions.c | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/udiskslinuxmountoptions.c b/src/udiskslinuxmountoptions.c
|
||||||
|
index 7729d4015..819c9ba96 100644
|
||||||
|
--- a/src/udiskslinuxmountoptions.c
|
||||||
|
+++ b/src/udiskslinuxmountoptions.c
|
||||||
|
@@ -614,7 +614,6 @@ udisks_linux_mount_options_get_builtin (void)
|
||||||
|
"/org/freedesktop/UDisks2/data/builtin_mount_options.conf",
|
||||||
|
G_RESOURCE_LOOKUP_FLAGS_NONE,
|
||||||
|
&error);
|
||||||
|
- g_resource_unref (daemon_resource);
|
||||||
|
|
||||||
|
if (builtin_opts_bytes == NULL)
|
||||||
|
{
|
@ -0,0 +1,25 @@
|
|||||||
|
From 0edd6f5579c964323d86897aff9476c20d7901ba Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Mon, 22 Nov 2021 14:23:08 +0100
|
||||||
|
Subject: [PATCH] tests: Do not check that writeAmplificationRatio is bigger
|
||||||
|
than 0
|
||||||
|
|
||||||
|
Apparently the bios_in_write value is now 0 for newly created VDO
|
||||||
|
pools and because we use it for the writeAmplificationRatio
|
||||||
|
calculation we get zero too.
|
||||||
|
---
|
||||||
|
src/tests/dbus-tests/test_20_LVM.py | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_20_LVM.py b/src/tests/dbus-tests/test_20_LVM.py
|
||||||
|
index 7fbff0434..fde7c3f3f 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_20_LVM.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_20_LVM.py
|
||||||
|
@@ -508,7 +508,6 @@ def test_create(self):
|
||||||
|
# get statistics and do some simple sanity check
|
||||||
|
stats = lv.GetStatistics(self.no_options, dbus_interface=self.iface_prefix + '.VDOVolume')
|
||||||
|
self.assertIn("writeAmplificationRatio", stats.keys())
|
||||||
|
- self.assertGreater(float(stats["writeAmplificationRatio"]), 0)
|
||||||
|
|
||||||
|
def test_enable_disable_compression_deduplication(self):
|
||||||
|
vgname = 'udisks_test_vdo_vg'
|
@ -1,33 +0,0 @@
|
|||||||
From d747e73aaec2c4e2cf124646230159e8b45a5da8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Tomas Bzatek <tbzatek@redhat.com>
|
|
||||||
Date: Tue, 5 Nov 2024 17:01:00 +0100
|
|
||||||
Subject: [PATCH] lvm2: Try opening for unused device detection harder
|
|
||||||
|
|
||||||
Though the voluntary BSD locks cannot be used here due to opening
|
|
||||||
O_EXCL already, let's make several attempts before bailing out.
|
|
||||||
---
|
|
||||||
modules/lvm2/udiskslvm2daemonutil.c | 9 ++++++++-
|
|
||||||
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/modules/lvm2/udiskslvm2daemonutil.c b/modules/lvm2/udiskslvm2daemonutil.c
|
|
||||||
index b2131f9ca..32736d20f 100644
|
|
||||||
--- a/modules/lvm2/udiskslvm2daemonutil.c
|
|
||||||
+++ b/modules/lvm2/udiskslvm2daemonutil.c
|
|
||||||
@@ -65,9 +65,16 @@ udisks_daemon_util_lvm2_block_is_unused (UDisksBlock *block,
|
|
||||||
{
|
|
||||||
const gchar *device_file;
|
|
||||||
int fd;
|
|
||||||
+ gint num_tries = 0;
|
|
||||||
|
|
||||||
device_file = udisks_block_get_device (block);
|
|
||||||
- fd = open (device_file, O_RDONLY | O_EXCL);
|
|
||||||
+
|
|
||||||
+ while ((fd = open (device_file, O_RDONLY | O_EXCL)) < 0)
|
|
||||||
+ {
|
|
||||||
+ g_usleep (100 * 1000); /* microseconds */
|
|
||||||
+ if (num_tries++ > 10)
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
g_set_error (error, UDISKS_ERROR, UDISKS_ERROR_FAILED,
|
|
@ -0,0 +1,418 @@
|
|||||||
|
From 9fdf616dd3a1dc8d9c17a7cd48995dd11068eedd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tomas Bzatek <tbzatek@redhat.com>
|
||||||
|
Date: Thu, 25 May 2023 14:20:05 +0200
|
||||||
|
Subject: [PATCH] LUKS FIPS fixes
|
||||||
|
|
||||||
|
---
|
||||||
|
src/tests/dbus-tests/test_50_block.py | 8 ++-
|
||||||
|
src/tests/dbus-tests/test_70_encrypted.py | 67 ++++++++++-------------
|
||||||
|
src/tests/integration-test | 30 +++++-----
|
||||||
|
3 files changed, 50 insertions(+), 55 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/tests/dbus-tests/test_50_block.py b/src/tests/dbus-tests/test_50_block.py
|
||||||
|
index 2154eea8..09f8fb95 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_50_block.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_50_block.py
|
||||||
|
@@ -12,6 +12,8 @@ import udiskstestcase
|
||||||
|
class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
||||||
|
'''This is a basic block device test suite'''
|
||||||
|
|
||||||
|
+ LUKS_PASSPHRASE = 'shouldnotseeme'
|
||||||
|
+
|
||||||
|
def _close_luks(self, disk):
|
||||||
|
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
@@ -241,7 +243,7 @@ class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
||||||
|
|
||||||
|
# format the disk
|
||||||
|
disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
|
||||||
|
- disk.Format('xfs', {'encrypt.passphrase': 'test'}, dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
+ disk.Format('xfs', {'encrypt.passphrase': self.LUKS_PASSPHRASE}, dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
|
||||||
|
# cleanup -- close the luks and remove format
|
||||||
|
self.addCleanup(self.wipe_fs, self.vdevs[0])
|
||||||
|
@@ -249,7 +251,7 @@ class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
||||||
|
|
||||||
|
# configuration items as arrays of dbus.Byte
|
||||||
|
opts = self.str_to_ay('verify')
|
||||||
|
- passwd = self.str_to_ay('test')
|
||||||
|
+ passwd = self.str_to_ay(self.LUKS_PASSPHRASE)
|
||||||
|
|
||||||
|
# set the new configuration
|
||||||
|
conf = dbus.Dictionary({'passphrase-contents': passwd,
|
||||||
|
@@ -294,7 +296,7 @@ class UdisksBlockTest(udiskstestcase.UdisksTestCase):
|
||||||
|
|
||||||
|
# format the disk
|
||||||
|
disk = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
|
||||||
|
- disk.Format('xfs', {'encrypt.passphrase': 'test'}, dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
+ disk.Format('xfs', {'encrypt.passphrase': self.LUKS_PASSPHRASE}, dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
|
||||||
|
# cleanup -- close the luks and remove format
|
||||||
|
self.addCleanup(self.wipe_fs, self.vdevs[0])
|
||||||
|
diff --git a/src/tests/dbus-tests/test_70_encrypted.py b/src/tests/dbus-tests/test_70_encrypted.py
|
||||||
|
index effcceac..2f5a8854 100644
|
||||||
|
--- a/src/tests/dbus-tests/test_70_encrypted.py
|
||||||
|
+++ b/src/tests/dbus-tests/test_70_encrypted.py
|
||||||
|
@@ -40,6 +40,9 @@ def _get_blkid_version():
|
||||||
|
class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
'''This is an encrypted device test suite'''
|
||||||
|
|
||||||
|
+ PASSPHRASE = 'shouldnotseeme'
|
||||||
|
+ LUKS_NAME = 'myshinylittleluks'
|
||||||
|
+
|
||||||
|
def _create_luks(self, device, passphrase, binary=False):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@@ -60,7 +63,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
disk_name = os.path.basename(self.vdevs[0])
|
||||||
|
disk = self.get_object('/block_devices/' + disk_name)
|
||||||
|
|
||||||
|
- self._create_luks(disk, 'test')
|
||||||
|
+ self._create_luks(disk, self.PASSPHRASE)
|
||||||
|
self.addCleanup(self._remove_luks, disk)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
@@ -124,7 +127,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
disk_name = os.path.basename(self.vdevs[0])
|
||||||
|
disk = self.get_object('/block_devices/' + disk_name)
|
||||||
|
|
||||||
|
- self._create_luks(disk, 'test')
|
||||||
|
+ self._create_luks(disk, self.PASSPHRASE)
|
||||||
|
self.addCleanup(self._remove_luks, disk)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
@@ -160,11 +163,11 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
# wrong password
|
||||||
|
msg = 'org.freedesktop.UDisks2.Error.Failed: Error unlocking %s *' % self.vdevs[0]
|
||||||
|
with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
- disk.Unlock('shbdkjaf', self.no_options,
|
||||||
|
+ disk.Unlock('abcdefghijklmn', self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
# right password
|
||||||
|
- luks = disk.Unlock('test', self.no_options,
|
||||||
|
+ luks = disk.Unlock(self.PASSPHRASE, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
self.assertIsNotNone(luks)
|
||||||
|
self.assertTrue(os.path.exists('/dev/disk/by-uuid/%s' % luks_uuid))
|
||||||
|
@@ -180,7 +183,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
|
||||||
|
# read-only
|
||||||
|
ro_opts = dbus.Dictionary({'read-only': dbus.Boolean(True)}, signature=dbus.Signature('sv'))
|
||||||
|
- luks = disk.Unlock('test', ro_opts,
|
||||||
|
+ luks = disk.Unlock(self.PASSPHRASE, ro_opts,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
self.assertIsNotNone(luks)
|
||||||
|
self.assertTrue(os.path.exists('/dev/disk/by-uuid/%s' % luks_uuid))
|
||||||
|
@@ -196,13 +199,10 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
crypttab = self.read_file('/etc/crypttab')
|
||||||
|
self.addCleanup(self.write_file, '/etc/crypttab', crypttab)
|
||||||
|
|
||||||
|
- passwd = 'test'
|
||||||
|
- luks_name = 'myshinylittleluks'
|
||||||
|
-
|
||||||
|
disk_name = os.path.basename(self.vdevs[0])
|
||||||
|
disk = self.get_object('/block_devices/' + disk_name)
|
||||||
|
|
||||||
|
- self._create_luks(disk, passwd)
|
||||||
|
+ self._create_luks(disk, self.PASSPHRASE)
|
||||||
|
self.addCleanup(self._remove_luks, disk)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
@@ -212,20 +212,20 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
# add new entry to the crypttab
|
||||||
|
- new_crypttab = crypttab + '%s UUID=%s none\n' % (luks_name, disk_uuid)
|
||||||
|
+ new_crypttab = crypttab + '%s UUID=%s none\n' % (self.LUKS_NAME, disk_uuid)
|
||||||
|
self.write_file('/etc/crypttab', new_crypttab)
|
||||||
|
|
||||||
|
dbus_conf = disk.GetSecretConfiguration(self.no_options, dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
self.assertIsNotNone(dbus_conf)
|
||||||
|
- self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), luks_name)
|
||||||
|
+ self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), self.LUKS_NAME)
|
||||||
|
|
||||||
|
# unlock the device
|
||||||
|
- luks = disk.Unlock(passwd, self.no_options,
|
||||||
|
+ luks = disk.Unlock(self.PASSPHRASE, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
self.assertIsNotNone(luks)
|
||||||
|
|
||||||
|
# unlock should use name from crypttab for the /dev/mapper device
|
||||||
|
- dm_path = '/dev/mapper/%s' % luks_name
|
||||||
|
+ dm_path = '/dev/mapper/%s' % self.LUKS_NAME
|
||||||
|
self.assertTrue(os.path.exists(dm_path))
|
||||||
|
|
||||||
|
# preferred 'device' should be /dev/mapper/name too
|
||||||
|
@@ -240,8 +240,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
crypttab = self.read_file('/etc/crypttab')
|
||||||
|
self.addCleanup(self.write_file, '/etc/crypttab', crypttab)
|
||||||
|
|
||||||
|
- passwd = b'test\0test'
|
||||||
|
- luks_name = 'myshinylittleluks'
|
||||||
|
+ passwd = b'testtesttest\0testtesttest'
|
||||||
|
|
||||||
|
# create key file
|
||||||
|
_fd, key_file = tempfile.mkstemp()
|
||||||
|
@@ -262,12 +261,12 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
# add new entry to the crypttab
|
||||||
|
- new_crypttab = crypttab + '%s UUID=%s %s\n' % (luks_name, disk_uuid, key_file)
|
||||||
|
+ new_crypttab = crypttab + '%s UUID=%s %s\n' % (self.LUKS_NAME, disk_uuid, key_file)
|
||||||
|
self.write_file('/etc/crypttab', new_crypttab)
|
||||||
|
|
||||||
|
dbus_conf = disk.GetSecretConfiguration(self.no_options, dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
self.assertIsNotNone(dbus_conf)
|
||||||
|
- self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), luks_name)
|
||||||
|
+ self.assertEqual(self.ay_to_str(dbus_conf[0][1]['name']), self.LUKS_NAME)
|
||||||
|
self.assertEqual(self.ay_to_str(dbus_conf[0][1]['passphrase-path']), key_file)
|
||||||
|
|
||||||
|
# unlock the device using empty passphrase (should use the key file)
|
||||||
|
@@ -276,7 +275,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
self.assertIsNotNone(luks)
|
||||||
|
|
||||||
|
# unlock should use name from crypttab for the /dev/mapper device
|
||||||
|
- dm_path = '/dev/mapper/%s' % luks_name
|
||||||
|
+ dm_path = '/dev/mapper/%s' % self.LUKS_NAME
|
||||||
|
self.assertTrue(os.path.exists(dm_path))
|
||||||
|
|
||||||
|
# preferred 'device' should be /dev/mapper/name too
|
||||||
|
@@ -289,7 +288,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
disk_name = os.path.basename(self.vdevs[0])
|
||||||
|
disk = self.get_object('/block_devices/' + disk_name)
|
||||||
|
|
||||||
|
- self._create_luks(disk, 'test')
|
||||||
|
+ self._create_luks(disk, self.PASSPHRASE)
|
||||||
|
self.addCleanup(self._remove_luks, disk)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
@@ -316,11 +315,11 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
disk_name = os.path.basename(self.vdevs[0])
|
||||||
|
disk = self.get_object('/block_devices/' + disk_name)
|
||||||
|
|
||||||
|
- self._create_luks(disk, 'test')
|
||||||
|
+ self._create_luks(disk, self.PASSPHRASE)
|
||||||
|
self.addCleanup(self._remove_luks, disk)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
- disk.ChangePassphrase('test', 'password', self.no_options,
|
||||||
|
+ disk.ChangePassphrase(self.PASSPHRASE, self.PASSPHRASE + '222', self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
disk.Lock(self.no_options, dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
@@ -328,11 +327,11 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
# old password, should fail
|
||||||
|
msg = 'org.freedesktop.UDisks2.Error.Failed: Error unlocking %s *' % self.vdevs[0]
|
||||||
|
with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
||||||
|
- disk.Unlock('test', self.no_options,
|
||||||
|
+ disk.Unlock(self.PASSPHRASE, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
# new password
|
||||||
|
- luks = disk.Unlock('password', self.no_options,
|
||||||
|
+ luks = disk.Unlock(self.PASSPHRASE + '222', self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
self.assertIsNotNone(luks)
|
||||||
|
|
||||||
|
@@ -343,7 +342,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
|
||||||
|
def test_resize(self):
|
||||||
|
device = self.get_device(self.vdevs[0])
|
||||||
|
- self._create_luks(device, 'test')
|
||||||
|
+ self._create_luks(device, self.PASSPHRASE)
|
||||||
|
self.addCleanup(self._remove_luks, device)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
@@ -372,8 +371,6 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
fstab = self.read_file('/etc/fstab')
|
||||||
|
self.addCleanup(self.write_file, '/etc/fstab', fstab)
|
||||||
|
|
||||||
|
- passphrase = 'test'
|
||||||
|
-
|
||||||
|
disk_name = os.path.basename(self.vdevs[0])
|
||||||
|
disk = self.get_object('/block_devices/' + disk_name)
|
||||||
|
|
||||||
|
@@ -384,7 +381,7 @@ class UdisksEncryptedTest(udiskstestcase.UdisksTestCase):
|
||||||
|
self.assertIsNotNone(part)
|
||||||
|
|
||||||
|
# create LUKS on the partition and add it to crypttab
|
||||||
|
- self._create_luks(part, passphrase)
|
||||||
|
+ self._create_luks(part, self.PASSPHRASE)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
conf = dbus.Dictionary({'name': self.str_to_ay('udisks_luks_test'),
|
||||||
|
@@ -521,10 +518,8 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
||||||
|
super(UdisksEncryptedTestLUKS2, self).setUp()
|
||||||
|
|
||||||
|
def test_resize(self):
|
||||||
|
- passwd = 'test'
|
||||||
|
-
|
||||||
|
device = self.get_device(self.vdevs[0])
|
||||||
|
- self._create_luks(device, passwd)
|
||||||
|
+ self._create_luks(device, self.PASSPHRASE)
|
||||||
|
self.addCleanup(self._remove_luks, device)
|
||||||
|
self.udev_settle()
|
||||||
|
|
||||||
|
@@ -550,7 +545,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
||||||
|
|
||||||
|
# right passphrase
|
||||||
|
d = dbus.Dictionary(signature='sv')
|
||||||
|
- d['passphrase'] = passwd
|
||||||
|
+ d['passphrase'] = self.PASSPHRASE
|
||||||
|
device.Resize(dbus.UInt64(100*1024*1024), d,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
@@ -559,7 +554,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
||||||
|
|
||||||
|
# resize back to the original size (using binary passphrase)
|
||||||
|
d = dbus.Dictionary(signature='sv')
|
||||||
|
- d['keyfile_contents'] = self.str_to_ay(passwd, False)
|
||||||
|
+ d['keyfile_contents'] = self.str_to_ay(self.PASSPHRASE, False)
|
||||||
|
device.Resize(dbus.UInt64(clear_size), d,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
|
||||||
|
@@ -577,7 +572,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
||||||
|
|
||||||
|
# create LUKS without specifying version
|
||||||
|
options = dbus.Dictionary(signature='sv')
|
||||||
|
- options['encrypt.passphrase'] = 'test'
|
||||||
|
+ options['encrypt.passphrase'] = self.PASSPHRASE
|
||||||
|
|
||||||
|
disk.Format('xfs', options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Block')
|
||||||
|
@@ -613,14 +608,12 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
||||||
|
|
||||||
|
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
|
||||||
|
def test_integrity(self):
|
||||||
|
- passwd = 'test'
|
||||||
|
-
|
||||||
|
cryptsetup_version = _get_cryptsetup_version()
|
||||||
|
if cryptsetup_version < LooseVersion('2.2.0'):
|
||||||
|
self.skipTest('Integrity devices are not marked as internal in cryptsetup < 2.2.0')
|
||||||
|
|
||||||
|
device = self.get_device(self.vdevs[0])
|
||||||
|
- self._create_luks_integrity(self.vdevs[0], passwd)
|
||||||
|
+ self._create_luks_integrity(self.vdevs[0], self.PASSPHRASE)
|
||||||
|
|
||||||
|
self.addCleanup(self._remove_luks, device)
|
||||||
|
self.udev_settle()
|
||||||
|
@@ -630,7 +623,7 @@ class UdisksEncryptedTestLUKS2(UdisksEncryptedTest):
|
||||||
|
# the device is not opened, we need to read the UUID from LUKS metadata
|
||||||
|
luks_uuid = BlockDev.crypto_luks_uuid(self.vdevs[0])
|
||||||
|
|
||||||
|
- luks_path = device.Unlock('test', self.no_options,
|
||||||
|
+ luks_path = device.Unlock(self.PASSPHRASE, self.no_options,
|
||||||
|
dbus_interface=self.iface_prefix + '.Encrypted')
|
||||||
|
self.assertIsNotNone(luks_path)
|
||||||
|
self.assertTrue(os.path.exists('/dev/disk/by-uuid/%s' % luks_uuid))
|
||||||
|
diff --git a/src/tests/integration-test b/src/tests/integration-test
|
||||||
|
index 4499a6a9..71955559 100755
|
||||||
|
--- a/src/tests/integration-test
|
||||||
|
+++ b/src/tests/integration-test
|
||||||
|
@@ -1336,7 +1336,7 @@ class Luks(UDisksTestCase):
|
||||||
|
|
||||||
|
def setup_crypto_device(self):
|
||||||
|
self.fs_create(None, 'ext4', GLib.Variant('a{sv}', {
|
||||||
|
- 'encrypt.passphrase': GLib.Variant('s', 's3kr1t'),
|
||||||
|
+ 'encrypt.passphrase': GLib.Variant('s', 's3kr1ts3kr1t'),
|
||||||
|
'label': GLib.Variant('s', 'treasure')}))
|
||||||
|
self.client.settle()
|
||||||
|
crypt_obj = self.client.get_object(self.udisks_block().get_object_path())
|
||||||
|
@@ -1347,7 +1347,7 @@ class Luks(UDisksTestCase):
|
||||||
|
@staticmethod
|
||||||
|
def unlock_crypto_device(encrypted):
|
||||||
|
return encrypted.call_unlock_sync(
|
||||||
|
- 's3kr1t', no_options, None)
|
||||||
|
+ 's3kr1ts3kr1t', no_options, None)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
"""clean up behind failed test cases"""
|
||||||
|
@@ -1415,7 +1415,7 @@ class Luks(UDisksTestCase):
|
||||||
|
udev_dump = subprocess.Popen(['udevadm', 'info', '--export-db'],
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
out = udev_dump.communicate()[0]
|
||||||
|
- self.assertFalse(b's3kr1t' in out, 'password in udev properties')
|
||||||
|
+ self.assertFalse(b's3kr1ts3kr1t' in out, 'password in udev properties')
|
||||||
|
self.assertFalse(b'essiv:sha' in out, 'key information in udev properties')
|
||||||
|
|
||||||
|
finally:
|
||||||
|
@@ -1525,18 +1525,18 @@ class Luks(UDisksTestCase):
|
||||||
|
encrypted = self.setup_crypto_device()
|
||||||
|
# wrong password, has bytes after a trailing '\0'
|
||||||
|
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
||||||
|
- '', Luks.keyfile_options(b's3kr1t\0X'), None)
|
||||||
|
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\0X'), None)
|
||||||
|
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
||||||
|
- '', Luks.keyfile_options(b's3kr1t\n'), None)
|
||||||
|
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\n'), None)
|
||||||
|
# correct password, specified as keyfile
|
||||||
|
- encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1t'), None)
|
||||||
|
+ encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1ts3kr1t'), None)
|
||||||
|
encrypted.call_lock_sync(no_options, None)
|
||||||
|
|
||||||
|
def test_plaintext_keyfile(self):
|
||||||
|
"""Setup a device using a plaintext keyfile."""
|
||||||
|
# Using a plaintext keyfile should be equivalent to passphrase
|
||||||
|
self.fs_create(None, 'ext4', GLib.Variant('a{sv}', {
|
||||||
|
- 'encrypt.passphrase': GLib.Variant('ay', _bytes_to_ay(b's3kr1t')),
|
||||||
|
+ 'encrypt.passphrase': GLib.Variant('ay', _bytes_to_ay(b's3kr1ts3kr1t')),
|
||||||
|
'label': GLib.Variant('s', 'treasure')}))
|
||||||
|
|
||||||
|
crypt_obj = self.client.get_object(self.udisks_block().get_object_path())
|
||||||
|
@@ -1547,16 +1547,16 @@ class Luks(UDisksTestCase):
|
||||||
|
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
||||||
|
'h4ckpassword', no_options, None)
|
||||||
|
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
||||||
|
- '', Luks.keyfile_options(b's3kr1t\0X'), None)
|
||||||
|
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\0X'), None)
|
||||||
|
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
||||||
|
- '', Luks.keyfile_options(b's3kr1t\n'), None)
|
||||||
|
+ '', Luks.keyfile_options(b's3kr1ts3kr1t\n'), None)
|
||||||
|
|
||||||
|
# correct password
|
||||||
|
- encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1t'), None)
|
||||||
|
+ encrypted.call_unlock_sync('', Luks.keyfile_options(b's3kr1ts3kr1t'), None)
|
||||||
|
encrypted.call_lock_sync(no_options, None)
|
||||||
|
|
||||||
|
# correct password, specified as passphrase
|
||||||
|
- encrypted.call_unlock_sync('s3kr1t', no_options, None)
|
||||||
|
+ encrypted.call_unlock_sync('s3kr1ts3kr1t', no_options, None)
|
||||||
|
encrypted.call_lock_sync(no_options, None)
|
||||||
|
|
||||||
|
def test_binary_keyfile(self):
|
||||||
|
@@ -1622,11 +1622,11 @@ class Luks(UDisksTestCase):
|
||||||
|
encrypted = self.setup_crypto_device()
|
||||||
|
|
||||||
|
# change: passphrase -> passphrase
|
||||||
|
- encrypted.call_change_passphrase_sync('s3kr1t', 'passphrase', no_options, None)
|
||||||
|
+ encrypted.call_change_passphrase_sync('s3kr1ts3kr1t', 'passphrase', no_options, None)
|
||||||
|
|
||||||
|
# verify new password:
|
||||||
|
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
||||||
|
- 's3kr1t', no_options, None)
|
||||||
|
+ 's3kr1ts3kr1t', no_options, None)
|
||||||
|
encrypted.call_unlock_sync('passphrase', no_options, None)
|
||||||
|
encrypted.call_lock_sync(no_options, None)
|
||||||
|
|
||||||
|
@@ -1659,7 +1659,7 @@ class Luks(UDisksTestCase):
|
||||||
|
|
||||||
|
# change: keyfile -> passphrase
|
||||||
|
encrypted.call_change_passphrase_sync(
|
||||||
|
- '', 's3kr1t', GLib.Variant('a{sv}', {
|
||||||
|
+ '', 's3kr1ts3kr1t', GLib.Variant('a{sv}', {
|
||||||
|
'old_keyfile_contents': GLib.Variant('ay', _bytes_to_ay(key_file_1)),
|
||||||
|
}),
|
||||||
|
None)
|
||||||
|
@@ -1667,7 +1667,7 @@ class Luks(UDisksTestCase):
|
||||||
|
# verify new password:
|
||||||
|
self.assertRaises(GLib.GError, encrypted.call_unlock_sync,
|
||||||
|
'', Luks.keyfile_options(key_file_1), None)
|
||||||
|
- encrypted.call_unlock_sync('s3kr1t', no_options, None)
|
||||||
|
+ encrypted.call_unlock_sync('s3kr1ts3kr1t', no_options, None)
|
||||||
|
encrypted.call_lock_sync(no_options, None)
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
2.39.1
|
||||||
|
|
@ -0,0 +1,11 @@
|
|||||||
|
diff -up udisks-2.9.4/src/tests/dbus-tests/test_job.py.bak udisks-2.9.4/src/tests/dbus-tests/test_job.py
|
||||||
|
--- udisks-2.9.4/src/tests/dbus-tests/test_job.py.bak 2021-09-29 18:00:31.000000000 +0200
|
||||||
|
+++ udisks-2.9.4/src/tests/dbus-tests/test_job.py 2023-06-02 15:14:50.691620552 +0200
|
||||||
|
@@ -51,6 +51,7 @@ class UdisksJobTest(udiskstestcase.Udisk
|
||||||
|
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
+ @udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
|
||||||
|
def test_job(self):
|
||||||
|
'''Test basic Job functionality and properties'''
|
||||||
|
|
Loading…
Reference in new issue