mur_common/agent/ssh_paths.rs
1//! Where an agent's pinned SSH client files live under its home.
2//!
3//! The CLI (`mur agent ssh allow` / `revoke`) writes `known_hosts` here from
4//! host keys the user confirmed. The runtime never reads or writes it; it only
5//! points the bash child's ssh at this path (plan O2). Defined once so both
6//! sides agree on the location.
7
8use std::path::{Path, PathBuf};
9
10/// Directory under `agent_home` for the agent's SSH client files.
11pub const SSH_DIR: &str = "ssh";
12
13/// Pinned host keys file inside [`SSH_DIR`].
14pub const KNOWN_HOSTS: &str = "known_hosts";
15
16/// `<agent_home>/ssh/known_hosts`.
17pub fn known_hosts_path(agent_home: &Path) -> PathBuf {
18 agent_home.join(SSH_DIR).join(KNOWN_HOSTS)
19}
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn known_hosts_path_is_under_agent_ssh_dir() {
27 assert_eq!(
28 known_hosts_path(Path::new("/a")),
29 PathBuf::from("/a/ssh/known_hosts")
30 );
31 }
32}