From a7fd6be34dac9ddbd8f399c8a4475a5a7304cafe Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 7 Feb 2024 09:58:37 -0500 Subject: [PATCH 01/30] Increase retry dependency lower bound to 2.0.0 Signed-off-by: mulhern --- Cargo.lock | 10 +++++-- Cargo.toml | 2 +- src/engine/strat_engine/thinpool/mdv.rs | 40 ++++++++++++------------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8caddeca09..442da691bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -356,7 +356,7 @@ dependencies = [ "log", "nix 0.26.2", "rand", - "retry", + "retry 1.3.1", "semver", "serde", ] @@ -1152,6 +1152,12 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac95c60a949a63fd2822f4964939662d8f2c16c4fa0624fd954bc6e703b9a3f6" +[[package]] +name = "retry" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9166d72162de3575f950507683fac47e30f6f2c3836b71b7fbc61aa517c9c5f4" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1315,7 +1321,7 @@ dependencies = [ "proptest", "rand", "regex", - "retry", + "retry 2.0.0", "semver", "serde", "serde_derive", diff --git a/Cargo.toml b/Cargo.toml index 5d1d623497..6c01ff9744 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,7 +172,7 @@ version = "1.5.4" optional = true [dependencies.retry] -version = "1.3.1" +version = "2.0.0" default-features = false optional = true diff --git a/src/engine/strat_engine/thinpool/mdv.rs b/src/engine/strat_engine/thinpool/mdv.rs index 56687f950a..3c90fe3411 100644 --- a/src/engine/strat_engine/thinpool/mdv.rs +++ b/src/engine/strat_engine/thinpool/mdv.rs @@ -191,17 +191,16 @@ impl MetadataVol { /// Tear down a Metadata Volume. pub fn teardown(&mut self, pool_uuid: PoolUuid) -> StratisResult<()> { - if let Err(e) = retry_with_index(Fixed::from_millis(100).take(2), |i| { - trace!("MDV unmount attempt {}", i); - umount(&self.mount_pt) - }) { - return Err(match e { - retry::Error::Internal(msg) => StratisError::Msg(msg), - retry::Error::Operation { error, .. } => StratisError::Chained( - "Failed to unmount MDV".to_string(), - Box::new(StratisError::from(error)), - ), - }); + if let Err(retry::Error { error, .. }) = + retry_with_index(Fixed::from_millis(100).take(2), |i| { + trace!("MDV unmount attempt {}", i); + umount(&self.mount_pt) + }) + { + return Err(StratisError::Chained( + "Failed to unmount MDV".to_string(), + Box::new(StratisError::from(error)), + )); } if let Err(err) = remove_dir(&self.mount_pt) { @@ -266,17 +265,16 @@ impl Drop for MetadataVol { }; if mtpt_stat.st_dev != parent_stat.st_dev { - if let Err(e) = retry_with_index(Fixed::from_millis(100).take(2), |i| { - trace!("MDV unmount attempt {}", i); - umount(mount_pt) - }) { - Err(match e { - retry::Error::Internal(msg) => StratisError::Msg(msg), - retry::Error::Operation { error, .. } => StratisError::Chained( - "Failed to unmount MDV".to_string(), - Box::new(StratisError::from(error)), - ), + if let Err(retry::Error { error, .. }) = + retry_with_index(Fixed::from_millis(100).take(2), |i| { + trace!("MDV unmount attempt {}", i); + umount(mount_pt) }) + { + Err(StratisError::Chained( + "Failed to unmount MDV".to_string(), + Box::new(StratisError::from(error)), + )) } else { Ok(()) } From fd16e06540c986af8564e05dbb63e5ebbe8466a9 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 19 Feb 2024 20:31:19 -0500 Subject: [PATCH 02/30] Increase bindgen dependency lower bound to 0.69.0 Signed-off-by: mulhern --- Cargo.lock | 30 +++++++++++++++++++++++++----- Cargo.toml | 2 +- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 442da691bb..14aac16068 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,6 +133,26 @@ dependencies = [ "syn 2.0.29", ] +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.4.0", + "cexpr", + "clang-sys", + "itertools 0.12.0", + "lazy_static", + "lazycell", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.29", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -367,7 +387,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734fba4d2e6b551396439ea7dd4f56980b11bb096bbf505d4a259943b228367b" dependencies = [ - "bindgen", + "bindgen 0.68.1", ] [[package]] @@ -717,7 +737,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "163068067b2faf263fb2fc3daff137b45608ee185044ca849dc41438aa38e23a" dependencies = [ - "bindgen", + "bindgen 0.68.1", "cc", ] @@ -751,7 +771,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20fc299fd05078d353a895d940fc463d1008d94258fc8096c095467549324707" dependencies = [ - "bindgen", + "bindgen 0.68.1", "cc", "pkg-config", "semver", @@ -831,7 +851,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "378e7ca4e85e592564e6a96c362303972b5c7860367014383aadc10a8704fc38" dependencies = [ - "bindgen", + "bindgen 0.68.1", "errno", "libc", ] @@ -1291,7 +1311,7 @@ dependencies = [ "assert_cmd", "assert_matches", "async-trait", - "bindgen", + "bindgen 0.69.4", "byteorder", "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 6c01ff9744..f51b7c3d6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,7 +225,7 @@ pkg-config = "0.3.18" [build-dependencies.bindgen] default_features = false features = ["runtime"] -version = "0.68.1" +version = "0.69.0" optional = true [dev-dependencies] From 06705bcbe2e8e132095f1e67612f5c81958fad67 Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 7 Mar 2024 10:30:58 -0500 Subject: [PATCH 03/30] Update a comment justifying the minimum thin dev size Signed-off-by: mulhern --- src/engine/shared.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/shared.rs b/src/engine/shared.rs index c52686393c..2895db6c78 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -32,8 +32,10 @@ const DEFAULT_THIN_DEV_SIZE: Sectors = Sectors(2 * IEC::Gi); // 1 TiB #[cfg(test)] pub const DEFAULT_THIN_DEV_SIZE: Sectors = Sectors(2 * IEC::Gi); // 1 TiB -// xfs is planning to reject making "small" filesystems: -// https://www.spinics.net/lists/linux-xfs/msg59453.html +// Current versions of xfs now reject "small" filesystems: +// The data section of the filesystem must be at least 300 MiB. +// A Stratis imposed minimum of 512 MiB allows sufficient space for XFS +// metadata. const MIN_THIN_DEV_SIZE: Sectors = Sectors(IEC::Mi); // 512 MiB /// Called when the name of a requested pool coincides with the name of an From b955769aaed65cc397b036a64f6cae855b486423 Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 7 Mar 2024 13:25:46 -0500 Subject: [PATCH 04/30] Use a constant for the maximum name size Signed-off-by: mulhern --- src/engine/shared.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/shared.rs b/src/engine/shared.rs index 2895db6c78..8c8d3a2de8 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -38,6 +38,11 @@ pub const DEFAULT_THIN_DEV_SIZE: Sectors = Sectors(2 * IEC::Gi); // 1 TiB // metadata. const MIN_THIN_DEV_SIZE: Sectors = Sectors(IEC::Mi); // 512 MiB +// Linux has a maximum filename length of 255 bytes. We use this length +// as a cap on the size of the pool name also. This ensures that the name +// serialized in the pool-level metadata has a bounded length. +const MAXIMUM_NAME_SIZE: usize = 255; + /// Called when the name of a requested pool coincides with the name of an /// existing pool. Returns an error if the specifications of the requested /// pool differ from the specifications of the existing pool, otherwise @@ -143,10 +148,9 @@ pub fn validate_name(name: &str) -> StratisResult<()> { if name == "." || name == ".." { return Err(StratisError::Msg(format!("Name is . or .. : {name}"))); } - // Linux has a maximum filename length of 255 bytes - if name.len() > 255 { + if name.len() > MAXIMUM_NAME_SIZE { return Err(StratisError::Msg(format!( - "Name has more than 255 bytes: {name}" + "Name has more than {MAXIMUM_NAME_SIZE} bytes: {name}" ))); } if name.len() != name.trim().len() { From 40712799e25d5f8c7a73a49ffd30903746e24e8c Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 7 Mar 2024 13:45:57 -0500 Subject: [PATCH 05/30] Do not construct a String from metadata when saving Where the metadata is written, the as_bytes() method just extracts the vec from the String struct. Just make a vec of the metadata, and pass a reference to that vec when saving. Signed-off-by: mulhern --- src/engine/strat_engine/pool.rs | 10 ++++------ src/engine/strat_engine/thinpool/mdv.rs | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/engine/strat_engine/pool.rs b/src/engine/strat_engine/pool.rs index 4a8d1ee930..0f36bc13b6 100644 --- a/src/engine/strat_engine/pool.rs +++ b/src/engine/strat_engine/pool.rs @@ -324,8 +324,8 @@ impl StratPool { /// Write current metadata to pool members. #[pool_mutating_action("NoPoolChanges")] pub fn write_metadata(&mut self, name: &str) -> StratisResult<()> { - let data = serde_json::to_string(&self.record(name))?; - self.backstore.save_state(data.as_bytes()) + let data = serde_json::to_vec(&self.record(name))?; + self.backstore.save_state(&data) } /// Teardown a pool. @@ -433,10 +433,8 @@ impl StratPool { self.thin_pool.teardown(pool_uuid)?; let mut data = self.record(pool_name); data.started = Some(false); - let json = serde_json::to_string(&data).map_err(|e| (StratisError::from(e), false))?; - self.backstore - .save_state(json.as_bytes()) - .map_err(|e| (e, false))?; + let json = serde_json::to_vec(&data).map_err(|e| (StratisError::from(e), false))?; + self.backstore.save_state(&json).map_err(|e| (e, false))?; self.backstore.teardown(pool_uuid).map_err(|e| (e, false))?; let bds = self.backstore.drain_bds(); Ok(DeviceSet::from(bds)) diff --git a/src/engine/strat_engine/thinpool/mdv.rs b/src/engine/strat_engine/thinpool/mdv.rs index 3c90fe3411..94f1d2a14f 100644 --- a/src/engine/strat_engine/thinpool/mdv.rs +++ b/src/engine/strat_engine/thinpool/mdv.rs @@ -110,7 +110,7 @@ impl MetadataVol { uuid: FilesystemUuid, fs: &StratFilesystem, ) -> StratisResult<()> { - let data = serde_json::to_string(&fs.record(name, uuid))?; + let data = serde_json::to_vec(&fs.record(name, uuid))?; let path = self .mount_pt .join(FILESYSTEM_DIR) @@ -125,7 +125,7 @@ impl MetadataVol { .create(true) .open(&temp_path)?; - mdv_record_file.write_all(data.as_bytes())?; + mdv_record_file.write_all(&data)?; // This ultimately results in an fsync() on the file. mdv_record_file.sync_all()?; } From 7cd1aa0f77a02ddaa01276db4ef2e4397e12d12f Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 11 Mar 2024 19:06:41 -0400 Subject: [PATCH 06/30] Cargo.toml: Set up workspace table This will cause stratisd_proc_macros dependencies to be included in the vendor tarfile and the Fedora generated requires and will allow us to package stratisd with stratisd_proc_macros as a path dependency. Signed-off-by: mulhern --- .packit.yaml | 4 ++-- Cargo.toml | 14 +++++++++++--- stratisd_proc_macros/Cargo.toml | 6 +++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.packit.yaml b/.packit.yaml index cf30df4a2f..1a29f97b32 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -12,14 +12,14 @@ actions: post-upstream-clone: - "git clone https://github.com/stratis-storage/ci --depth=1 ../distro" - "mv ../distro/mockbuild_test/stratisd.spec ../distro/stratisd.spec" - - "cargo install cargo-version-util" + - "cargo install cargo-get" - "cargo install cargo-vendor-filterer" create-archive: - "sh -c 'python3 ../distro/release_management/create_artifacts.py ../distro/ --pre-release --specfile-path=../distro/stratisd.spec stratisd --vendor-method=filtered'" fix-spec-file: - "echo 'skipping automatic fix-spec-file actions'" get-current-version: - - "cargo version-util get-version" + - "cargo get package.version" srpm_build_deps: - git diff --git a/Cargo.toml b/Cargo.toml index f51b7c3d6a..b6b0a630c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "stratisd" version = "3.6.5" -authors = ["Stratis Developers "] -edition = "2021" -rust-version = "1.71.1" # LOWEST SUPPORTED RUST TOOLCHAIN +authors.workspace = true +edition.workspace = true +rust-version.workspace = true build = "build.rs" description = "Stratis daemon" license = "MPL-2.0" @@ -31,6 +31,14 @@ exclude = [ "/udev" ] +[workspace] +members = [".", "stratisd_proc_macros"] + +[workspace.package] +authors = ["Stratis Developers "] +edition = "2021" +rust-version = "1.71.1" # LOWEST SUPPORTED RUST TOOLCHAIN + [[bin]] name = "stratisd" required-features = ["engine"] diff --git a/stratisd_proc_macros/Cargo.toml b/stratisd_proc_macros/Cargo.toml index e8327a185b..64987b7611 100644 --- a/stratisd_proc_macros/Cargo.toml +++ b/stratisd_proc_macros/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "stratisd_proc_macros" version = "0.2.1" -authors = ["Stratis Developers "] -edition = "2021" -rust-version = "1.71.1" # LOWEST SUPPORTED RUST TOOLCHAIN +authors.workspace = true +edition.workspace = true +rust-version.workspace = true description = "Stratis daemon procedural macros" license = "MPL-2.0" repository = "https://github.com/stratis-storage/stratisd/" From dc9aeaffea6e7ffe5a16cc88f2e47ca5fd1f80d5 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Tue, 12 Mar 2024 14:28:13 -0400 Subject: [PATCH 07/30] github actions: update FEDORA_RELEASE to F40, F39 Signed-off-by: Bryan Gurney --- .github/workflows/cargo.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index 0b25005186..2f7c0bbed8 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -57,6 +57,6 @@ jobs: - name: Run comparisons of version specs with available Fedora packages # yamllint disable rule:line-length run: | - COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=rawhide IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper" make -f Makefile_dependencies check-fedora-versions - COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f39 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper" make -f Makefile_dependencies check-fedora-versions - COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f38 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper" make -f Makefile_dependencies check-fedora-versions + COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=rawhide IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper --ignore-high=libblkid-rs" make -f Makefile_dependencies check-fedora-versions + COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f40 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper --ignore-high=libblkid-rs" make -f Makefile_dependencies check-fedora-versions + COMPARE_FEDORA_VERSIONS=./ci/dependency_management/compare_fedora_versions FEDORA_RELEASE=f39 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs --ignore-high=libcryptsetup-rs-sys --ignore-high=devicemapper --ignore-high=libblkid-rs" make -f Makefile_dependencies check-fedora-versions From 4fddda5d650dadcfef555280907913e85a78067e Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 12 Mar 2024 20:13:51 -0400 Subject: [PATCH 08/30] Add serializer for Strings The serializer will limit the length of every string in the metadata to a maximum allowed value. The vector of thin pool feature args does not get this treatment because they are really keys, represented as strings and are read from the device mapper table or set by stratisd. Signed-off-by: mulhern --- src/engine/strat_engine/serde_structs.rs | 72 +++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/engine/strat_engine/serde_structs.rs b/src/engine/strat_engine/serde_structs.rs index f77693509a..2e41b970f0 100644 --- a/src/engine/strat_engine/serde_structs.rs +++ b/src/engine/strat_engine/serde_structs.rs @@ -12,12 +12,58 @@ // can convert to or from them when saving our current state, or // restoring state from saved metadata. -use serde::Serialize; +use serde::{Serialize, Serializer}; use devicemapper::{Sectors, ThinDevId}; use crate::engine::types::{DevUuid, FilesystemUuid}; +const MAXIMUM_STRING_SIZE: usize = 255; + +// Find the largest index which occurs on a char boundary of value which is no +// greater than len. +// TODO: Replace this method with String::floor_char_boundary when +// possible. +fn our_floor_char_boundary(value: &str, len: usize) -> usize { + let len = std::cmp::min(len, value.len()); + + let mut new_index = len; + while !value.is_char_boundary(new_index) && new_index != 0 { + new_index -= 1; + } + + new_index +} + +// Return a new String, split at the highest index which lies on a char +// boundary of value which is no greater than len. +fn safe_split_at(value: &str, len: usize) -> &str { + value.split_at(our_floor_char_boundary(value, len)).0 +} + +// Serialize a string. Only the first MAXIMUM_STRING_SIZE bytes of the string +// are serialized. +fn serialize_string(value: &str, serializer: S) -> Result +where + S: Serializer, +{ + str::serialize(safe_split_at(value, MAXIMUM_STRING_SIZE), serializer) +} + +// Serialize an optional string. Only the first MAXIMUM_STRING_SIZE bytes of +// the string are serialized. +fn serialize_option_string(value: &Option, serializer: S) -> Result +where + S: Serializer, +{ + Option::serialize( + &value + .as_ref() + .map(|v| safe_split_at(v, MAXIMUM_STRING_SIZE)), + serializer, + ) +} + /// Implements saving struct data to a serializable form. The form should be /// sufficient, in conjunction with the environment, to reconstruct the /// saved struct in all its essentials. @@ -31,6 +77,7 @@ pub trait Recordable { // some duplicate type definitions which are obviously not defined twice. #[derive(Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct PoolSave { + #[serde(serialize_with = "serialize_string")] pub name: String, pub backstore: BackstoreSave, pub flex_devs: FlexDevsSave, @@ -70,8 +117,10 @@ pub struct BaseDevSave { pub struct BaseBlockDevSave { pub uuid: DevUuid, #[serde(skip_serializing_if = "Option::is_none")] + #[serde(serialize_with = "serialize_option_string")] pub user_info: Option, #[serde(skip_serializing_if = "Option::is_none")] + #[serde(serialize_with = "serialize_option_string")] pub hardware_info: Option, } @@ -112,6 +161,7 @@ pub struct ThinPoolDevSave { // by stratisd. #[derive(Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct FilesystemSave { + #[serde(serialize_with = "serialize_string")] pub name: String, pub uuid: FilesystemUuid, pub thin_id: ThinDevId, @@ -120,3 +170,23 @@ pub struct FilesystemSave { #[serde(skip_serializing_if = "Option::is_none")] pub fs_size_limit: Option, } + +#[cfg(test)] +mod tests { + use super::safe_split_at; + proptest! { + #[test] + /// Check safe splitting on random strings. + fn test_split(s in "\\PC*", index in 0..10usize) { + let result = safe_split_at(&s, s.len().saturating_sub(index)); + prop_assert_eq!(s.find(result), Some(0)); + // A UTF8 String character requires at most 4 bytes. + prop_assert!(s.len() - result.len() <= index + 3); + + prop_assert!((index == 0 || s.is_empty()) || result.len() < s.len()); + prop_assert!(result.len() != s.len() || (index == 0 || s.is_empty())); + prop_assert!(result.is_char_boundary(result.len())); + + } + } +} From feac03e6ef5845594c829454f10e10e3f303f5f3 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 18 Mar 2024 09:54:34 -0400 Subject: [PATCH 09/30] validate_name: Change error strings The UserInfo will probably be a name of sorts, but it is still best to generalize the string a bit. Signed-off-by: mulhern --- src/engine/shared.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/shared.rs b/src/engine/shared.rs index 8c8d3a2de8..ae65dc748b 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -142,7 +142,7 @@ pub fn set_key_shared(key_fd: RawFd, memory: &mut [u8]) -> StratisResult pub fn validate_name(name: &str) -> StratisResult<()> { if name.contains('\u{0}') { return Err(StratisError::Msg(format!( - "Name contains NULL characters: {name}" + "Provided string contains NULL characters: {name}" ))); } if name == "." || name == ".." { @@ -150,17 +150,17 @@ pub fn validate_name(name: &str) -> StratisResult<()> { } if name.len() > MAXIMUM_NAME_SIZE { return Err(StratisError::Msg(format!( - "Name has more than {MAXIMUM_NAME_SIZE} bytes: {name}" + "Provided string has more than {MAXIMUM_NAME_SIZE} bytes: {name}" ))); } if name.len() != name.trim().len() { return Err(StratisError::Msg(format!( - "Name contains leading or trailing space: {name}" + "Provided string contains leading or trailing space: {name}" ))); } if name.chars().any(|c| c.is_control()) { return Err(StratisError::Msg(format!( - "Name contains control characters: {name}" + "Provided string contains control characters: {name}" ))); } lazy_static! { @@ -169,19 +169,19 @@ pub fn validate_name(name: &str) -> StratisResult<()> { } if NAME_UDEVREGEX.is_match(name) { return Err(StratisError::Msg(format!( - "Name contains characters not allowed in udev symlinks: {name}" + "Provided string contains characters not allowed in udev symlinks: {name}" ))); } let name_path = Path::new(name); if name_path.components().count() != 1 { return Err(StratisError::Msg(format!( - "Name is a path with 0 or more than 1 components: {name}" + "Provided string is a path with 0 or more than 1 components: {name}" ))); } if name_path.is_absolute() { return Err(StratisError::Msg(format!( - "Name is an absolute path: {name}" + "Provided string is an absolute path: {name}" ))); } Ok(()) From 9ef2fb26b4eaf44efbf229d247faede7334bf437 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 18 Mar 2024 12:50:00 -0400 Subject: [PATCH 10/30] vaidate_name: Clarify some error messages Return early if the name is just empty. Simplify the messaging where the name can be interpreted as a directory path. Signed-off-by: mulhern --- src/engine/shared.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/engine/shared.rs b/src/engine/shared.rs index ae65dc748b..1a490ea265 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -140,6 +140,12 @@ pub fn set_key_shared(key_fd: RawFd, memory: &mut [u8]) -> StratisResult /// Validate a str for use as a Pool or Filesystem name. pub fn validate_name(name: &str) -> StratisResult<()> { + if name.is_empty() { + return Err(StratisError::Msg(format!( + "Provided string is empty: {name}" + ))); + } + if name.contains('\u{0}') { return Err(StratisError::Msg(format!( "Provided string contains NULL characters: {name}" @@ -174,14 +180,9 @@ pub fn validate_name(name: &str) -> StratisResult<()> { } let name_path = Path::new(name); - if name_path.components().count() != 1 { - return Err(StratisError::Msg(format!( - "Provided string is a path with 0 or more than 1 components: {name}" - ))); - } - if name_path.is_absolute() { + if name_path.components().count() > 1 || name_path.is_absolute() { return Err(StratisError::Msg(format!( - "Provided string is an absolute path: {name}" + "Provided string is a directory path: {name}" ))); } Ok(()) From 8f662531d99512f5ce106e294acb7fa110cdc82d Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 18 Mar 2024 09:32:29 -0400 Subject: [PATCH 11/30] Reject UserInfo values that do not satisfy validate_name Signed-off-by: mulhern --- src/engine/sim_engine/pool.rs | 1 + src/engine/strat_engine/pool.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/engine/sim_engine/pool.rs b/src/engine/sim_engine/pool.rs index d6b7dda5c9..d16a6f4847 100644 --- a/src/engine/sim_engine/pool.rs +++ b/src/engine/sim_engine/pool.rs @@ -628,6 +628,7 @@ impl Pool for SimPool { uuid: DevUuid, user_info: Option<&str>, ) -> StratisResult> { + user_info.map(validate_name).transpose()?; Ok(self.get_mut_blockdev_internal(uuid).map_or_else( || RenameAction::NoSource, |(_, b)| { diff --git a/src/engine/strat_engine/pool.rs b/src/engine/strat_engine/pool.rs index 0f36bc13b6..75fdd71085 100644 --- a/src/engine/strat_engine/pool.rs +++ b/src/engine/strat_engine/pool.rs @@ -1133,6 +1133,7 @@ impl Pool for StratPool { uuid: DevUuid, user_info: Option<&str>, ) -> StratisResult> { + user_info.map(validate_name).transpose()?; let result = self.backstore.set_blockdev_user_info(uuid, user_info); match result { Ok(Some(uuid)) => { From a838a0a77bab67379d672bb0f9854f6b43c6e588 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 11:21:31 -0400 Subject: [PATCH 12/30] Fix clippy::useless-vec lint Signed-off-by: Bryan Gurney --- src/engine/strat_engine/liminal/setup.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/strat_engine/liminal/setup.rs b/src/engine/strat_engine/liminal/setup.rs index c648f38bb1..90f6e056ec 100644 --- a/src/engine/strat_engine/liminal/setup.rs +++ b/src/engine/strat_engine/liminal/setup.rs @@ -84,7 +84,7 @@ pub fn get_name(infos: HashMap) -> StratisResult>(); match get_metadata(infos)? { Some((_, pool)) => { - let v = vec![]; + let v = []; let meta_uuids = pool .backstore .data_tier From 030f9356b95f47e6b92b63bd83270806fe15defa Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 11:26:05 -0400 Subject: [PATCH 13/30] Fix let-underscore-lock lint Signed-off-by: Bryan Gurney --- src/engine/structures/lock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/structures/lock.rs b/src/engine/structures/lock.rs index a849a28b9b..201dc1120b 100644 --- a/src/engine/structures/lock.rs +++ b/src/engine/structures/lock.rs @@ -516,7 +516,7 @@ where /// This counter performs wrapping addition so the maximum number of futures supported by /// this lock is u64::MAX. fn next_idx(&self) -> u64 { - let (mut lock_record, _) = self.acquire_mutex(); + let (mut lock_record, _unused) = self.acquire_mutex(); let idx = lock_record.next_idx; lock_record.next_idx = lock_record.next_idx.wrapping_add(1); idx From b8839e4328b30da5a064da089ea7ac19e9a47d35 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 13:31:52 -0400 Subject: [PATCH 14/30] Use explicit OpenOptions::truncate() Signed-off-by: Bryan Gurney --- src/engine/strat_engine/pool.rs | 3 +++ src/engine/strat_engine/tests/loopbacked.rs | 1 + src/engine/strat_engine/thinpool/mdv.rs | 1 + src/engine/strat_engine/thinpool/thinpool.rs | 5 +++++ 4 files changed, 10 insertions(+) diff --git a/src/engine/strat_engine/pool.rs b/src/engine/strat_engine/pool.rs index 75fdd71085..754a1899f0 100644 --- a/src/engine/strat_engine/pool.rs +++ b/src/engine/strat_engine/pool.rs @@ -1377,6 +1377,7 @@ mod tests { .unwrap(); OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(&new_file) .unwrap() @@ -1685,6 +1686,7 @@ mod tests { let mut f = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(); @@ -1760,6 +1762,7 @@ mod tests { let mut f = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(); diff --git a/src/engine/strat_engine/tests/loopbacked.rs b/src/engine/strat_engine/tests/loopbacked.rs index ae6229874e..2fbcc96c50 100644 --- a/src/engine/strat_engine/tests/loopbacked.rs +++ b/src/engine/strat_engine/tests/loopbacked.rs @@ -54,6 +54,7 @@ impl LoopTestDev { .read(true) .write(true) .create(true) + .truncate(true) .open(path) .unwrap(); diff --git a/src/engine/strat_engine/thinpool/mdv.rs b/src/engine/strat_engine/thinpool/mdv.rs index 94f1d2a14f..70da2b8825 100644 --- a/src/engine/strat_engine/thinpool/mdv.rs +++ b/src/engine/strat_engine/thinpool/mdv.rs @@ -123,6 +123,7 @@ impl MetadataVol { let mut mdv_record_file = OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(&temp_path)?; mdv_record_file.write_all(&data)?; diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index df7f446cb7..d3b58f8889 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -1947,6 +1947,7 @@ mod tests { convert_test!(IEC::Mi, u64, usize), OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(file_path) .unwrap(), @@ -2095,6 +2096,7 @@ mod tests { convert_test!(IEC::Mi, u64, usize), OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(file_path) .unwrap(), @@ -2268,6 +2270,7 @@ mod tests { writeln!( &OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(), @@ -2478,6 +2481,7 @@ mod tests { .unwrap(); OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(&new_file) .unwrap() @@ -2602,6 +2606,7 @@ mod tests { .unwrap(); let mut file = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(new_file) .unwrap(); From 77d92804ccf230aa34218cc11ff8a70b51c5575c Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 15:26:00 -0400 Subject: [PATCH 15/30] get_dm_init: Allow static_mut_refs Signed-off-by: Bryan Gurney --- src/engine/strat_engine/dm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/strat_engine/dm.rs b/src/engine/strat_engine/dm.rs index 960e978f56..74023cbeeb 100644 --- a/src/engine/strat_engine/dm.rs +++ b/src/engine/strat_engine/dm.rs @@ -25,6 +25,7 @@ static mut DM_CONTEXT: Option> = None; /// Path to logical devices for encrypted devices pub const DEVICEMAPPER_PATH: &str = "/dev/mapper"; +#[allow(static_mut_refs)] pub fn get_dm_init() -> StratisResult<&'static DM> { unsafe { INIT.call_once(|| DM_CONTEXT = Some(DM::new())); From afdbc022cf4853928893a52bfbb0e6f2e01755ca Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 15:27:32 -0400 Subject: [PATCH 16/30] DeviceInfo: allow clippy lint large_enum_variant Signed-off-by: Bryan Gurney --- src/engine/strat_engine/liminal/identify.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/strat_engine/liminal/identify.rs b/src/engine/strat_engine/liminal/identify.rs index ca6acb08d9..b03e96122c 100644 --- a/src/engine/strat_engine/liminal/identify.rs +++ b/src/engine/strat_engine/liminal/identify.rs @@ -150,6 +150,7 @@ impl fmt::Display for StratisInfo { /// An enum type to distinguish between LUKS devices belong to Stratis and /// Stratis devices. #[derive(Debug, Eq, Hash, PartialEq)] +#[allow(clippy::large_enum_variant)] pub enum DeviceInfo { Luks(LuksInfo), Stratis(StratisInfo), From 4992bdf130c39da240eb65036886722148747e1e Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 15:29:00 -0400 Subject: [PATCH 17/30] stratisd: Allow clippy lint suspicious_open_options Signed-off-by: Bryan Gurney --- src/bin/stratisd.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bin/stratisd.rs b/src/bin/stratisd.rs index ca68555a50..337f4c9418 100644 --- a/src/bin/stratisd.rs +++ b/src/bin/stratisd.rs @@ -52,6 +52,8 @@ fn initialize_log(log_level: Option<&str>) { /// To ensure only one instance of stratisd runs at a time, acquire an /// exclusive lock. Return an error if lock attempt fails. fn trylock_pid_file() -> StratisResult { + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) @@ -81,6 +83,8 @@ fn trylock_pid_file() -> StratisResult { } }; + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) From 759e48dfed8a80a36c36721500a179f4c42b0dd4 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 15:30:01 -0400 Subject: [PATCH 18/30] stratisd-min: Allow clippy lint suspicious_open_options Signed-off-by: Bryan Gurney --- src/bin/stratis-min/stratisd-min.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bin/stratis-min/stratisd-min.rs b/src/bin/stratis-min/stratisd-min.rs index c44fac79cf..0e2caac764 100644 --- a/src/bin/stratis-min/stratisd-min.rs +++ b/src/bin/stratis-min/stratisd-min.rs @@ -44,6 +44,8 @@ fn parse_args() -> Command { /// To ensure only one instance of stratisd runs at a time, acquire an /// exclusive lock. Return an error if lock attempt fails. fn trylock_pid_file() -> StratisResult { + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) @@ -75,6 +77,8 @@ fn trylock_pid_file() -> StratisResult { } }; + #[allow(unknown_lints)] + #[allow(clippy::suspicious_open_options)] let mut f = OpenOptions::new() .read(true) .write(true) From d185a19b22ca7024c9ee3d0dcd70c5155afbb74d Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 15:32:33 -0400 Subject: [PATCH 19/30] generators: Use explicit OpenOptions::truncate() Signed-off-by: Bryan Gurney --- src/bin/utils/generators/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/utils/generators/lib.rs b/src/bin/utils/generators/lib.rs index a68357627a..e5768e6036 100644 --- a/src/bin/utils/generators/lib.rs +++ b/src/bin/utils/generators/lib.rs @@ -70,7 +70,11 @@ pub fn get_kernel_cmdline() -> Result>>, io:: } pub fn write_unit_file(dest: &Path, file_contents: String) -> Result<(), io::Error> { - let mut file = OpenOptions::new().write(true).create(true).open(dest)?; + let mut file = OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(dest)?; file.write_all(file_contents.as_bytes())?; Ok(()) } From cd9166e2fa6e0c88d561cf23bae88168321d2673 Mon Sep 17 00:00:00 2001 From: Bryan Gurney Date: Thu, 21 Mar 2024 15:48:57 -0400 Subject: [PATCH 20/30] Allow unknown lint for static_mut_refs Signed-off-by: Bryan Gurney --- src/engine/strat_engine/dm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/strat_engine/dm.rs b/src/engine/strat_engine/dm.rs index 74023cbeeb..a7589a21f3 100644 --- a/src/engine/strat_engine/dm.rs +++ b/src/engine/strat_engine/dm.rs @@ -25,6 +25,7 @@ static mut DM_CONTEXT: Option> = None; /// Path to logical devices for encrypted devices pub const DEVICEMAPPER_PATH: &str = "/dev/mapper"; +#[allow(unknown_lints)] #[allow(static_mut_refs)] pub fn get_dm_init() -> StratisResult<&'static DM> { unsafe { From e960a5902314f066fa6dd53b96a9b3b5bae4a9ce Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 21 Mar 2024 17:32:22 -0400 Subject: [PATCH 21/30] validate_filesystem_size: divisble -> divisible Signed-off-by: mulhern --- src/engine/shared.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/shared.rs b/src/engine/shared.rs index 1a490ea265..a98480b1a8 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -218,7 +218,7 @@ pub fn validate_filesystem_size( let size_sectors = size.sectors(); if size_sectors.bytes() != size { Err(StratisError::Msg(format!( - "Requested size or size limit of filesystem {name} must be divisble by {SECTOR_SIZE}" + "Requested size or size limit of filesystem {name} must be divisible by {SECTOR_SIZE}" ))) } else if size_sectors < MIN_THIN_DEV_SIZE { Err(StratisError::Msg(format!( From 38f079c253496f52687bf1ea3a0acaeb09c6b4a1 Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 21 Mar 2024 18:29:36 -0400 Subject: [PATCH 22/30] validate_filesystem_size: return more specific error Return a specific error when the filesystem size specified is just too big. Small enough is still quite big, a smidge less than 8 ZiB. Signed-off-by: mulhern --- src/engine/shared.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/shared.rs b/src/engine/shared.rs index a98480b1a8..3cf804a28e 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -215,6 +215,13 @@ pub fn validate_filesystem_size( ) -> StratisResult> { size_opt .map(|size| { + let max_size = Sectors(u64::MAX).bytes(); + if size > max_size { + return Err(StratisError::Msg(format!( + "Requested size or size limit of filesystem {name} exceeds maximum specifiable filesystem size {max_size}" + ))); + } + let size_sectors = size.sectors(); if size_sectors.bytes() != size { Err(StratisError::Msg(format!( From 45740d5ce946c19505e3695835be7bcb23bee6f6 Mon Sep 17 00:00:00 2001 From: mulhern Date: Fri, 1 Mar 2024 08:45:38 -0500 Subject: [PATCH 23/30] Increase env_logger dependency lower bound to 0.11.0 Signed-off-by: mulhern --- Cargo.lock | 161 +++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- 2 files changed, 138 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14aac16068..e5fccfd5f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,17 +35,31 @@ dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", - "anstyle-wincon", + "anstyle-wincon 1.0.1", "colorchoice", "is-terminal", "utf8parse", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon 3.0.2", + "colorchoice", + "utf8parse", +] + [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -62,7 +76,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -72,7 +86,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", ] [[package]] @@ -278,7 +302,7 @@ version = "4.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae" dependencies = [ - "anstream", + "anstream 0.3.2", "anstyle", "bitflags 1.3.2", "clap_lex", @@ -371,7 +395,7 @@ checksum = "9ff98688149bf6128f259f0009f98eb8ad82584aa0aae143081fdfde513d3d13" dependencies = [ "bitflags 2.4.0", "devicemapper-sys", - "env_logger", + "env_logger 0.10.0", "lazy_static", "log", "nix 0.26.2", @@ -418,6 +442,16 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" version = "0.10.0" @@ -431,6 +465,19 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" +dependencies = [ + "anstream 0.6.13", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "errno" version = "0.3.1" @@ -439,7 +486,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -653,7 +700,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.2", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -671,7 +718,7 @@ dependencies = [ "hermit-abi 0.3.2", "io-lifetimes", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -894,7 +941,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1195,7 +1242,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1321,7 +1368,7 @@ dependencies = [ "dbus-tree", "devicemapper", "either", - "env_logger", + "env_logger 0.11.2", "futures", "iocuddle", "itertools 0.12.0", @@ -1402,7 +1449,7 @@ dependencies = [ "fastrand", "redox_syscall", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1443,7 +1490,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1609,7 +1656,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", ] [[package]] @@ -1618,7 +1665,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.4", ] [[package]] @@ -1627,13 +1683,28 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] [[package]] @@ -1642,38 +1713,80 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" diff --git a/Cargo.toml b/Cargo.toml index b6b0a630c8..692583fb0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,7 +114,7 @@ version = "1.6.1" optional = true [dependencies.env_logger] -version ="0.10.0" +version ="0.11.0" optional = true [dependencies.futures] From eac3b413a5d68436229022d29ea8cb30feac6a66 Mon Sep 17 00:00:00 2001 From: John Baublitz Date: Mon, 25 Mar 2024 12:08:54 -0400 Subject: [PATCH 24/30] Fix PID file bug in stratisd and stratisd-min This commit fixes a bug in the Stratis daemons. The bug would theoretically only occur if stratisd gets restarted and reassigned a PID with less digits than the previous PID. This commit truncates the file when we determine there is no other instance of the daemon running to avoid this occuring. --- src/bin/stratis-min/stratisd-min.rs | 1 + src/bin/stratisd.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/bin/stratis-min/stratisd-min.rs b/src/bin/stratis-min/stratisd-min.rs index 0e2caac764..cdf13ae98a 100644 --- a/src/bin/stratis-min/stratisd-min.rs +++ b/src/bin/stratis-min/stratisd-min.rs @@ -61,6 +61,7 @@ fn trylock_pid_file() -> StratisResult { })?; let stratisd_min_file = match flock(f.as_raw_fd(), FlockArg::LockExclusiveNonblock) { Ok(_) => { + f.set_len(0)?; f.write_all(getpid().to_string().as_bytes())?; f } diff --git a/src/bin/stratisd.rs b/src/bin/stratisd.rs index 337f4c9418..37a8e8af11 100644 --- a/src/bin/stratisd.rs +++ b/src/bin/stratisd.rs @@ -67,6 +67,7 @@ fn trylock_pid_file() -> StratisResult { })?; let stratisd_file = match flock(f.as_raw_fd(), FlockArg::LockExclusiveNonblock) { Ok(_) => { + f.set_len(0)?; f.write_all(getpid().to_string().as_bytes())?; Ok(f) } From 5abef24986addbc252f5b5f71347b5664d8e0705 Mon Sep 17 00:00:00 2001 From: mulhern Date: Fri, 22 Mar 2024 21:26:38 -0400 Subject: [PATCH 25/30] Initialize devicemapper context without mutability Signed-off-by: mulhern --- Cargo.lock | 5 +++-- Cargo.toml | 5 +++++ src/engine/strat_engine/dm.rs | 29 ++++++++++++----------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5fccfd5f2..bb316e81f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1021,9 +1021,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "peeking_take_while" @@ -1382,6 +1382,7 @@ dependencies = [ "log", "loopdev-3", "nix 0.27.1", + "once_cell", "pkg-config", "predicates", "pretty-hex", diff --git a/Cargo.toml b/Cargo.toml index 692583fb0b..a222dcb682 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,6 +167,10 @@ version = "0.27.1" optional = true features = ["fs", "ioctl", "mount", "poll", "process", "sched", "signal", "socket"] +[dependencies.once_cell] +version = "1.19.0" +optional = true + [dependencies.pretty-hex] version = "0.4.1" optional = true @@ -266,6 +270,7 @@ engine = [ "libudev", "log", "nix", + "once_cell", "rand", "regex", "retry", diff --git a/src/engine/strat_engine/dm.rs b/src/engine/strat_engine/dm.rs index a7589a21f3..f52aeac67d 100644 --- a/src/engine/strat_engine/dm.rs +++ b/src/engine/strat_engine/dm.rs @@ -4,9 +4,11 @@ // Get ability to instantiate a devicemapper context. -use std::{path::Path, sync::Once}; +use std::path::Path; -use devicemapper::{DevId, DmNameBuf, DmOptions, DmResult, DM}; +use once_cell::sync::Lazy; + +use devicemapper::{DevId, DmError, DmNameBuf, DmOptions, DM}; use crate::{ engine::{ @@ -19,25 +21,18 @@ use crate::{ stratis::{StratisError, StratisResult}, }; -static INIT: Once = Once::new(); -static mut DM_CONTEXT: Option> = None; - /// Path to logical devices for encrypted devices pub const DEVICEMAPPER_PATH: &str = "/dev/mapper"; -#[allow(unknown_lints)] -#[allow(static_mut_refs)] +pub static DM_CONTEXT: Lazy> = Lazy::new(DM::new); + pub fn get_dm_init() -> StratisResult<&'static DM> { - unsafe { - INIT.call_once(|| DM_CONTEXT = Some(DM::new())); - match &DM_CONTEXT { - Some(Ok(ref context)) => Ok(context), - Some(Err(e)) => Err(StratisError::Chained( - "Failed to initialize DM context".to_string(), - Box::new(e.clone().into()), - )), - _ => panic!("DM_CONTEXT.is_some()"), - } + match *DM_CONTEXT { + Ok(ref context) => Ok(context), + Err(ref e) => Err(StratisError::Chained( + "Failed to initialize DM context".to_string(), + Box::new(e.clone().into()), + )), } } From c8c52b74fc3a0f6d7391fd1e3924f038c9a1f3b0 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 25 Mar 2024 17:02:09 -0400 Subject: [PATCH 26/30] Increase nix dependency lower bound to 0.28.0 Allow deprecated use of flock. Signed-off-by: mulhern --- Cargo.lock | 17 ++++++++++++----- Cargo.toml | 2 +- src/bin/stratis-min/stratisd-min.rs | 2 ++ src/bin/stratisd.rs | 2 ++ src/engine/shared.rs | 9 ++++++--- src/jsonrpc/client/key.rs | 2 +- src/jsonrpc/client/pool.rs | 4 ++-- src/jsonrpc/server/server.rs | 6 +++--- src/stratis/udev_monitor.rs | 4 ++-- 9 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb316e81f3..c8ed53e34f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -264,6 +264,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" version = "0.4.26" @@ -790,9 +796,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.149" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libcryptsetup-rs" @@ -973,12 +979,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.4.0", "cfg-if 1.0.0", + "cfg_aliases", "libc", "memoffset 0.9.0", ] @@ -1381,7 +1388,7 @@ dependencies = [ "libudev", "log", "loopdev-3", - "nix 0.27.1", + "nix 0.28.0", "once_cell", "pkg-config", "predicates", diff --git a/Cargo.toml b/Cargo.toml index a222dcb682..ec083a778b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -163,7 +163,7 @@ version = "0.4.19" optional = true [dependencies.nix] -version = "0.27.1" +version = "0.28.0" optional = true features = ["fs", "ioctl", "mount", "poll", "process", "sched", "signal", "socket"] diff --git a/src/bin/stratis-min/stratisd-min.rs b/src/bin/stratis-min/stratisd-min.rs index cdf13ae98a..35cbea64d1 100644 --- a/src/bin/stratis-min/stratisd-min.rs +++ b/src/bin/stratis-min/stratisd-min.rs @@ -2,6 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#![allow(deprecated)] + use std::{ env, error::Error, diff --git a/src/bin/stratisd.rs b/src/bin/stratisd.rs index 37a8e8af11..dfbec47304 100644 --- a/src/bin/stratisd.rs +++ b/src/bin/stratisd.rs @@ -2,6 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#![allow(deprecated)] + use std::{ env, fs::{File, OpenOptions}, diff --git a/src/engine/shared.rs b/src/engine/shared.rs index 3cf804a28e..537b4c73c6 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -6,7 +6,10 @@ use std::{ collections::{hash_map::RandomState, HashMap, HashSet}, fs::File, io::Read, - os::unix::io::{FromRawFd, RawFd}, + os::{ + fd::AsFd, + unix::io::{FromRawFd, RawFd}, + }, path::{Path, PathBuf}, }; @@ -125,8 +128,8 @@ pub fn set_key_shared(key_fd: RawFd, memory: &mut [u8]) -> StratisResult let bytes_read = key_file.read(memory)?; if bytes_read == MAX_STRATIS_PASS_SIZE { - let mut pollers = [PollFd::new(&key_file, PollFlags::POLLIN)]; - let num_events = poll(&mut pollers, 0)?; + let mut pollers = [PollFd::new(key_file.as_fd(), PollFlags::POLLIN)]; + let num_events = poll(&mut pollers, 0u8)?; if num_events > 0 { return Err(StratisError::Msg(format!( "Provided key exceeded maximum allow length of {}", diff --git a/src/jsonrpc/client/key.rs b/src/jsonrpc/client/key.rs index 03497fde11..77372b72c9 100644 --- a/src/jsonrpc/client/key.rs +++ b/src/jsonrpc/client/key.rs @@ -25,7 +25,7 @@ pub fn key_set(key_desc: KeyDescription, keyfile_path: Option<&str>) -> StratisR let (read_end, write_end) = pipe()?; write(write_end, password.as_bytes())?; - do_request!(KeySet, key_desc; read_end) + do_request!(KeySet, key_desc; read_end.as_raw_fd()) } }; if rc != 0 { diff --git a/src/jsonrpc/client/pool.rs b/src/jsonrpc/client/pool.rs index 76766889b4..d85a56096c 100644 --- a/src/jsonrpc/client/pool.rs +++ b/src/jsonrpc/client/pool.rs @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use std::path::PathBuf; +use std::{os::fd::AsRawFd, path::PathBuf}; use nix::unistd::{pipe, write}; @@ -37,7 +37,7 @@ pub fn pool_start( do_request_standard!(PoolStart, id, unlock_method; { let (read_end, write_end) = pipe()?; write(write_end, password.as_bytes())?; - read_end + read_end.as_raw_fd() }) } else { do_request_standard!(PoolStart, id, unlock_method) diff --git a/src/jsonrpc/server/server.rs b/src/jsonrpc/server/server.rs index c13ff90f90..3386ca6d80 100644 --- a/src/jsonrpc/server/server.rs +++ b/src/jsonrpc/server/server.rs @@ -22,8 +22,8 @@ use futures::{ use nix::{ fcntl::{fcntl, FcntlArg, OFlag}, sys::socket::{ - accept, bind, listen, recvmsg, sendmsg, socket, AddressFamily, ControlMessageOwned, - MsgFlags, SockFlag, SockType, UnixAddr, + accept, bind, listen, recvmsg, sendmsg, socket, AddressFamily, Backlog, + ControlMessageOwned, MsgFlags, SockFlag, SockType, UnixAddr, }, unistd::close, }; @@ -444,7 +444,7 @@ impl StratisUnixListener { })?; fcntl(fd.as_raw_fd(), FcntlArg::F_SETFL(flags | OFlag::O_NONBLOCK))?; bind(fd.as_raw_fd(), &UnixAddr::new(path.as_ref())?)?; - listen(&fd, 0)?; + listen(&fd, Backlog::new(0).expect("0 is always valid"))?; Ok(StratisUnixListener { fd: AsyncFd::new(fd)?, }) diff --git a/src/stratis/udev_monitor.rs b/src/stratis/udev_monitor.rs index a840e9631e..99d1b17226 100644 --- a/src/stratis/udev_monitor.rs +++ b/src/stratis/udev_monitor.rs @@ -33,8 +33,8 @@ pub async fn udev_thread( loop { - let mut pollers = [PollFd::new(&udev, PollFlags::POLLIN)]; - match poll(&mut pollers, 100)? { + let mut pollers = [PollFd::new(udev.as_fd(), PollFlags::POLLIN)]; + match poll(&mut pollers, 100u8)? { 0 => { match should_exit.try_recv() { Ok(()) => { From 25cd8a60afe71b0ad9910970acab1e87b34f9414 Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 26 Mar 2024 09:45:39 -0400 Subject: [PATCH 27/30] Increase lower bounds of Stratis-project dependencies Signed-off-by: mulhern --- Cargo.lock | 142 ++++++++++------------------------------------------- Cargo.toml | 10 ++-- 2 files changed, 30 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8ed53e34f..b679164625 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -137,26 +137,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bindgen" -version = "0.68.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" -dependencies = [ - "bitflags 2.4.0", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.29", -] - [[package]] name = "bindgen" version = "0.69.4" @@ -395,29 +375,29 @@ dependencies = [ [[package]] name = "devicemapper" -version = "0.34.0" +version = "0.34.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff98688149bf6128f259f0009f98eb8ad82584aa0aae143081fdfde513d3d13" +checksum = "68d15851812d2feb80b0b51ab7d440927e4a900c16d33b154e64a2828e0d7041" dependencies = [ "bitflags 2.4.0", "devicemapper-sys", - "env_logger 0.10.0", + "env_logger", "lazy_static", "log", - "nix 0.26.2", + "nix 0.28.0", "rand", - "retry 1.3.1", + "retry", "semver", "serde", ] [[package]] name = "devicemapper-sys" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734fba4d2e6b551396439ea7dd4f56980b11bb096bbf505d4a259943b228367b" +checksum = "3d6681f5413e2094480381a97b8299f548c0579f07095ee20fe58e0a28cb34b5" dependencies = [ - "bindgen 0.68.1", + "bindgen", ] [[package]] @@ -458,19 +438,6 @@ dependencies = [ "regex", ] -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.11.2" @@ -774,9 +741,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libblkid-rs" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b43fd7c0de11a5209aff91fb625c118fc15173ae3dd0ac11e8f61a1b4d1a863" +checksum = "c4b9f67fa2e7a372994bd5be702ea51add4fbee90bfcbf1224a88806240cb8f2" dependencies = [ "either", "libblkid-rs-sys", @@ -786,11 +753,11 @@ dependencies = [ [[package]] name = "libblkid-rs-sys" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "163068067b2faf263fb2fc3daff137b45608ee185044ca849dc41438aa38e23a" +checksum = "d8e2a4facc1d764d39c5126817def019f29fca51e965db1bb826f1730c0068d8" dependencies = [ - "bindgen 0.68.1", + "bindgen", "cc", ] @@ -802,9 +769,9 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libcryptsetup-rs" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73d2aa26d63e5289d6fac1e7e0be2e248ded9b5dfb3e2c345820d060c537d4b6" +checksum = "99a61d3782d841dca88244f582cfd95d96da9d175fb06616d50a480058647e39" dependencies = [ "bitflags 2.4.0", "either", @@ -820,11 +787,11 @@ dependencies = [ [[package]] name = "libcryptsetup-rs-sys" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20fc299fd05078d353a895d940fc463d1008d94258fc8096c095467549324707" +checksum = "c78b397341cb9aa5ddc8d11118754ed0eab4aeb9cee96ee7cbe83a7d2867b8d2" dependencies = [ - "bindgen 0.68.1", + "bindgen", "cc", "pkg-config", "semver", @@ -900,11 +867,11 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "loopdev-3" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "378e7ca4e85e592564e6a96c362303972b5c7860367014383aadc10a8704fc38" +checksum = "90a97d7a5124296ee9124a815acdc3dc4a91f577b72812b3f1f99bb959b46e8d" dependencies = [ - "bindgen 0.68.1", + "bindgen", "errno", "libc", ] @@ -915,15 +882,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -963,20 +921,6 @@ dependencies = [ "void", ] -[[package]] -name = "nix" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", - "memoffset 0.7.1", - "pin-utils", - "static_assertions", -] - [[package]] name = "nix" version = "0.28.0" @@ -987,7 +931,7 @@ dependencies = [ "cfg-if 1.0.0", "cfg_aliases", "libc", - "memoffset 0.9.0", + "memoffset", ] [[package]] @@ -1032,12 +976,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1220,12 +1158,6 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" -[[package]] -name = "retry" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac95c60a949a63fd2822f4964939662d8f2c16c4fa0624fd954bc6e703b9a3f6" - [[package]] name = "retry" version = "2.0.0" @@ -1352,12 +1284,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "stratisd" version = "3.6.5" @@ -1365,7 +1291,7 @@ dependencies = [ "assert_cmd", "assert_matches", "async-trait", - "bindgen 0.69.4", + "bindgen", "byteorder", "chrono", "clap", @@ -1375,7 +1301,7 @@ dependencies = [ "dbus-tree", "devicemapper", "either", - "env_logger 0.11.2", + "env_logger", "futures", "iocuddle", "itertools 0.12.0", @@ -1396,7 +1322,7 @@ dependencies = [ "proptest", "rand", "regex", - "retry 2.0.0", + "retry", "semver", "serde", "serde_derive", @@ -1460,15 +1386,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - [[package]] name = "termios" version = "0.3.3" @@ -1643,15 +1560,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index ec083a778b..e330a76f86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,7 @@ version = "2.3.0" optional = true [dependencies.devicemapper] -version = "0.34.0" +version = "0.34.2" optional = true [dependencies.dbus] @@ -134,7 +134,7 @@ version = "1.4.0" optional = true [dependencies.libblkid-rs] -version = "0.3.1" +version = "0.3.2" optional = true [dependencies.libc] @@ -142,12 +142,12 @@ version = "0.2.147" optional = true [dependencies.libcryptsetup-rs] -version = "0.9.1" +version = "0.9.3" features = ["mutex"] optional = true [dependencies.libcryptsetup-rs-sys] -version = "0.3.0" +version = "0.4.0" optional = true [dependencies.libmount] @@ -243,7 +243,7 @@ optional = true [dev-dependencies] assert_cmd = "2.0.8" assert_matches = "1.5.0" -loopdev-3 = "0.5.0" +loopdev-3 = "0.5.1" predicates = "3.0.0" proptest = "1.0.0" From 043cfbe5c718b0c13a603e6ff37ae1ed521d6fb5 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 25 Mar 2024 20:50:47 -0400 Subject: [PATCH 28/30] Hack .packit.yaml to remove stratis-decode-dm from spec file Signed-off-by: mulhern --- .packit.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.packit.yaml b/.packit.yaml index 1a29f97b32..eb5942eeb9 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -12,6 +12,7 @@ actions: post-upstream-clone: - "git clone https://github.com/stratis-storage/ci --depth=1 ../distro" - "mv ../distro/mockbuild_test/stratisd.spec ../distro/stratisd.spec" + - "sed -i '/stratis-decode-dm/d' ../distro/stratisd.spec" - "cargo install cargo-get" - "cargo install cargo-vendor-filterer" create-archive: From f5f38436731d3dea2a3c6cf550c4cccc4144a93c Mon Sep 17 00:00:00 2001 From: mulhern Date: Tue, 26 Mar 2024 10:00:13 -0400 Subject: [PATCH 29/30] Increase mio transitive dependency to 0.8.11 See https://rustsec.org/advisories/RUSTSEC-2024-0019. Signed-off-by: mulhern --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b679164625..801b261557 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -899,9 +899,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "mio" -version = "0.8.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "wasi", From 3a01b1c3f020b62afd04e89e86d8e0f2ff859a19 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 25 Mar 2024 21:00:58 -0400 Subject: [PATCH 30/30] version 3.6.6 Signed-off-by: mulhern --- CHANGES.txt | 39 +++++++++++++++++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7d16584851..1183f3a1b9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,42 @@ +stratisd 3.6.6 +============== +Recommended Rust toolchain version: 1.76.0 +Recommended development platform for Python development: Fedora 39 + +* New commits: + * Increase lower bounds of Stratis-project dependencies + * Increase mio transitive dependency to 0.8.11 + * Hack .packit.yaml to remove stratis-decode-dm from spec file + +* Cherry-picked commits: + * Increase retry dependency lower bound to 2.0.0 + * Increase bindgen dependency lower bound to 0.69.0 + * Update a comment justifying the minimum thin dev size + * Use a constant for the maximum name size + * Do not construct a String from metadata when saving + * Cargo.toml: Set up workspace table + * github actions: update FEDORA_RELEASE to F40, F39 + * Add serializer for Strings + * validate_name: Change error strings + * validate_name: Clarify some error messages + * Reject UserInfo values that do not satisfy validate_name + * Fix clippy::useless-vec lint + * Fix let-underscore-lock lint + * Use explicit OpenOptions::truncate() + * get_dm_init: Allow static_mut_refs + * DeviceInfo: allow clippy lint large_enum_variant + * stratisd: Allow clippy lint suspicious_open_options + * stratisd-min: Allow clippy lint suspicious_open_options + * generators: Use explicit OpenOptions::truncate() + * Allow unknown lint for static_mut_refs + * validate_filesystem_size: divisble -> divisible + * validate_filesystem_size: return more specific error + * Increase env_logger dependency lower bound to 0.11.0 + * Fix PID file bug in stratisd and stratisd-min + * Initialize devicemapper context without mutability + * Increase nix dependency lower bound to 0.28.0 + + stratisd 3.6.5 ============== Recommended Rust toolchain version: 1.76.0 diff --git a/Cargo.lock b/Cargo.lock index 801b261557..061912dce1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1286,7 +1286,7 @@ dependencies = [ [[package]] name = "stratisd" -version = "3.6.5" +version = "3.6.6" dependencies = [ "assert_cmd", "assert_matches", diff --git a/Cargo.toml b/Cargo.toml index e330a76f86..3a6a3e7fa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stratisd" -version = "3.6.5" +version = "3.6.6" authors.workspace = true edition.workspace = true rust-version.workspace = true