Skip to content

Commit af63018

Browse files
committed
fix(ssh-agent): print actual endpoint for SSH_AUTH_SOCK
1 parent c850a2f commit af63018

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

agents/ssh-agent/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ pub async fn run_agent() -> Result<()> {
3636
let mut listener = AgentListener::bind(&socket_path)
3737
.await
3838
.with_context(|| format!("Failed to bind socket {}", socket_path.display()))?;
39-
info!("persona-ssh-agent listening at {}", socket_path.display());
40-
println!("SSH_AUTH_SOCK={}", socket_path.display());
39+
let mut endpoint = listener.address();
40+
if endpoint == "unknown" {
41+
endpoint = socket_path.display().to_string();
42+
}
43+
info!("persona-ssh-agent listening at {}", endpoint);
44+
println!("SSH_AUTH_SOCK={}", endpoint);
4145

4246
// Write state files
4347
let state_dir = std::env::var("PERSONA_AGENT_STATE_DIR")
@@ -51,7 +55,7 @@ pub async fn run_agent() -> Result<()> {
5155
let _ = std::fs::create_dir_all(&state_dir);
5256
let sock_file = state_dir.join("ssh-agent.sock");
5357
let pid_file = state_dir.join("ssh-agent.pid");
54-
let _ = std::fs::write(&sock_file, socket_path.display().to_string());
58+
let _ = std::fs::write(&sock_file, &endpoint);
5559
let _ = std::fs::write(&pid_file, std::process::id().to_string());
5660

5761
// Load keys from Persona

0 commit comments

Comments
 (0)