Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(ssh): keep concrete agent stream types for Windows agent auth

zipg1efd41cfaa75
diff --git a/crates/dbx-drivers/src/db/ssh_tunnel.rs b/crates/dbx-drivers/src/db/ssh_tunnel.rs
index 2c270fec63..42ecaca752 100644
--- a/crates/dbx-drivers/src/db/ssh_tunnel.rs
+++ b/crates/dbx-drivers/src/db/ssh_tunnel.rs
@@ -9,9 +9,8 @@ use std::sync::Arc;
use base64::engine::general_purpose::STANDARD as BASE64_STANDARD;
use base64::Engine;
use russh::client::{self, AuthResult, Config, GexParams, Handle, KeyboardInteractiveAuthResponse};
-#[cfg(windows)]
-use russh::keys::agent::client::AgentStream;
-use russh::keys::agent::{client::AgentClient, AgentIdentity};
+use russh::keys::agent::client::{AgentClient, AgentStream};
+use russh::keys::agent::AgentIdentity;
use russh::keys::ssh_key::HashAlg;
use russh::keys::{decode_secret_key, key::PrivateKeyWithHashAlg, PrivateKey};
use russh::MethodKind;
@@ -747,38 +746,35 @@ async fn try_authenticate_with_agent(
let mut failures = Vec::new();
for endpoint in windows_ssh_agent_endpoints(ssh_agent_sock_path) {
let label = endpoint.label();
- let agent: AgentClient<Box<dyn AgentStream + Send + Unpin + 'static>> = match endpoint {
+ // Every transport keeps its own concrete stream type. Erasing both into one
+ // `dyn AgentStream` (russh's `AgentClient::dynamic`) makes rustc unable to
+ // prove the spawned tunnel task is `Send`: the whole chain is rejected with
+ // "implementation of `std::marker::Send` is not general enough" for the
+ // `&str` user argument, which broke the Windows build.
+ let outcome = match endpoint {
WindowsSshAgentEndpoint::NamedPipe(path) => {
match tokio::time::timeout(*connect_timeout, AgentClient::connect_named_pipe(&path)).await {
- Ok(Ok(agent)) => agent.dynamic(),
- Ok(Err(error)) => {
- failures.push(format!("{label} is unavailable: {error}"));
- continue;
- }
- Err(_) => {
- failures.push(format!("{label} connection timed out"));
- continue;
- }
+ Ok(Ok(agent)) => authenticate_with_agent_client(session, ssh_user, agent, connect_timeout)
+ .await
+ .map_err(|error| format!("{label}: {error}")),
+ Ok(Err(error)) => Err(format!("{label} is unavailable: {error}")),
+ Err(_) => Err(format!("{label} connection timed out")),
}
}
WindowsSshAgentEndpoint::Pageant => {
match tokio::time::timeout(*connect_timeout, AgentClient::connect_pageant()).await {
- Ok(Ok(agent)) => agent.dynamic(),
- Ok(Err(error)) => {
- failures.push(format!("{label} is unavailable: {error}"));
- continue;
- }
- Err(_) => {
- failures.push(format!("{label} connection timed out"));
- continue;
- }
+ Ok(Ok(agent)) => authenticate_with_agent_client(session, ssh_user, agent, connect_timeout)
+ .await
+ .map_err(|error| format!("{label}: {error}")),
+ Ok(Err(error)) => Err(format!("{label} is unavailable: {error}")),
+ Err(_) => Err(format!("{label} connection timed out")),
}
}
};
- match authenticate_with_agent_client(session, ssh_user, agent, connect_timeout).await {
+ match outcome {
Ok(outcome) => return Ok(outcome),
- Err(error) => failures.push(format!("{label}: {error}")),
+ Err(error) => failures.push(error),
}
}
@@ -796,7 +792,7 @@ async fn authenticate_with_agent_client<S>(
connect_timeout: &Duration,
) -> Result<AgentAuthenticationOutcome, String>
where
- S: russh::keys::agent::client::AgentStream + Send + Unpin + 'static,
+ S: AgentStream + Send + Unpin + 'static,
{
let identities = match agent.request_identities().await {
Ok(ids) if ids.is_empty() => {