1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

PSCP: change handling of default protocol/port.

A user points out that in the current state of PSCP, if you have some
protocol other than SSH configured in Default Settings, then
specifying a non-saved-session hostname on the PSCP command line will
cause it to try to connect with protocol SSH but the port number from
Default Settings.

A better approach is the one used in PSFTP: we use the port number
from the saved session _if_ the protocol is also one that's known to
PSCP (i.e. SSH or bare ssh-connection), and otherwise, we reset both
to sensible values.
This commit is contained in:
Simon Tatham 2020-04-19 14:40:30 +01:00
parent 21492da89e
commit b951d05819

13
pscp.c
View File

@ -395,6 +395,17 @@ static void do_cmd(char *host, char *user, char *cmd)
}
}
/*
* Force protocol to SSH if the user has somehow contrived to
* select one we don't support (e.g. by loading an inappropriate
* saved session). In that situation we assume the port number is
* useless too.)
*/
if (!backend_vt_from_proto(conf_get_int(conf, CONF_protocol))) {
conf_set_int(conf, CONF_protocol, PROT_SSH);
conf_set_int(conf, CONF_port, 22);
}
/*
* Disable scary things which shouldn't be enabled for simple
* things like SCP and SFTP: agent forwarding, port forwarding,
@ -2242,8 +2253,6 @@ int psftp_main(int argc, char *argv[])
int i;
bool sanitise_stderr = true;
settings_set_default_protocol(PROT_SSH);
sk_init();
/* Load Default Settings before doing anything else. */