diff --git a/network.h b/network.h index 099895bc..068e6cc6 100644 --- a/network.h +++ b/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 */ diff --git a/otherbackends/raw.c b/otherbackends/raw.c index 7e80e42b..a5b3f427 100644 --- a/otherbackends/raw.c +++ b/otherbackends/raw.c @@ -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); diff --git a/otherbackends/rlogin.c b/otherbackends/rlogin.c index 6da67070..035295c9 100644 --- a/otherbackends/rlogin.c +++ b/otherbackends/rlogin.c @@ -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); diff --git a/otherbackends/supdup.c b/otherbackends/supdup.c index f680c521..a46bfd9a 100644 --- a/otherbackends/supdup.c +++ b/otherbackends/supdup.c @@ -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); diff --git a/otherbackends/telnet.c b/otherbackends/telnet.c index fecee06c..df23f2f2 100644 --- a/otherbackends/telnet.c +++ b/otherbackends/telnet.c @@ -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); diff --git a/proxy/noproxy.c b/proxy/noproxy.c index 82347d51..248688e0 100644 --- a/proxy/noproxy.c +++ b/proxy/noproxy.c @@ -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); } diff --git a/proxy/nosshproxy.c b/proxy/nosshproxy.c index 5f2bbdca..1160b8de 100644 --- a/proxy/nosshproxy.c +++ b/proxy/nosshproxy.c @@ -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; } diff --git a/proxy/proxy.c b/proxy/proxy.c index 08d5afba..69b32866 100644 --- a/proxy/proxy.c +++ b/proxy/proxy.c @@ -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, diff --git a/proxy/sshproxy.c b/proxy/sshproxy.c index d113cb04..8d8a0e90 100644 --- a/proxy/sshproxy.c +++ b/proxy/sshproxy.c @@ -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)); + } } } diff --git a/ssh/portfwd.c b/ssh/portfwd.c index 9dd35ea4..204f0632 100644 --- a/ssh/portfwd.c +++ b/ssh/portfwd.c @@ -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); diff --git a/ssh/ssh.c b/ssh/ssh.c index adc55391..1def173e 100644 --- a/ssh/ssh.c +++ b/ssh/ssh.c @@ -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); diff --git a/ssh/x11fwd.c b/ssh/x11fwd.c index 6886dace..1d2fe512 100644 --- a/ssh/x11fwd.c +++ b/ssh/x11fwd.c @@ -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); diff --git a/unix/pageant.c b/unix/pageant.c index a0b2e9e2..2fa3eeaa 100644 --- a/unix/pageant.c +++ b/unix/pageant.c @@ -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); diff --git a/unix/sharing.c b/unix/sharing.c index 66628723..8db2d71e 100644 --- a/unix/sharing.c +++ b/unix/sharing.c @@ -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;