the default X display should be whatever comes out of $DISPLAY,
rather than Windows's hardwired `localhost:0'. Secondly, this may
give rise to a display name without a hostname (`:0' or similar),
which we now need to be able to deal with. Of course, we still don't
_properly_ support X forwarding in Unix Plink, since we still can't
authenticate with the local display.
git-svn-id: svn://svn.tartarus.org/sgt/putty@2420
cda61777-01e9-0310-a592-
d414129be87e
gppi(sesskey, "BCE", 1, &cfg->bce);
gppi(sesskey, "BlinkText", 0, &cfg->blinktext);
gppi(sesskey, "X11Forward", 0, &cfg->x11_forward);
gppi(sesskey, "BCE", 1, &cfg->bce);
gppi(sesskey, "BlinkText", 0, &cfg->blinktext);
gppi(sesskey, "X11Forward", 0, &cfg->x11_forward);
gpps(sesskey, "X11Display", "localhost:0", cfg->x11_display,
sizeof(cfg->x11_display));
gpps(sesskey, "X11Display", "localhost:0", cfg->x11_display,
sizeof(cfg->x11_display));
+#else
+ {
+ /* On Unix, the default X display should simply be $DISPLAY. */
+ char *disp = getenv("DISPLAY");
+ gpps(sesskey, "X11Display", disp, cfg->x11_display,
+ sizeof(cfg->x11_display));
+ }
+#endif
gppi(sesskey, "LocalPortAcceptAll", 0, &cfg->lport_acceptall);
gppi(sesskey, "RemotePortAcceptAll", 0, &cfg->rport_acceptall);
gppi(sesskey, "LocalPortAcceptAll", 0, &cfg->lport_acceptall);
gppi(sesskey, "RemotePortAcceptAll", 0, &cfg->rport_acceptall);
displaynum = 0; /* sensible default */
if (n > sizeof(host) - 1)
n = sizeof(host) - 1;
displaynum = 0; /* sensible default */
if (n > sizeof(host) - 1)
n = sizeof(host) - 1;
- strncpy(host, display, n);
- host[n] = '\0';
+ if (n > 0) {
+ strncpy(host, display, n);
+ host[n] = '\0';
+ } else {
+ /*
+ * Local display numbers, particularly on Unix, often omit
+ * the display part completely.
+ */
+ strcpy(host, "localhost");
+ }