]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Use local username consistently in Unix Plink.
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Mon, 5 Jan 2015 23:41:43 +0000 (23:41 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Mon, 5 Jan 2015 23:51:12 +0000 (23:51 +0000)
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

index 3bcec398b60d13627ef6e7d58b813796728f346d..6290a2c2a713b7adb2a4bd7fc1debd99591ae058 100644 (file)
@@ -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.
      */