New version 2.26

- Add missing plugins to the default config (vtrefny)
- remove unused variable and fix build with LLVM/clang (tpgxyz)
- exec: Fix deprecated glib function call Glib will rename "g_spawn_check_exit_status()" to "g_spawn_check_wait_status()" in version 2.69. (manuel.wassermann97)
- tests: Tag LvmPVVGLVcachePoolCreateRemoveTestCase as unstable (vtrefny)
- tests: Force remove LVM VG /dev/ entry not removed by vgremove (vtrefny)
- tests: Do not try to remove VG before removing the VDO pool (vtrefny)
- crypto: Let cryptsetup autodect encryption sector size when not specified (vtrefny)
- Fix skipping tests on Debian testing (vtrefny)
- tests: Temporarily skip test_snapshotcreate_lvorigin_snapshotmerge (vtrefny)
- tests: Do not check that XFS shrink fails with xfsprogs >= 5.12 (vtrefny)
- tests: Make sure the test temp mount is always unmounted (vtrefny)
- swap: Fix memory leak (vtrefny)
- mdraid: Fix memory leak (vtrefny)
- lvm-dbus: Fix memory leak (vtrefny)
- kbd: Fix memory leak (vtrefny)
- fs: Fix memory leak (vtrefny)
- dm: Fix memory leak in the DM plugin and DM logging redirect function (vtrefny)
- crypto: Fix memory leak (vtrefny)
- kbd: Fix memory leak (vtrefny)
- tests: Call fs_vfat_mkfs with "--mbr=n" extra option in tests (vtrefny)
- fs: Allow using empty label for vfat with newest dosfstools (vtrefny)
- vdo: Do not use g_memdup in bd_vdo_stats_copy (vtrefny)
- crypto: Fix default key size for non XTS ciphers (vtrefny)
- NEWS.rts: Fix markup (vtrefny)
This commit is contained in:
Vojtech Trefny 2021-07-28 09:05:24 +02:00
parent 8572706548
commit dc016e8925
7 changed files with 30 additions and 340 deletions

1
.gitignore vendored
View File

@ -46,3 +46,4 @@
/libblockdev-2.23.tar.gz /libblockdev-2.23.tar.gz
/libblockdev-2.24.tar.gz /libblockdev-2.24.tar.gz
/libblockdev-2.25.tar.gz /libblockdev-2.25.tar.gz
/libblockdev-2.26.tar.gz

View File

