diff --git a/.packit.yaml b/.packit.yaml index 0504a12d8b..509dd8f94e 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -30,7 +30,21 @@ jobs: - job: copr_build trigger: pull_request targets: - - fedora-all + - fedora-development + + - job: copr_build + trigger: pull_request + additional_repos: + - https://dl.fedoraproject.org/pub/fedora/linux/updates/testing/40/Everything/x86_64/ + targets: + - fedora-40 + + - job: copr_build + trigger: pull_request + additional_repos: + - https://dl.fedoraproject.org/pub/fedora/linux/updates/testing/39/Everything/x86_64/ + targets: + - fedora-39 - job: tests identifier: local diff --git a/CHANGES.txt b/CHANGES.txt index cf7a5fd88e..663b740724 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,14 @@ +stratisd 3.7.3 +============== +Recommended Rust toolchain version: 1.81.0 +Recommended development platform for Python development: Fedora 40 + +* Cherry-picked commits: + * Allow improper ctypes in bindgen-generated bindings + * Build f40 and f39 copr repos with additional repo + * Tidies + * Change matches macro expansion to assert_matches + stratisd 3.7.2 ============== Recommended Rust toolchain version: 1.81.0 diff --git a/Cargo.lock b/Cargo.lock index b7d2ad63a0..1b71d25f73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1282,7 +1282,7 @@ dependencies = [ [[package]] name = "stratisd" -version = "3.7.2" +version = "3.7.3" dependencies = [ "assert_cmd", "assert_matches", diff --git a/Cargo.toml b/Cargo.toml index 88aad02118..6553d16adf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stratisd" -version = "3.7.2" +version = "3.7.3" authors.workspace = true edition.workspace = true rust-version.workspace = true diff --git a/src/engine/strat_engine/backstore/backstore.rs b/src/engine/strat_engine/backstore/backstore.rs index aa8f916890..49a115a95e 100644 --- a/src/engine/strat_engine/backstore/backstore.rs +++ b/src/engine/strat_engine/backstore/backstore.rs @@ -1021,6 +1021,18 @@ where level: ActionAvailability::NoRequests, }; } + if let Err(e) = blockdev.reload_crypt_metadata() { + warn!( + "Failed to reload on-disk metadata for device {}: {}", + blockdev.physical_path().display(), + e, + ); + return StratisError::RollbackError { + causal_error: Box::new(causal_error), + rollback_error: Box::new(e), + level: ActionAvailability::NoRequests, + }; + } } causal_error @@ -1332,7 +1344,7 @@ mod tests { Ok(false) ); - matches!( + assert_matches!( backstore.bind_clevis( "tang", &json!({"url": env::var("TANG_URL").expect("TANG_URL env var required"), "stratis:tang:trust_url": true}) diff --git a/src/engine/strat_engine/backstore/blockdev.rs b/src/engine/strat_engine/backstore/blockdev.rs index efc8d9b9f1..3742a4fefa 100644 --- a/src/engine/strat_engine/backstore/blockdev.rs +++ b/src/engine/strat_engine/backstore/blockdev.rs @@ -364,6 +364,15 @@ impl StratBlockDev { self.blksizes } + /// Reload the crypt metadata from disk and store in the crypt handle if the device is + /// encrypted. + pub fn reload_crypt_metadata(&mut self) -> StratisResult<()> { + match self.underlying_device.crypt_handle_mut() { + Some(handle) => handle.reload_metadata(), + None => Ok(()), + } + } + /// Bind encrypted device using the given clevis configuration. pub fn bind_clevis(&mut self, pin: &str, clevis_info: &Value) -> StratisResult<()> { let crypt_handle = self.underlying_device.crypt_handle_mut().ok_or_else(|| { diff --git a/src/engine/strat_engine/backstore/crypt/handle.rs b/src/engine/strat_engine/backstore/crypt/handle.rs index dc7330bb15..9032b952c7 100644 --- a/src/engine/strat_engine/backstore/crypt/handle.rs +++ b/src/engine/strat_engine/backstore/crypt/handle.rs @@ -427,6 +427,17 @@ impl CryptHandle { } } + /// Reload the required information for Stratis from the LUKS2 metadata. + pub fn reload_metadata(&mut self) -> StratisResult<()> { + match setup_crypt_device(self.luks2_device_path())? { + Some(ref mut device) => { + self.metadata = load_crypt_metadata(device, self.luks2_device_path())?.ok_or_else(|| StratisError::Msg("Found no crypt metadata on this device".to_string()))?; + Ok(()) + } + None => Err(StratisError::Msg("Expected device to be an encrypted device but could not acquire handle to crypt device".to_string())), + } + } + /// Get the encryption info for this encrypted device. pub fn encryption_info(&self) -> &EncryptionInfo { &self.metadata.encryption_info diff --git a/src/systemd/bindings.rs b/src/systemd/bindings.rs index 5f41b12864..e28289ff46 100644 --- a/src/systemd/bindings.rs +++ b/src/systemd/bindings.rs @@ -6,6 +6,7 @@ #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] +#![allow(improper_ctypes)] #![allow(clippy::redundant_static_lifetimes)] #![allow(clippy::unreadable_literal)] #![allow(clippy::missing_safety_doc)]