From c55e39a640346fb9ffb017f9e508465fa2f0d014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 21 Mar 2025 16:56:04 +0100 Subject: [PATCH] Revert "Downgrade oo7" This reverts commit 2f107332fd8e537284d9db0637be0c09e2aa6aa4. --- Cargo.lock | 264 ++++---------------------------------------- Cargo.toml | 2 +- src/secret/linux.rs | 36 +++--- 3 files changed, 43 insertions(+), 259 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af0ee87c..4f052378 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ "tokio", "tracing", "url", - "zbus 5.5.0", + "zbus", ] [[package]] @@ -222,61 +222,12 @@ dependencies = [ "tokio", ] -[[package]] -name = "async-io" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" -dependencies = [ - "async-lock", - "cfg-if", - "concurrent-queue", - "futures-io", - "futures-lite", - "parking", - "polling", - "rustix 0.38.44", - "slab", - "tracing", - "windows-sys 0.59.0", -] - -[[package]] -name = "async-lock" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" -dependencies = [ - "event-listener", - "event-listener-strategy", - "pin-project-lite", -] - [[package]] name = "async-once-cell" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288f83726785267c6f2ef073a3d83dc3f9b81464e9f99898240cced85fce35a" -[[package]] -name = "async-process" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" -dependencies = [ - "async-channel", - "async-io", - "async-lock", - "async-signal", - "async-task", - "blocking", - "cfg-if", - "event-listener", - "futures-lite", - "rustix 0.38.44", - "tracing", -] - [[package]] name = "async-recursion" version = "1.1.1" @@ -298,24 +249,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "async-signal" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" -dependencies = [ - "async-io", - "async-lock", - "atomic-waker", - "cfg-if", - "futures-core", - "futures-io", - "rustix 0.38.44", - "signal-hook-registry", - "slab", - "windows-sys 0.59.0", -] - [[package]] name = "async-stream" version = "0.3.6" @@ -338,12 +271,6 @@ dependencies = [ "syn", ] -[[package]] -name = "async-task" -version = "4.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" - [[package]] name = "async-trait" version = "0.1.88" @@ -532,19 +459,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "blocking" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" -dependencies = [ - "async-channel", - "async-task", - "futures-io", - "futures-lite", - "piper", -] - [[package]] name = "bs58" version = "0.5.1" @@ -1754,7 +1668,7 @@ dependencies = [ "tokio-stream", "tracing", "yeslogic-fontconfig-sys", - "zbus 5.5.0", + "zbus", ] [[package]] @@ -1775,7 +1689,7 @@ dependencies = [ "serde", "thiserror 2.0.12", "tokio", - "zbus 5.5.0", + "zbus", ] [[package]] @@ -2199,12 +2113,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "hermit-abi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" - [[package]] name = "hex" version = "0.4.3" @@ -3581,7 +3489,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] @@ -3631,22 +3539,25 @@ checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" [[package]] name = "oo7" -version = "0.3.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc6ce4692fbfd044ce22ca07dcab1a30fa12432ca2aa5b1294eca50d3332a24" +checksum = "b37e8790c4ddf13c930a64ec856342039d6dc2eeecd14123a0a4bcdf680d8b70" dependencies = [ + "ashpd", "endi", "futures-util", + "getrandom 0.3.2", "num", "num-bigint-dig", "openssl", - "rand 0.8.5", + "rand 0.9.0", "serde", "tokio", "tracing", - "zbus 4.4.0", + "zbus", + "zbus_macros", "zeroize", - "zvariant 4.2.0", + "zvariant", ] [[package]] @@ -3863,17 +3774,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "piper" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" -dependencies = [ - "atomic-waker", - "fastrand", - "futures-io", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -3890,21 +3790,6 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" -[[package]] -name = "polling" -version = "3.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" -dependencies = [ - "cfg-if", - "concurrent-queue", - "hermit-abi 0.4.0", - "pin-project-lite", - "rustix 0.38.44", - "tracing", - "windows-sys 0.59.0", -] - [[package]] name = "poly1305" version = "0.8.0" @@ -4696,17 +4581,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha2" version = "0.10.8" @@ -5956,39 +5830,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zbus" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" -dependencies = [ - "async-broadcast", - "async-process", - "async-recursion", - "async-trait", - "enumflags2", - "event-listener", - "futures-core", - "futures-sink", - "futures-util", - "hex", - "nix", - "ordered-stream", - "rand 0.8.5", - "serde", - "serde_repr", - "sha1", - "static_assertions", - "tokio", - "tracing", - "uds_windows", - "windows-sys 0.52.0", - "xdg-home", - "zbus_macros 4.4.0", - "zbus_names 3.0.0", - "zvariant 4.2.0", -] - [[package]] name = "zbus" version = "5.5.0" @@ -6015,22 +5856,9 @@ dependencies = [ "windows-sys 0.59.0", "winnow", "xdg-home", - "zbus_macros 5.5.0", - "zbus_names 4.2.0", - "zvariant 5.4.0", -] - -[[package]] -name = "zbus_macros" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", - "zvariant_utils 2.1.0", + "zbus_macros", + "zbus_names", + "zvariant", ] [[package]] @@ -6043,20 +5871,9 @@ dependencies = [ "proc-macro2", "quote", "syn", - "zbus_names 4.2.0", - "zvariant 5.4.0", - "zvariant_utils 3.2.0", -] - -[[package]] -name = "zbus_names" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" -dependencies = [ - "serde", - "static_assertions", - "zvariant 4.2.0", + "zbus_names", + "zvariant", + "zvariant_utils", ] [[package]] @@ -6068,7 +5885,7 @@ dependencies = [ "serde", "static_assertions", "winnow", - "zvariant 5.4.0", + "zvariant", ] [[package]] @@ -6174,19 +5991,6 @@ dependencies = [ "syn", ] -[[package]] -name = "zvariant" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" -dependencies = [ - "endi", - "enumflags2", - "serde", - "static_assertions", - "zvariant_derive 4.2.0", -] - [[package]] name = "zvariant" version = "5.4.0" @@ -6199,21 +6003,8 @@ dependencies = [ "static_assertions", "url", "winnow", - "zvariant_derive 5.4.0", - "zvariant_utils 3.2.0", -] - -[[package]] -name = "zvariant_derive" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", - "zvariant_utils 2.1.0", + "zvariant_derive", + "zvariant_utils", ] [[package]] @@ -6226,18 +6017,7 @@ dependencies = [ "proc-macro2", "quote", "syn", - "zvariant_utils 3.2.0", -] - -[[package]] -name = "zvariant_utils" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "zvariant_utils", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 789c7958..c8ac6bbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,7 +114,7 @@ ashpd = { version = "0.11", default-features = false, features = [ "tracing", "tokio", ] } -oo7 = { version = "0.3", default-features = false, features = [ +oo7 = { version = "0.4", default-features = false, features = [ "openssl_crypto", "tokio", "tracing", diff --git a/src/secret/linux.rs b/src/secret/linux.rs index 7dda65ef..63be54de 100644 --- a/src/secret/linux.rs +++ b/src/secret/linux.rs @@ -162,7 +162,7 @@ async fn store_session_inner(session: StoredSession) -> Result<(), oo7::Error> { let keyring = Keyring::new().await?; let attributes = session.attributes(); - let secret = session.passphrase; + let secret = oo7::Secret::text(session.passphrase); keyring .create_item( @@ -255,8 +255,8 @@ impl StoredSession { } else { // Even if we store the secret as plain text, the file backend always returns a // blob so let's always treat it as a byte slice. - match String::from_utf8(secret.as_slice().to_owned()) { - Ok(passphrase) => (passphrase, None), + match String::from_utf8(secret.as_bytes().to_owned()) { + Ok(passphrase) => (passphrase.clone(), None), Err(error) => { error!("Could not get secret in stored session: {error}"); return Err(LinuxSecretFieldError::Invalid.into()); @@ -348,7 +348,7 @@ impl StoredSession { info!("Migrating to version 7…"); let new_attributes = self.attributes(); - let new_secret = self.passphrase.clone(); + let new_secret = oo7::Secret::text(&self.passphrase); spawn_tokio!(async move { if let Err(error) = item.set_secret(new_secret).await { @@ -488,15 +488,15 @@ impl From for SecretError { impl UserFacingError for oo7::Error { fn to_user_facing(&self) -> String { match self { - oo7::Error::Portal(error) => error.to_user_facing(), + oo7::Error::File(error) => error.to_user_facing(), oo7::Error::DBus(error) => error.to_user_facing(), } } } -impl UserFacingError for oo7::portal::Error { +impl UserFacingError for oo7::file::Error { fn to_user_facing(&self) -> String { - use oo7::portal::Error; + use oo7::file::Error; match self { Error::FileHeaderMismatch(_) | @@ -508,6 +508,8 @@ impl UserFacingError for oo7::portal::Error { Error::SaltSizeMismatch(_, _) | Error::ChecksumMismatch | Error::AlgorithmMismatch(_) | + Error::IncorrectSecret | + Error::Crypto(_) | Error::Utf8(_) => gettext( "The secret storage file is corrupted.", ), @@ -521,15 +523,15 @@ impl UserFacingError for oo7::portal::Error { Error::TargetFileChanged(_) => gettext( "The secret storage file has been changed by another process.", ), - Error::PortalBus(_) => gettext( - "An unexpected error occurred when interacting with the D-Bus Secret Portal backend.", - ), - Error::CancelledPortalRequest => gettext( + Error::Portal(ashpd::Error::Portal(ashpd::PortalError::Cancelled(_))) => gettext( "The request to the Flatpak Secret Portal was cancelled. Make sure to accept any prompt asking to access it.", ), - Error::PortalNotAvailable => gettext( + Error::Portal(ashpd::Error::PortalNotFound(_)) => gettext( "The Flatpak Secret Portal is not available. Make sure xdg-desktop-portal is installed, and it is at least at version 1.5.0.", ), + Error::Portal(_) => gettext( + "An unexpected error occurred when interacting with the D-Bus Secret Portal backend.", + ), Error::WeakKey(_) => gettext( "The Flatpak Secret Portal provided a key that is too weak to be secure.", ), @@ -551,13 +553,13 @@ impl UserFacingError for oo7::dbus::Error { ServiceError::ZBus(_) => gettext( "An unexpected error occurred when interacting with the D-Bus Secret Service.", ), - ServiceError::IsLocked => gettext( + ServiceError::IsLocked(_) => gettext( "The collection or item is locked.", ), - ServiceError::NoSession => gettext( + ServiceError::NoSession(_) => gettext( "The D-Bus Secret Service session does not exist.", ), - ServiceError::NoSuchObject => gettext( + ServiceError::NoSuchObject(_) => gettext( "The collection or item does not exist.", ), }, @@ -567,7 +569,9 @@ impl UserFacingError for oo7::dbus::Error { Error::NotFound(_) => gettext( "Could not access the default collection. Make sure a keyring was created and set as default.", ), - Error::Zbus(_) | + Error::ZBus(_) | + Error::Utf8(_) | + Error::Crypto(_) | Error::IO(_) => gettext( "An unexpected error occurred when interacting with the D-Bus Secret Service.", ),