The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(security): persist adopted keyring entries to the file store
Steven Enamakelec343bed6023
diff --git a/crates/openhuman-core/src/security/keyring/file_store.rs b/crates/openhuman-core/src/security/keyring/file_store.rsindex bddf9394a9..f034aee39c 100644--- a/crates/openhuman-core/src/security/keyring/file_store.rs+++ b/crates/openhuman-core/src/security/keyring/file_store.rs@@ -216,10 +216,14 @@ pub fn quarantine_corrupt(path: &Path, suffix: &str) -> Option<PathBuf> {match std::fs::hard_link(path, &target) {Ok(()) => {if let Err(e) = std::fs::remove_file(path) {- log::warn!(- "[keyring] quarantined {} but could not remove the original: {e}",+ // Not moved aside after all: drop the extra link so the+ // caller does not treat the original as gone.+ let _ = std::fs::remove_file(&target);+ log::error!(+ "[keyring] {} could not be parsed and could not be moved aside: {e}",path.display());+ return None;}return Some(log_quarantined(path, target));}diff --git a/crates/openhuman-core/src/security/keyring/ops.rs b/crates/openhuman-core/src/security/keyring/ops.rsindex ac31d60ea4..6eaf0b26e4 100644--- a/crates/openhuman-core/src/security/keyring/ops.rs+++ b/crates/openhuman-core/src/security/keyring/ops.rs@@ -67,19 +67,24 @@ pub fn get(user_id: &str, key: &str) -> Result<Option<String>, KeyringError> {};log::debug!("[keyring] get (storage)");get_adopting(secrets, &namespaced_key(user_id, key), key, || {- // The storage backend is authoritative once configured, so a failing- // legacy backend must not fail the read; it is logged so a broken OS- // keychain does not look like "nothing stored".- match process_get(user_id, key) {- Ok(value) => value,- Err(error) => {- log::warn!("[keyring] legacy process-backend read failed during adoption: {error}");- None- }- }+ legacy_or_warn(process_get(user_id, key))})}+/// The legacy process-backend value to adopt. The storage backend is+/// authoritative once configured, so a failing legacy backend must not fail+/// the read; it is logged so a broken OS keychain does not look like+/// "nothing stored".+fn legacy_or_warn(result: Result<Option<String>, KeyringError>) -> Option<String> {+ match result {+ Ok(value) => value,+ Err(error) => {+ log::warn!("[keyring] legacy process-backend read failed during adoption: {error}");+ None+ }+ }+}+/// Read `name` from the storage-backed `secrets`. On a miss, ask `legacy` for/// a secret an earlier process-keyring install stored and adopt it into/// storage, so enabling a backend does not hide it. `key` is only for errors.diff --git a/crates/openhuman-core/src/security/keyring/ops_adoption_tests.rs b/crates/openhuman-core/src/security/keyring/ops_adoption_tests.rsindex f5740451c1..d7307e49c6 100644--- a/crates/openhuman-core/src/security/keyring/ops_adoption_tests.rs+++ b/crates/openhuman-core/src/security/keyring/ops_adoption_tests.rs@@ -89,3 +89,23 @@ fn adopted_secrets_do_not_cross_scopes() {None);}++#[test]+fn a_failing_legacy_backend_reads_as_nothing_to_adopt() {+ assert_eq!(+ legacy_or_warn(Err(KeyringError::Backend("locked".into()))),+ None+ );+ assert_eq!(+ legacy_or_warn(Ok(Some("v".into()))).as_deref(),+ Some("v")+ );+ // With nothing legacy to adopt, the storage read is still answered.+ let storage = MemoryStorage::new();+ let secrets = storage_secrets_in(&storage, "local");+ let read = get_adopting(secrets, "alice:k", "k", || {+ legacy_or_warn(Err(KeyringError::Backend("locked".into())))+ })+ .unwrap();+ assert_eq!(read, None);+}