mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Merge the two low-level portfwd setup systems.
In commit09954a87c
I introduced the portfwdmgr_connect_socket() system, which opened a port forwarding given a callback to create the Socket itself, with the aim of using it to make forwardings to Unix- domain sockets and Windows named pipes (both initially for agent forwarding). But I forgot that a year and a bit ago, in commit834396170
, I already introduced a similar low-level system for creating a PortForwarding around an unusual kind of socket: the portfwd_raw_new() system, which in place of a callback uses a two-phase setup protocol (you create the socket in between the two setup calls, and can roll it back if the socket can't be created). There's really no need to have _both_ these systems! So now I'm merging them, which is to say, I'm enhancing portfwd_raw_new to have the one new feature it needs, and throwing away the newer system completely. The new feature is to be able to control the initial state of the 'ready' flag: portfwd_raw_new was always used for initiating port forwardings in response to an incoming local connection, which means you need to start off with ready=false and set it true when the other end of the SSH connection sends back OPEN_CONFIRMATION. Now it's being used for initiating port forwardings in response to a CHANNEL_OPEN, we need to be able to start with ready=true. This commit reverts09954a87c2
and its followup fix12aa06ccc9
, and simplifies the agent_connect system down to a single trivial function that makes a Socket given a Plug.
This commit is contained in:
@ -130,30 +130,12 @@ static const char *agent_socket_path(void)
|
||||
return getenv("SSH_AUTH_SOCK");
|
||||
}
|
||||
|
||||
struct agent_connect_ctx {
|
||||
SockAddr *addr;
|
||||
};
|
||||
|
||||
Socket *agent_connect(void *vctx, Plug *plug)
|
||||
{
|
||||
agent_connect_ctx *ctx = (agent_connect_ctx *)vctx;
|
||||
return sk_new(sk_addr_dup(ctx->addr), 0, false, false, false, false, plug);
|
||||
}
|
||||
|
||||
agent_connect_ctx *agent_get_connect_ctx(void)
|
||||
Socket *agent_connect(Plug *plug)
|
||||
{
|
||||
const char *path = agent_socket_path();
|
||||
if (!path)
|
||||
return NULL;
|
||||
agent_connect_ctx *ctx = snew(agent_connect_ctx);
|
||||
ctx->addr = unix_sock_addr(path);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void agent_free_connect_ctx(agent_connect_ctx *ctx)
|
||||
{
|
||||
sk_addr_free(ctx->addr);
|
||||
sfree(ctx);
|
||||
return new_error_socket_fmt(plug, "SSH_AUTH_SOCK not set");
|
||||
return sk_new(unix_sock_addr(path), 0, false, false, false, false, plug);
|
||||
}
|
||||
|
||||
agent_pending_query *agent_query(
|
||||
|
Reference in New Issue
Block a user