diff --git a/server/src/daemon/collection.rs b/server/src/daemon/collection.rs index 2527aeb01..59d843c30 100644 --- a/server/src/daemon/collection.rs +++ b/server/src/daemon/collection.rs @@ -2,7 +2,7 @@ use std::{ collections::HashMap, - sync::{atomic::AtomicBool, Arc}, + sync::{atomic::AtomicBool, Arc, Mutex}, time::Duration, }; @@ -29,7 +29,7 @@ pub struct Collection { locked: AtomicBool, created: Duration, modified: Duration, - manager: Arc, + manager: Arc>, path: OwnedObjectPath, } @@ -139,7 +139,7 @@ impl Collection { alias: &str, created: Duration, keyring: Arc, - manager: Arc, + manager: Arc>, ) -> Self { Self { items: Default::default(), diff --git a/server/src/daemon/item.rs b/server/src/daemon/item.rs index 9c3db22df..b09606fa2 100644 --- a/server/src/daemon/item.rs +++ b/server/src/daemon/item.rs @@ -1,6 +1,9 @@ // org.freedesktop.Secret.Item -use std::{collections::HashMap, sync::Arc}; +use std::{ + collections::HashMap, + sync::{Arc, Mutex}, +}; use oo7::{ dbus::api::SecretInner, @@ -24,7 +27,7 @@ pub struct Item { path: OwnedObjectPath, keyring: Arc, locked: bool, - manager: Arc, + manager: Arc>, } #[zbus::interface(name = "org.freedesktop.Secret.Item")] @@ -110,7 +113,7 @@ impl Item { item: portal::Item, collection_path: ObjectPath<'_>, keyring: Arc, - manager: Arc, + manager: Arc>, ) -> Self { Self { path: OwnedObjectPath::try_from(format!("{}/items/{}", collection_path, item.label(),)) diff --git a/server/src/daemon/service.rs b/server/src/daemon/service.rs index 59f918f77..0de80d940 100644 --- a/server/src/daemon/service.rs +++ b/server/src/daemon/service.rs @@ -31,7 +31,7 @@ pub struct Service { collections: RwLock>, keyring: Arc, cnx: Mutex>, - manager: Arc, + manager: Arc>, } #[zbus::interface(name = "org.freedesktop.Secret.Service")] @@ -48,6 +48,10 @@ impl Service { let (session, key) = Session::new(client_public_key, Arc::clone(&self.manager)); // TODO: clean up the default generated key // TODO call self.manager.set_sessions(); + self.manager + .lock() + .unwrap() + .insert_session(session.path().to_owned(), session.to_owned()); let key = key .map(|k| OwnedValue::from(&k)) .unwrap_or_else(|| Value::new::>(vec![]).try_to_owned().unwrap()); @@ -268,7 +272,7 @@ impl Service { collections: RwLock::new(Vec::new()), keyring: Arc::new(Keyring::load_default().await.unwrap()), cnx: Default::default(), - manager: Arc::new(ServiceManager::new()), + manager: Arc::new(Mutex::new(ServiceManager::new())), } } diff --git a/server/src/daemon/session.rs b/server/src/daemon/session.rs index 517a8b5f6..584f421ca 100644 --- a/server/src/daemon/session.rs +++ b/server/src/daemon/session.rs @@ -1,6 +1,6 @@ // org.freedesktop.Secret.Session -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use oo7::Key; use zbus::{fdo, interface, zvariant}; @@ -11,7 +11,7 @@ use super::service_manager::ServiceManager; #[derive(Debug, Clone)] pub struct Session { client_public_key: Arc>, - manager: Arc, + manager: Arc>, pub path: OwnedObjectPath, } @@ -29,7 +29,7 @@ impl Session { impl Session { pub fn new( client_public_key: Option, - manager: Arc, + manager: Arc>, ) -> (Self, Option) { // make use of the keys let service_key = vec![0];