Repository navigation
Conversation
bilelmoussaoui
left a comment
There was a problem hiding this comment.
Not a proper review, but I think we should still split this into smaller PRs.
Having a wrapper Record/Keyring, make sense. Although i am not sure if that is better than having say, a trait that defines what is a Collection, and what is an Item inside of it.
Then most of the v1 file item level APIs would become trait implementation for v1 "backend". Not sure how doable but might be interesting to give it a shot.
📊 Code Coverage Report
Coverage report generated by cargo-tarpaulin |
|
Thanks for the review, @bilelmoussaoui. I agree it would be easier to review this in smaller PRs. I’d start with the partial-unlock fix and its regression test. That fix stands on its own. If the daemon can’t unlock one item, the collection and its other items should stay locked. For the storage work, I’d then try a small V1 implementation with a collection trait and an associated item type implementing an item trait. One concrete question is whether the D-Bus item can read and update a record without reaching through the wrapper to get a Would you be happy with that split and with trying the trait design in the second PR? I’d like to confirm the direction with you before reorganizing this one. |
|
Sounds good to me to split the fix into a separate issue. |
D-Bus searches need subset matches and CreateItem needs exact matches for replacement. Let the collection request either operation without fetching and passing around a V1 file key. Both paths still acquire the key once per query. Keep the V0 digest conversion with the records that need it. Only encrypted legacy placeholders use it, and they share the converted attributes across a search. Dispatch records from both discovery paths and keep cached replacements in sync with successful file writes.
Have discovery, creation and migration return the daemon keyring directly so Collection::new can accept the same type at every call site. Route password changes and item operations through that adapter while retaining the atomic lock transition from main. Exercise Secret Service lookup on a locked, unencrypted V1 file and after unlock, and reopen a newly created collection with the V1 reader.
01c2056 to
e43c63c
Compare
| @@ -0,0 +1,282 @@ | |||
| //! File-backed storage used by daemon collections. | |||
|
|
|||
| use std::{ | |||
There was a problem hiding this comment.
I would split the Keyring & record types into separate files.
| data_dir: &Path, | ||
| name: &str, | ||
| secret: Option<Secret>, | ||
| ) -> Result<Self, file::Error> { |
There was a problem hiding this comment.
Instead, I would create a new error type for the server as other implementations might not use file::Error specific errors ?
|
|
||
| pub async fn query<'a>( | ||
| &self, | ||
| attributes: &'a HashMap<String, String>, |
There was a problem hiding this comment.
should use impl AsAttributes.
| exact: bool, | ||
| ) -> Result<ItemQuery<'a>, oo7::crypto::Error> { | ||
| match self { | ||
| Self::V1(keyring) => ItemQuery::new(keyring, attributes, exact).await, |
There was a problem hiding this comment.
I am still not sure what is the usefulness of ItemQuery, maybe do that in a separate PR/commit?
| } | ||
| } | ||
|
|
||
| fn unlocked_v1(&self) -> Result<&file::UnlockedKeyring, file::Error> { |
There was a problem hiding this comment.
This is leaking v1/v0 details into something that is meant to be generic. If we were to have a generic implementation, it should cover both Locked/Unlocked keyring, same for records.
| /// The cached storage record for a registered D-Bus item. | ||
| pub(crate) struct Record { | ||
| item: file::Item, | ||
| v0_placeholder: bool, |
There was a problem hiding this comment.
Same thing, we shouldn't leak v0 details here.
| } | ||
|
|
||
| impl Keyring { | ||
| pub async fn open( |
There was a problem hiding this comment.
would keep the open_at name.
| .await?; | ||
|
|
||
| let items = unlocked.search_items(&[("created", "unenc-test")]).await?; | ||
| let persisted = UnlockedKeyring::load(unlocked.path().unwrap(), None).await?; |
There was a problem hiding this comment.
what is the point in reloading the keyring here?
| "Should be locked initially" | ||
| ); | ||
|
|
||
| // Locked V1 items in an unencrypted keyring carry plaintext attributes. |
There was a problem hiding this comment.
seems like an unrelated change?
This is the first step of #642. Daemon collections now use a private storage adapter backed by the existing libsecret-compatible V1 keyring. The daemon still serves the same Secret Service API, opens existing files in place and writes new collections in V1.
The commits can be reviewed in order.
The final tree passes the daemon suite with default features (165 tests) and with OpenSSL and default features disabled (164 tests), the workspace formatting check and daemon Clippy with default features. The unencrypted collection tests exercise Secret Service lookup before and after unlock and reopen a newly created file with the V1 reader.