1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00
putty-source/unix/config-unix.c
Simon Tatham 0d3bb73608 Initial support for in-process proxy SSH connections.
This introduces a new entry to the radio-button list of proxy types,
in which the 'Proxy host' box is taken to be the name of an SSH server
or saved session. We make an entire subsidiary SSH connection to that
host, open a direct-tcpip channel through it, and use that as the
connection over which to run the primary network connection.

The result is basically the same as if you used a local proxy
subprocess, with a command along the lines of 'plink -batch %proxyhost
-nc %host:%port'. But it's all done in-process, by having an SshProxy
object implement the Socket trait to talk to the main connection, and
implement Seat and LogPolicy to talk to its subsidiary SSH backend.
All the refactoring in recent years has got us to the point where we
can do that without both SSH instances fighting over some global
variable or unique piece of infrastructure.

From an end user perspective, doing SSH proxying in-process like this
is a little bit easier to set up: it doesn't require you to bake the
full pathname of Plink into your saved session (or to have it on the
system PATH), and the SshProxy setup function automatically turns off
SSH features that would be inappropriate in this context, such as
additional port forwardings, or acting as a connection-sharing
upstream. And it has minor advantages like getting the Event Log for
the subsidiary connection interleaved in the main Event Log, as if it
were stderr output from a proxy subcommand, without having to
deliberately configure the subsidiary Plink into verbose mode.

However, this is an initial implementation only, and it doesn't yet
support the _big_ payoff for doing this in-process, which (I hope)
will be the ability to handle interactive prompts from the subsidiary
SSH connection via the same user interface as the primary one. For
example, you might need to answer two password prompts in succession,
or (the first time you use a session configured this way) confirm the
host keys for both proxy and destination SSH servers. Comments in the
new source file discuss some design thoughts on filling in this gap.

For the moment, if the proxy SSH connection encounters any situation
where an interactive prompt is needed, it will make the safe
assumption, the same way 'plink -batch' would do. So it's at least no
_worse_ than the existing technique of putting the proxy connection in
a subprocess.
2021-05-22 14:13:52 +01:00

73 lines
2.4 KiB
C

/*
* uxcfg.c - the Unix-specific parts of the PuTTY configuration
* box.
*/
#include <assert.h>
#include <stdlib.h>
#include "putty.h"
#include "dialog.h"
#include "storage.h"
void unix_setup_config_box(struct controlbox *b, bool midsession, int protocol)
{
struct controlset *s;
union control *c;
/*
* The Conf structure contains two Unix-specific elements which
* are not configured in here: stamp_utmp and login_shell. This
* is because pterm does not put up a configuration box right at
* the start, which is the only time when these elements would
* be useful to configure.
*/
/*
* On Unix, we don't have a drop-down list for the printer
* control.
*/
s = ctrl_getset(b, "Terminal", "printing", "Remote-controlled printing");
assert(s->ncontrols == 1 && s->ctrls[0]->generic.type == CTRL_EDITBOX);
s->ctrls[0]->editbox.has_list = false;
/*
* Unix supports a local-command proxy. This also means we must
* adjust the text on the `Telnet command' control.
*/
if (!midsession) {
int i;
s = ctrl_getset(b, "Connection/Proxy", "basics", NULL);
for (i = 0; i < s->ncontrols; i++) {
c = s->ctrls[i];
if (c->generic.type == CTRL_RADIO &&
c->generic.context.i == CONF_proxy_type) {
assert(c->generic.handler == conf_radiobutton_handler);
c->radio.nbuttons++;
c->radio.buttons =
sresize(c->radio.buttons, c->radio.nbuttons, char *);
c->radio.buttons[c->radio.nbuttons-1] =
dupstr("Local");
c->radio.buttondata =
sresize(c->radio.buttondata, c->radio.nbuttons, intorptr);
c->radio.buttondata[c->radio.nbuttons-1] = I(PROXY_CMD);
if (c->radio.ncolumns < 4)
c->radio.ncolumns = 4;
break;
}
}
for (i = 0; i < s->ncontrols; i++) {
c = s->ctrls[i];
if (c->generic.type == CTRL_EDITBOX &&
c->generic.context.i == CONF_proxy_telnet_command) {
assert(c->generic.handler == conf_editbox_handler);
sfree(c->generic.label);
c->generic.label = dupstr("Telnet command, or local"
" proxy command");
break;
}
}
}
}