Skip to content

Commit

Permalink
Fixes SetSecret call
Browse files Browse the repository at this point in the history
This change fixes the SetSecret call failing to correctly update the
secret of an item.

Signed-off-by: Dhanuka Warusadura <dhanuka@gnome.org>
  • Loading branch information
warusadura committed Oct 15, 2024
1 parent 4e49899 commit 47c840f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion server/src/daemon/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,27 @@ impl Item {
),))
}

pub async fn set_secret(&self, secret: Vec<u8>) {
pub async fn set_secret(&self, secret: SecretInner) -> Result<()> {
let session = secret.0;
let iv = secret.1;
let value = secret.2;

let session = self.manager.lock().unwrap().session(session.into());
if session.is_none() {
tracing::info!("The session does not exist");
return Err(ServiceError::NoSession);
}

let session = session.unwrap();
let key = session.aes_key();
let secret = crypto::decrypt(value, key, iv);

let mut inner = self.inner.write().await;
inner.set_secret(secret);

tracing::info!("SetSecret called for item: {}. secret updated", self.path);

Ok(())
}

#[zbus(property, name = "Locked")]
Expand Down

0 comments on commit 47c840f

Please sign in to comment.