mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-10-18 19:10:30 +08:00
crypto: Error on empty SSH_AUTH_SOCK
The empty string will never give a useful socket. Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.dev>
This commit is contained in:
committed by
Lorenz Leutgeb
co-authored by
Lorenz Leutgeb
parent
50129a7179
commit
919d5c780c
@@ -29,6 +29,8 @@ pub enum ConnectError {
|
||||
Agent(#[from] AgentError),
|
||||
#[error("Unable to read environment variable '{var}': {source}")]
|
||||
EnvVar { var: String, source: VarError },
|
||||
#[error("Environment variable '{var}' is set to the empty string.")]
|
||||
EnvVarEmpty { var: String },
|
||||
}
|
||||
|
||||
impl ConnectError {
|
||||
@@ -72,7 +74,10 @@ impl Agent {
|
||||
const SSH_AUTH_SOCK: &str = "SSH_AUTH_SOCK";
|
||||
|
||||
let path = match std::env::var(SSH_AUTH_SOCK) {
|
||||
Ok(path) => Ok(PathBuf::from(path)),
|
||||
Ok(path) if !path.is_empty() => Ok(PathBuf::from(path)),
|
||||
Ok(_) => Err(ConnectError::EnvVarEmpty {
|
||||
var: SSH_AUTH_SOCK.to_string(),
|
||||
}),
|
||||
#[cfg(windows)]
|
||||
Err(VarError::NotPresent) => {
|
||||
// Windows exposes the SSH Agent on a default named pipe.
|
||||
|
||||
Reference in New Issue
Block a user