@ -1,27 +0,0 @@
From 2da13152619ee7233650339797657b45088b2219 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 18 Aug 2020 09:44:29 +0200
Subject: [PATCH] dm: Fix comparing DM RAID member devices UUID
There is no "UUID" property in UDev we must use the "ID_FS_UUID"
one.
This comparison works only because most DM RAID members don't have
UUID so the check is skipped, but it fails for DDF RAID members
which have a special GUID/UUID in UDev database.
---
src/plugins/dm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/dm.c b/src/plugins/dm.c
index a6412028..4ab0d2a4 100644
--- a/src/plugins/dm.c
+++ b/src/plugins/dm.c
@@ -482,7 +482,7 @@ static gboolean raid_dev_matches_spec (struct raid_dev *raid_dev, const gchar *n
context = udev_new ();
device = udev_device_new_from_subsystem_sysname (context, "block", dev_name);
- dev_uuid = udev_device_get_property_value (device, "UUID");
+ dev_uuid = udev_device_get_property_value (device, "ID_FS_UUID");
major_str = udev_device_get_property_value (device, "MAJOR");
minor_str = udev_device_get_property_value (device, "MINOR");

View File

@ -1,119 +0,0 @@
From a29d25fdfdcd7b133052eab1a3d1defe12c1733f Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 10 Jun 2020 17:03:28 +0200
Subject: [PATCH] exec: Fix setting locale for util calls
This actually fixes two issue. The _utils_exec_and_report_progress
function didn't set the LC_ALL=C environment variable to make sure
we get output in English. And also we shouldn't use setenv in the
GSpawnChildSetupFunc, it's actually example of what not to do in
g_spawn_async documentation. This fix uses g_environ_setenv and
passes the new environment to the g_spawn call.
---
src/utils/exec.c | 26 +++++++++++++++++---------
tests/utils_test.py | 7 +++++++
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/utils/exec.c b/src/utils/exec.c
index 9293930..37bd960 100644
--- a/src/utils/exec.c
+++ b/src/utils/exec.c
@@ -140,11 +140,6 @@ static void log_done (guint64 task_id, gint exit_code) {
return;
}
-static void set_c_locale(gpointer user_data __attribute__((unused))) {
- if (setenv ("LC_ALL", "C", 1) != 0)
- g_warning ("Failed to set LC_ALL=C for a child process!");
-}
-
/**
* bd_utils_exec_and_report_error:
* @argv: (array zero-terminated=1): the argv array for the call
@@ -194,6 +189,8 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr
const BDExtraArg **extra_p = NULL;
gint exit_status = 0;
guint i = 0;
+ gchar **old_env = NULL;
+ gchar **new_env = NULL;
if (extra) {
args_len = g_strv_length ((gchar **) argv);
@@ -219,16 +216,20 @@ gboolean bd_utils_exec_and_report_status_error (const gchar **argv, const BDExtr
args[i] = NULL;
}
+ old_env = g_get_environ ();
+ new_env = g_environ_setenv (old_env, "LC_ALL", "C", TRUE);
+
task_id = log_running (args ? args : argv);
- success = g_spawn_sync (NULL, args ? (gchar **) args : (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH,
- (GSpawnChildSetupFunc) set_c_locale, NULL,
- &stdout_data, &stderr_data, &exit_status, error);
+ success = g_spawn_sync (NULL, args ? (gchar **) args : (gchar **) argv, new_env, G_SPAWN_SEARCH_PATH,
+ NULL, NULL, &stdout_data, &stderr_data, &exit_status, error);
if (!success) {
/* error is already populated from the call */
+ g_strfreev (new_env);
g_free (stdout_data);
g_free (stderr_data);
return FALSE;
}
+ g_strfreev (new_env);
/* g_spawn_sync set the status in the same way waitpid() does, we need
to get the process exit code manually (this is similar to calling
@@ -297,6 +298,8 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt
gboolean err_done = FALSE;
GString *stdout_data = g_string_new (NULL);
GString *stderr_data = g_string_new (NULL);
+ gchar **old_env = NULL;
+ gchar **new_env = NULL;
/* TODO: share this code between functions */
if (extra) {
@@ -325,7 +328,10 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt
task_id = log_running (args ? args : argv);
- ret = g_spawn_async_with_pipes (NULL, args ? (gchar**) args : (gchar**) argv, NULL,
+ old_env = g_get_environ ();
+ new_env = g_environ_setenv (old_env, "LC_ALL", "C", TRUE);
+
+ ret = g_spawn_async_with_pipes (NULL, args ? (gchar**) args : (gchar**) argv, new_env,
G_SPAWN_DEFAULT|G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, &pid, NULL, &out_fd, &err_fd, error);
@@ -333,9 +339,11 @@ static gboolean _utils_exec_and_report_progress (const gchar **argv, const BDExt
/* error is already populated */
g_string_free (stdout_data, TRUE);
g_string_free (stderr_data, TRUE);
+ g_strfreev (new_env);
g_free (args);
return FALSE;
}
+ g_strfreev (new_env);
args_str = g_strjoinv (" ", args ? (gchar **) args : (gchar **) argv);
msg = g_strdup_printf ("Started '%s'", args_str);
diff --git a/tests/utils_test.py b/tests/utils_test.py
index 4bec3db..2bec5ed 100644
--- a/tests/utils_test.py
+++ b/tests/utils_test.py
@@ -170,6 +170,13 @@ class UtilsExecLoggingTest(UtilsTestCase):
# exit code != 0
self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util-fail", "1.1", "version", "Version:\\s(.*)"))
+ @tag_test(TestTags.NOSTORAGE, TestTags.CORE)
+ def test_exec_locale(self):
+ """Verify that setting locale for exec functions works as expected"""
+
+ succ, out = BlockDev.utils_exec_and_capture_output(["locale"])
+ self.assertTrue(succ)
+ self.assertIn("LC_ALL=C", out)
class UtilsDevUtilsTestCase(UtilsTestCase):
@tag_test(TestTags.NOSTORAGE, TestTags.CORE)
--
2.26.2

View File

@ -1,166 +0,0 @@
From d05deed377b4e793c8c319eb028b8343fb317586 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 16 Jun 2021 16:15:38 +0200
Subject: [PATCH] crypto: Let cryptsetup autodect encryption sector size when
not specified
Thanks to this 4k sector size will be used on 4k drives.
---
configure.ac | 2 +
src/plugins/crypto.h | 6 +++
tests/crypto_test.py | 93 ++++++++++++++++++++++++++++++++++++++------
3 files changed, 89 insertions(+), 12 deletions(-)
diff --git a/configure.ac b/configure.ac
index abe1412..ad71a46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -211,6 +211,8 @@ AS_IF([test "x$with_crypto" != "xno"],
[AC_DEFINE([LIBCRYPTSETUP_2])], [])
AS_IF([$PKG_CONFIG --atleast-version=2.3.0 libcryptsetup],
[AC_DEFINE([LIBCRYPTSETUP_BITLK])], [])
+ AS_IF([$PKG_CONFIG --atleast-version=2.4.0 libcryptsetup],
+ [AC_DEFINE([LIBCRYPTSETUP_24])], [])
AS_IF([test "x$with_escrow" != "xno"],
[LIBBLOCKDEV_PKG_CHECK_MODULES([NSS], [nss >= 3.18.0])
LIBBLOCKDEV_CHECK_HEADER([volume_key/libvolume_key.h], [$GLIB_CFLAGS $NSS_CFLAGS], [libvolume_key.h not available])],
diff --git a/src/plugins/crypto.h b/src/plugins/crypto.h
index 71a1438..fef1e73 100644
--- a/src/plugins/crypto.h
+++ b/src/plugins/crypto.h
@@ -38,7 +38,13 @@ typedef enum {
#define DEFAULT_LUKS_KEYSIZE_BITS 512
#define DEFAULT_LUKS_CIPHER "aes-xts-plain64"
+
+#ifdef LIBCRYPTSETUP_24
+/* 0 for autodetect since 2.4.0 */
+#define DEFAULT_LUKS2_SECTOR_SIZE 0
+#else
#define DEFAULT_LUKS2_SECTOR_SIZE 512
+#endif
typedef enum {
BD_CRYPTO_TECH_LUKS = 0,
diff --git a/tests/crypto_test.py b/tests/crypto_test.py
index 0609a07..3e99a2d 100644
--- a/tests/crypto_test.py
+++ b/tests/crypto_test.py
@@ -16,26 +16,18 @@ PASSWD = "myshinylittlepassword"
PASSWD2 = "myshinylittlepassword2"
PASSWD3 = "myshinylittlepassword3"
-def have_luks2():
- try:
- succ = BlockDev.utils_check_util_version("cryptsetup", "2.0.3", "--version", r"cryptsetup ([0-9+\.]+)")
- except GLib.GError:
- return False
- else:
- return succ
-
-def have_bitlk():
+def check_cryptsetup_version(version):
try:
- succ = BlockDev.utils_check_util_version("cryptsetup", "2.3.0", "--version", r"cryptsetup ([0-9+\.]+)")
+ succ = BlockDev.utils_check_util_version("cryptsetup", version, "--version", r"cryptsetup ([0-9+\.]+)")
except GLib.GError:
return False
else:
return succ
-HAVE_LUKS2 = have_luks2()
-HAVE_BITLK = have_bitlk()
+HAVE_LUKS2 = check_cryptsetup_version("2.0.3")
+HAVE_BITLK = check_cryptsetup_version("2.3.0")
class CryptoTestCase(unittest.TestCase):
@@ -928,6 +920,83 @@ class CryptoTestInfo(CryptoTestCase):
succ = BlockDev.crypto_luks_close("libblockdevTestLUKS")
self.assertTrue(succ)
+
+class CryptoTestLuksSectorSize(CryptoTestCase):
+ def setUp(self):
+ if not check_cryptsetup_version("2.4.0"):
+ self.skipTest("cryptsetup encryption sector size not available, skipping.")
+
+ # we need a loop devices for this test case
+ self.addCleanup(self._clean_up)
+ self.dev_file = create_sparse_tempfile("crypto_test", 1024**3)
+ self.dev_file2 = create_sparse_tempfile("crypto_test", 1024**3)
+
+ succ, loop = BlockDev.loop_setup(self.dev_file)
+ if not succ:
+ raise RuntimeError("Failed to setup loop device for testing")
+ self.loop_dev = "/dev/%s" % loop
+
+ succ, loop = BlockDev.loop_setup(self.dev_file)
+ if not succ:
+ raise RuntimeError("Failed to setup loop device for testing")
+ self.loop_dev2 = "/dev/%s" % loop
+
+ # set sector size of the loop device to 4k
+ ret, _out, _err = run_command("losetup --sector-size 4096 %s" % self.loop_dev)
+ self.assertEqual(ret, 0)
+
+ def _clean_up(self):
+ try:
+ BlockDev.crypto_luks_close("libblockdevTestLUKS")
+ except:
+ pass
+
+ BlockDev.loop_teardown(self.loop_dev)
+ os.unlink(self.dev_file)
+
+ BlockDev.loop_teardown(self.loop_dev2)
+ os.unlink(self.dev_file2)
+
+ @tag_test(TestTags.SLOW)
+ @unittest.skipUnless(HAVE_LUKS2, "LUKS 2 not supported")
+ def test_luks2_sector_size_autodetect(self):
+ """Verify that we can autodetect 4k drives and set 4k sector size for them"""
+
+ # format the 4k loop device, encryption sector size should default to 4096
+ succ = BlockDev.crypto_luks_format(self.loop_dev, "aes-cbc-essiv:sha256", 256, PASSWD, None, 0,
+ BlockDev.CryptoLUKSVersion.LUKS2)
+ self.assertTrue(succ)
+
+ succ = BlockDev.crypto_luks_open(self.loop_dev, "libblockdevTestLUKS", PASSWD, None, False)
+ self.assertTrue(succ)
+
+ info = BlockDev.crypto_luks_info("libblockdevTestLUKS")
+ self.assertIsNotNone(info)
+
+ self.assertEqual(info.version, BlockDev.CryptoLUKSVersion.LUKS2)
+ self.assertEqual(info.sector_size, 4096)
+
+ succ = BlockDev.crypto_luks_close("libblockdevTestLUKS")
+ self.assertTrue(succ)
+
+ # with the 512 loop device, we should still get 512
+ succ = BlockDev.crypto_luks_format(self.loop_dev2, "aes-cbc-essiv:sha256", 256, PASSWD, None, 0,
+ BlockDev.CryptoLUKSVersion.LUKS2)
+ self.assertTrue(succ)
+
+ succ = BlockDev.crypto_luks_open(self.loop_dev2, "libblockdevTestLUKS", PASSWD, None, False)
+ self.assertTrue(succ)
+
+ info = BlockDev.crypto_luks_info("libblockdevTestLUKS")
+ self.assertIsNotNone(info)
+
+ self.assertEqual(info.version, BlockDev.CryptoLUKSVersion.LUKS2)
+ self.assertEqual(info.sector_size, 512)
+
+ succ = BlockDev.crypto_luks_close("libblockdevTestLUKS")
+ self.assertTrue(succ)
+
+
class CryptoTestIntegrity(CryptoTestCase):
@tag_test(TestTags.SLOW)
@unittest.skipUnless(HAVE_LUKS2, "LUKS 2 not supported")
--
2.31.1

View File

@ -1,15 +0,0 @@
diff --git a/src/plugins/kbd.c b/src/plugins/kbd.c
index a2908ec..97abd3b 100644
--- a/src/plugins/kbd.c
+++ b/src/plugins/kbd.c
@@ -732,6 +732,10 @@ static gboolean wait_for_file (const char *filename) {
*
* Tech category: %BD_KBD_TECH_BCACHE-%BD_KBD_TECH_MODE_CREATE
*/
+/* This triggers a known false positive warning in gcc-11. It's being
+ addressed upstream, but until the fix is available, this works around
+ the false positive. */
+__attribute__ ((optimize ("-O1")))
gboolean bd_kbd_bcache_create (const gchar *backing_device, const gchar *cache_device, const BDExtraArg **extra, const gchar **bcache_device, GError **error) {
const gchar *argv[6] = {"make-bcache", "-B", backing_device, "-C", cache_device, NULL};
gboolean success = FALSE;

View File

@ -124,15 +124,12 @@
%define configure_opts %{?python2_copts} %{?python3_copts} %{?bcache_copts} %{?lvm_dbus_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?kbd_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?vdo_copts} %{?tools_copts} %{?gi_copts} %define configure_opts %{?python2_copts} %{?python3_copts} %{?bcache_copts} %{?lvm_dbus_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?kbd_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?vdo_copts} %{?tools_copts} %{?gi_copts}
Name: libblockdev Name: libblockdev
Version: 2.25 Version: 2.26
Release: 5%{?dist} Release: 1%{?dist}
Summary: A library for low-level manipulation with block devices Summary: A library for low-level manipulation with block devices
License: LGPLv2+ License: LGPLv2+
URL: https://github.com/storaged-project/libblockdev URL: https://github.com/storaged-project/libblockdev
Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz
Patch0: libblockdev-gcc11.patch
Patch1: 0001-Fix-comparing-DM-RAID-member-devices-UUID.patch
Patch2: 0002-Let-cryptsetup-autodect-encryption-sector-size.patch
BuildRequires: make BuildRequires: make
BuildRequires: glib2-devel BuildRequires: glib2-devel
@ -391,8 +388,6 @@ BuildRequires: device-mapper-devel
Summary: The LVM plugin for the libblockdev library Summary: The LVM plugin for the libblockdev library
Requires: %{name}-utils%{?_isa} >= 0.11 Requires: %{name}-utils%{?_isa} >= 0.11
Requires: lvm2 Requires: lvm2
# for thin_metadata_size
Requires: device-mapper-persistent-data
%description lvm %description lvm
The libblockdev library plugin (and in the same time a standalone library) The libblockdev library plugin (and in the same time a standalone library)
@ -415,8 +410,6 @@ BuildRequires: device-mapper-devel
Summary: The LVM plugin for the libblockdev library Summary: The LVM plugin for the libblockdev library
Requires: %{name}-utils%{?_isa} >= 1.4 Requires: %{name}-utils%{?_isa} >= 1.4
Requires: lvm2-dbusd >= 2.02.156 Requires: lvm2-dbusd >= 2.02.156
# for thin_metadata_size
Requires: device-mapper-persistent-data
%description lvm-dbus %description lvm-dbus
The libblockdev library plugin (and in the same time a standalone library) The libblockdev library plugin (and in the same time a standalone library)
@ -684,9 +677,6 @@ A meta-package that pulls all the libblockdev plugins as dependencies.
%prep %prep
%setup -q -n %{name}-%{version} %setup -q -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build %build
autoreconf -ivf autoreconf -ivf
@ -990,6 +980,32 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files plugins-all %files plugins-all
%changelog %changelog
* Wed Jul 28 2021 Vojtech Trefny <vtrefny@redhat.com> - 2.26-1
- Add missing plugins to the default config (vtrefny)
- remove unused variable and fix build with LLVM/clang (tpgxyz)
- exec: Fix deprecated glib function call Glib will rename "g_spawn_check_exit_status()" to "g_spawn_check_wait_status()" in version 2.69. (manuel.wassermann97)
- tests: Tag LvmPVVGLVcachePoolCreateRemoveTestCase as unstable (vtrefny)
- tests: Force remove LVM VG /dev/ entry not removed by vgremove (vtrefny)
- tests: Do not try to remove VG before removing the VDO pool (vtrefny)
- crypto: Let cryptsetup autodect encryption sector size when not specified (vtrefny)
- Fix skipping tests on Debian testing (vtrefny)
- tests: Temporarily skip test_snapshotcreate_lvorigin_snapshotmerge (vtrefny)
- tests: Do not check that XFS shrink fails with xfsprogs >= 5.12 (vtrefny)
- tests: Make sure the test temp mount is always unmounted (vtrefny)
- swap: Fix memory leak (vtrefny)
- mdraid: Fix memory leak (vtrefny)
- lvm-dbus: Fix memory leak (vtrefny)
- kbd: Fix memory leak (vtrefny)
- fs: Fix memory leak (vtrefny)
- dm: Fix memory leak in the DM plugin and DM logging redirect function (vtrefny)
- crypto: Fix memory leak (vtrefny)
- kbd: Fix memory leak (vtrefny)
- tests: Call fs_vfat_mkfs with "--mbr=n" extra option in tests (vtrefny)
- fs: Allow using empty label for vfat with newest dosfstools (vtrefny)
- vdo: Do not use g_memdup in bd_vdo_stats_copy (vtrefny)
- crypto: Fix default key size for non XTS ciphers (vtrefny)
- NEWS.rts: Fix markup (vtrefny)
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.25-5 * Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.25-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (libblockdev-2.25.tar.gz) = 628d05f3a257b44208a9d0b5d84ae248fefd415812d9a93d132c03039b09fefc4d6110beb9aa0d3072e3f0c992e642d7867d0241209056538f132f86a748e195 SHA512 (libblockdev-2.26.tar.gz) = ddd4e9c22135bd7dad0bb9bc254ac0c63e3bacc592e7c5a0c846e367da3fc248bf6187f1c81407c3bce599d3b0ceeec9a8a0030ad8e981e245f715b35eaec523