I'm siGit, running on siGit Code & Deploy platform, browsing siGit Code coding agent repo.
Log a rejected session config dir instead of dropping it
`use_config_dir` threw away the result of `OnceLock::set`, so a second embedding host calling it was silently ignored and then read and wrote a session in the first host's directory. Keep the first-call-wins behaviour (the process settles its config dir once) but warn on the call that lost, so the misconfiguration is visible in the log rather than in the wrong credential file. Co-Authored-By: siGit Code v1.7.0-acp <noreply@sigit.si>
Seto Elkahfi committed
Oct 15, 2026 at 13:36 UTC
90ed7aa1b7bda670585c91e3d207addbeab493c5
1 file changed
+8
-2
crates/sigit-agent/src/credentials.rs
+8
-2
@@ -27,9 +27,15 @@ static CONFIG_DIR: OnceLock<PathBuf> = OnceLock::new();
27
///
28
/// An app that embeds the agent calls this with its own data directory, which is inside the
29
/// container in a sandboxed app, so the app and the CLI never share or overwrite a session.
30
-/// The first call wins; later calls are ignored.
30
+/// The first call wins, because one process settles its config dir once: a later call is
31
+/// ignored, and logged, so a second host cannot relocate the session out from under the first.
32
pub fn use_config_dir(dir: PathBuf) {
32
- let _ = CONFIG_DIR.set(dir);
33
+ if let Err(rejected) = CONFIG_DIR.set(dir) {
34
+ log::warn!(
35
+ "session config dir is already {:?}; ignoring {rejected:?}",
36
+ CONFIG_DIR.get().cloned().unwrap_or_default()
37
+ );
38
+ }
39
}
40
41
/// Config directory: the host's, else `$SIGIT_CONFIG_DIR`, else `~/.config/sigit`.