From 3a9ce5074d628206ed2f625842b12722f53c5867 Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Mon, 5 Jan 2015 23:41:43 +0000 Subject: [PATCH] Use local username consistently in Unix Plink. It tries to use the local username as the remote username if it has no better ideas, but the presence of Default Settings would defeat this, even if it had no username set. Reported by Jonathan Amery. --- unix/uxplink.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/unix/uxplink.c b/unix/uxplink.c index 3bcec398..6290a2c2 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -119,8 +119,6 @@ char *platform_default_s(const char *name) { if (!strcmp(name, "TermType")) return dupstr(getenv("TERM")); - if (!strcmp(name, "UserName")) - return get_username(); if (!strcmp(name, "SerialLine")) return dupstr("/dev/ttyS0"); return NULL; @@ -882,6 +880,18 @@ int main(int argc, char **argv) */ cmdline_run_saved(conf); + /* + * If we have no better ideas for the remote username, use the local + * one, as 'ssh' does. + */ + if (conf_get_str(conf, CONF_username)[0] == '\0') { + char *user = get_username(); + if (user) { + conf_set_str(conf, CONF_username, user); + sfree(user); + } + } + /* * Apply subsystem status. */ -- 2.45.2