Skip to content

Commit

Permalink
adjust code after third review
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Oct 15, 2024
1 parent 3b22966 commit f7883a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ exclude = [".github/"]
readme = "README.md"

[features]
linux-native = ["keyutils"]
linux-native = ["dep:linux-keyutils"]
apple-native = ["dep:security-framework"]
windows-native = ["dep:windows-sys", "dep:byteorder"]

keyutils = ["dep:linux-keyutils"]
sync-persistent-keyutils = ["keyutils", "sync-secret-service"]
async-persistent-keyutils = ["keyutils", "async-secret-service"]
sync-persistent-keyutils = ["dep:linux-keyutils", "sync-secret-service"]
async-persistent-keyutils = ["dep:linux-keyutils", "async-secret-service"]
sync-secret-service = ["dep:dbus-secret-service"]
async-secret-service = ["dep:secret-service", "dep:zbus"]
crypto-rust = ["dbus-secret-service?/crypto-rust", "secret-service?/crypto-rust"]
Expand Down
19 changes: 2 additions & 17 deletions src/keyutils_persistent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,9 @@ impl CredentialApi for KeyutilsPersistentCredential {
Ok(secret)
}

fn get_attributes(&self) -> Result<HashMap<String, String>> {
let Ok(attributes) = self.ss.get_attributes() else {
return self.keyutils.get_attributes();
};

Ok(attributes)
}

fn update_attributes(&self, attributes: &HashMap<&str, &str>) -> Result<()> {
let Ok(()) = self.ss.update_attributes(attributes) else {
return self.keyutils.update_attributes(attributes);
};

Ok(())
}

fn delete_credential(&self) -> Result<()> {
self.keyutils.delete_credential()?;
// TODO: log the error
let _ = self.keyutils.delete_credential();
self.ss.delete_credential()?;
Ok(())
}
Expand Down
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ pub mod mock;
feature = "async-persistent-keyutils",
)
))]
compile_error!("This crate cannot use the secret-service both synchronously and asynchronously");
compile_error!("This crate cannot use both the sync and async versions of any credential store");

//
// pick the *nix keystore
//
#[cfg(all(target_os = "linux", feature = "keyutils"))]
#[cfg(all(target_os = "linux", feature = "linux-native"))]
pub mod keyutils;
#[cfg(all(
target_os = "linux",
Expand Down Expand Up @@ -239,11 +239,9 @@ pub use keyutils_persistent as default;
// fallback to mock if neither keyutils nor secret service is available
#[cfg(all(
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"),
not(any(
feature = "keyutils",
feature = "sync-secret-service",
feature = "async-secret-service",
)),
not(feature = "linux-native"),
not(feature = "sync-secret-service"),
not(feature = "async-secret-service"),
))]
pub use mock as default;

Expand Down

0 comments on commit f7883a7

Please sign in to comment.