mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 01:18:00 +00:00
Pass an Interactor to new_connection().
Thanks to the previous commit, this new parameter can replace two of the existing ones: instead of passing a LogPolicy and a Seat, we now pass just an Interactor, from which any proxy implementation can extract the LogPolicy and the Seat anyway if they need it.
This commit is contained in:
parent
aac5e096fa
commit
89a390bdeb
24
network.h
24
network.h
@ -137,19 +137,14 @@ struct PlugVtable {
|
||||
* layer is now responsible for freeing it, and the caller shouldn't
|
||||
* assume it exists any more.
|
||||
*
|
||||
* You can optionally pass a LogPolicy to this function, which will be
|
||||
* passed on in turn to proxy types that can use one (e.g. SSH jump
|
||||
* host proxy). If you don't have one, all proxy types are required to
|
||||
* be able to manage without (and will just degrade their logging
|
||||
* control).
|
||||
*
|
||||
* If calling this from a backend with a Seat, you can also give it a
|
||||
* pointer to your 'Seat *'. In that situation, it might replace the
|
||||
* 'Seat *' with a temporary seat of its own, and give the real Seat
|
||||
* to the proxy system so that it can ask for passwords (and, in the
|
||||
* case of SSH proxying, other prompts like host key checks). If that
|
||||
* happens, then the resulting 'temp seat' is the backend's property,
|
||||
* and it will have to remember to free it when cleaning up, or after
|
||||
* pointer to the backend's Interactor trait. In that situation, it
|
||||
* might replace the backend's seat with a temporary seat of its own,
|
||||
* and give the real Seat to an Interactor somewhere in the proxy
|
||||
* system so that it can ask for passwords (and, in the case of SSH
|
||||
* proxying, other prompts like host key checks). If that happens,
|
||||
* then the resulting 'temp seat' is the backend's property, and it
|
||||
* will have to remember to free it when cleaning up, or after
|
||||
* flushing it back into the real seat when the network connection
|
||||
* attempt completes.
|
||||
*
|
||||
@ -163,7 +158,7 @@ struct PlugVtable {
|
||||
Socket *new_connection(SockAddr *addr, const char *hostname,
|
||||
int port, bool privport,
|
||||
bool oobinline, bool nodelay, bool keepalive,
|
||||
Plug *plug, Conf *conf, LogPolicy *lp, Seat **seat);
|
||||
Plug *plug, Conf *conf, Interactor *interactor);
|
||||
Socket *new_listener(const char *srcaddr, int port, Plug *plug,
|
||||
bool local_host_only, Conf *conf, int addressfamily);
|
||||
SockAddr *name_lookup(const char *host, int port, char **canonicalname,
|
||||
@ -181,8 +176,7 @@ Socket *platform_new_connection(SockAddr *addr, const char *hostname,
|
||||
Socket *sshproxy_new_connection(SockAddr *addr, const char *hostname,
|
||||
int port, bool privport,
|
||||
bool oobinline, bool nodelay, bool keepalive,
|
||||
Plug *plug, Conf *conf,
|
||||
LogPolicy *clientlp, Seat **clientseat);
|
||||
Plug *plug, Conf *conf, Interactor *itr);
|
||||
|
||||
/* socket functions */
|
||||
|
||||
|
@ -210,8 +210,7 @@ static char *raw_init(const BackendVtable *vt, Seat *seat,
|
||||
* Open socket.
|
||||
*/
|
||||
raw->s = new_connection(addr, *realhost, port, false, true, nodelay,
|
||||
keepalive, &raw->plug, conf,
|
||||
log_get_policy(logctx), &raw->seat);
|
||||
keepalive, &raw->plug, conf, &raw->interactor);
|
||||
if ((err = sk_socket_error(raw->s)) != NULL)
|
||||
return dupstr(err);
|
||||
|
||||
|
@ -290,7 +290,7 @@ static char *rlogin_init(const BackendVtable *vt, Seat *seat,
|
||||
*/
|
||||
rlogin->s = new_connection(addr, *realhost, port, true, false,
|
||||
nodelay, keepalive, &rlogin->plug, conf,
|
||||
log_get_policy(logctx), &rlogin->seat);
|
||||
&rlogin->interactor);
|
||||
if ((err = sk_socket_error(rlogin->s)) != NULL)
|
||||
return dupstr(err);
|
||||
|
||||
|
@ -759,7 +759,7 @@ static char *supdup_init(const BackendVtable *x, Seat *seat,
|
||||
*/
|
||||
supdup->s = new_connection(addr, *realhost, port, false, true,
|
||||
nodelay, keepalive, &supdup->plug, supdup->conf,
|
||||
log_get_policy(logctx), &supdup->seat);
|
||||
&supdup->interactor);
|
||||
if ((err = sk_socket_error(supdup->s)) != NULL)
|
||||
return dupstr(err);
|
||||
|
||||
|
@ -782,7 +782,7 @@ static char *telnet_init(const BackendVtable *vt, Seat *seat,
|
||||
*/
|
||||
telnet->s = new_connection(addr, *realhost, port, false, true, nodelay,
|
||||
keepalive, &telnet->plug, telnet->conf,
|
||||
log_get_policy(logctx), &telnet->seat);
|
||||
&telnet->interactor);
|
||||
if ((err = sk_socket_error(telnet->s)) != NULL)
|
||||
return dupstr(err);
|
||||
|
||||
|
@ -20,7 +20,7 @@ SockAddr *name_lookup(const char *host, int port, char **canonicalname,
|
||||
Socket *new_connection(SockAddr *addr, const char *hostname,
|
||||
int port, bool privport,
|
||||
bool oobinline, bool nodelay, bool keepalive,
|
||||
Plug *plug, Conf *conf, LogPolicy *lp, Seat **seat)
|
||||
Plug *plug, Conf *conf, Interactor *itr)
|
||||
{
|
||||
return sk_new(addr, port, privport, oobinline, nodelay, keepalive, plug);
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ const bool ssh_proxy_supported = false;
|
||||
Socket *sshproxy_new_connection(SockAddr *addr, const char *hostname,
|
||||
int port, bool privport,
|
||||
bool oobinline, bool nodelay, bool keepalive,
|
||||
Plug *plug, Conf *conf,
|
||||
LogPolicy *clientlp, Seat **clientseat)
|
||||
Plug *plug, Conf *conf, Interactor *itr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ static const PlugVtable ProxySocket_plugvt = {
|
||||
Socket *new_connection(SockAddr *addr, const char *hostname,
|
||||
int port, bool privport,
|
||||
bool oobinline, bool nodelay, bool keepalive,
|
||||
Plug *plug, Conf *conf, LogPolicy *lp, Seat **seat)
|
||||
Plug *plug, Conf *conf, Interactor *itr)
|
||||
{
|
||||
int type = conf_get_int(conf, CONF_proxy_type);
|
||||
|
||||
@ -409,7 +409,7 @@ Socket *new_connection(SockAddr *addr, const char *hostname,
|
||||
if (type == PROXY_SSH &&
|
||||
(sret = sshproxy_new_connection(addr, hostname, port, privport,
|
||||
oobinline, nodelay, keepalive,
|
||||
plug, conf, lp, seat)) != NULL)
|
||||
plug, conf, itr)) != NULL)
|
||||
return sret;
|
||||
|
||||
if ((sret = platform_new_connection(addr, hostname, port, privport,
|
||||
|
@ -483,7 +483,7 @@ Socket *sshproxy_new_connection(SockAddr *addr, const char *hostname,
|
||||
int port, bool privport,
|
||||
bool oobinline, bool nodelay, bool keepalive,
|
||||
Plug *plug, Conf *clientconf,
|
||||
LogPolicy *clientlp, Seat **clientseat)
|
||||
Interactor *clientitr)
|
||||
{
|
||||
SshProxy *sp = snew(SshProxy);
|
||||
memset(sp, 0, sizeof(*sp));
|
||||
@ -594,24 +594,27 @@ Socket *sshproxy_new_connection(SockAddr *addr, const char *hostname,
|
||||
sfree(realhost);
|
||||
|
||||
/*
|
||||
* If we've been given useful bits and pieces for interacting with
|
||||
* the end user, squirrel them away now.
|
||||
* If we've been given an Interactor by the caller, squirrel away
|
||||
* things it's holding.
|
||||
*/
|
||||
sp->clientlp = clientlp;
|
||||
if (clientseat && (backvt->flags & BACKEND_NOTIFIES_SESSION_START)) {
|
||||
/*
|
||||
* We can only keep the client's Seat if our own backend will
|
||||
* tell us when to give it back. (SSH-based backends _should_
|
||||
* do that, but we check the flag here anyway.)
|
||||
*
|
||||
* Also, check if the client already has a TempSeat, and if
|
||||
* so, don't wrap it with another one.
|
||||
*/
|
||||
if (is_tempseat(*clientseat)) {
|
||||
sp->clientseat = tempseat_get_real(*clientseat);
|
||||
} else {
|
||||
sp->clientseat = *clientseat;
|
||||
*clientseat = tempseat_new(sp->clientseat);
|
||||
if (clientitr) {
|
||||
sp->clientlp = interactor_logpolicy(clientitr);
|
||||
if (backvt->flags & BACKEND_NOTIFIES_SESSION_START) {
|
||||
/*
|
||||
* We can only keep the client's Seat if our own backend will
|
||||
* tell us when to give it back. (SSH-based backends _should_
|
||||
* do that, but we check the flag here anyway.)
|
||||
*
|
||||
* Also, check if the client already has a TempSeat, and if
|
||||
* so, don't wrap it with another one.
|
||||
*/
|
||||
Seat *clientseat = interactor_get_seat(clientitr);
|
||||
if (is_tempseat(clientseat)) {
|
||||
sp->clientseat = tempseat_get_real(clientseat);
|
||||
} else {
|
||||
sp->clientseat = clientseat;
|
||||
interactor_set_seat(clientitr, tempseat_new(sp->clientseat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1159,7 +1159,7 @@ char *portfwdmgr_connect(PortFwdManager *mgr, Channel **chan_ret,
|
||||
|
||||
pf->s = new_connection(addr, dummy_realhost, port,
|
||||
false, true, false, false, &pf->plug, mgr->conf,
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
sfree(dummy_realhost);
|
||||
if ((err = sk_socket_error(pf->s)) != NULL) {
|
||||
char *err_ret = dupstr(err);
|
||||
|
@ -826,8 +826,7 @@ static char *connect_to_host(
|
||||
|
||||
ssh->s = new_connection(addr, *realhost, port,
|
||||
false, true, nodelay, keepalive,
|
||||
&ssh->plug, ssh->conf,
|
||||
log_get_policy(ssh->logctx), &ssh->seat);
|
||||
&ssh->plug, ssh->conf, &ssh->interactor);
|
||||
if ((err = sk_socket_error(ssh->s)) != NULL) {
|
||||
ssh->s = NULL;
|
||||
seat_notify_remote_exit(ssh->seat);
|
||||
|
@ -563,7 +563,7 @@ static size_t x11_send(
|
||||
xconn->s = new_connection(sk_addr_dup(xconn->disp->addr),
|
||||
xconn->disp->realhost, xconn->disp->port,
|
||||
false, true, false, false, &xconn->plug,
|
||||
sshfwd_get_conf(xconn->c), NULL, NULL);
|
||||
sshfwd_get_conf(xconn->c), NULL);
|
||||
if ((err = sk_socket_error(xconn->s)) != NULL) {
|
||||
char *err_message = dupprintf("unable to connect to"
|
||||
" forwarded X server: %s", err);
|
||||
|
@ -1189,7 +1189,7 @@ void run_agent(FILE *logfp, const char *symlink_path)
|
||||
s = new_connection(sk_addr_dup(disp->addr),
|
||||
disp->realhost, disp->port,
|
||||
false, true, false, false, &conn->plug, conf,
|
||||
NULL, NULL);
|
||||
NULL);
|
||||
if ((err = sk_socket_error(s)) != NULL) {
|
||||
fprintf(stderr, "pageant: unable to connect to X server: %s", err);
|
||||
exit(1);
|
||||
|
@ -297,7 +297,7 @@ int platform_ssh_share(const char *pi_name, Conf *conf,
|
||||
if (can_downstream) {
|
||||
retsock = new_connection(unix_sock_addr(sockname),
|
||||
"", 0, false, true, false, false,
|
||||
downplug, conf, NULL, NULL);
|
||||
downplug, conf, NULL);
|
||||
if (sk_socket_error(retsock) == NULL) {
|
||||
sfree(*logtext);
|
||||
*logtext = sockname;
|
||||
|
Loading…
Reference in New Issue
Block a user