Go Back   The macosxhints Forums > OS X Help Requests > UNIX - X11



Reply
 
Thread Tools Rate Thread Display Modes
Old 11-21-2010, 01:01 AM   #1
m.g.daniel
Prospect
 
Join Date: Nov 2010
Posts: 7
PuTTY and X11

OSX 10.6.5 and freshly built PuTTY in the OSX ports environment.

Recently emigrated from GNU/Linux (Fedora distro) and still finding my sea-legs. Use PuTTY from GNU/Linux and Windows and wish to continue to do so (lowest common denominator :-)

PuTTY works a treat as an SSH terminal client. However, X11 forwarding, which works on all other platforms, fails to connect to the OSX X11 server. For example, from a PuTTY session on the *same* OSX host (same on others):

gort:~ $ xterm
X connection to localhost0:10.0 broken (explicit kill or server shutdown).
gort:~ $

Works OK from within terminal/iTerm "ssh -Y blah@blah" to the same host.

Have Googled extensively. Is there something obvious I'm missing here?
m.g.daniel is offline   Reply With Quote
Old 11-21-2010, 11:12 AM   #2
fracai
MVP
 
Join Date: May 2004
Posts: 2,087
You're probably best off posting on the MacPorts user support list.
Maybe open a new bug. Probably best off waiting for suggestions from the list first.

Out of curiosity, if it works fine using the system tools, what does PuTTY provide that makes it worth the effort?
fracai is offline   Reply With Quote
Old 11-21-2010, 11:23 AM   #3
m.g.daniel
Prospect
 
Join Date: Nov 2010
Posts: 7
Quote:
Originally Posted by fracai
You're probably best off posting on the MacPorts user support list.
Maybe open a new bug. Probably best off waiting for suggestions from the list first.

Out of curiosity, if it works fine using the system tools, what does PuTTY provide that makes it worth the effort?

Compatibility with other platforms I work from (GNU/Linux, Windows) and a reasonably functional VT1nn emulation. Will wait. I don't use the X11 forwarding very often but it's a nice-to-have and should just work.
m.g.daniel is offline   Reply With Quote
Old 11-21-2010, 12:39 PM   #4
fracai
MVP
 
Join Date: May 2004
Posts: 2,087
What do you mean by "compatibility"? Consistent interface? Or do you actually mean that only PuTTY is able to connect to some other hosts?

Are the VT100 and VT102 modes of Terminal not sufficient? Can't say that I'm familiar with the intricacies of emulation modes.
fracai is offline   Reply With Quote
Old 11-21-2010, 02:42 PM   #5
robinwmills
Major Leaguer
 
Join Date: Sep 2007
Location: San Jose, CA, USA.
Posts: 290
I'm not sure what you're asking here. I use ssh (-X) from Terminal.app to run X-Windows clients on the Mac (with the server running on Fedora). Works well. I use putty from Windows and that's also fine. I've never thought about putty on the Mac - terminal (and xterm) seem sufficient to me.
__________________
Robin
http://clanmills.com
24" iMac, 17" Powerbook, Vaio Ubuntu/W7 Laptop.
robinwmills is offline   Reply With Quote
Old 11-21-2010, 04:37 PM   #6
m.g.daniel
Prospect
 
Join Date: Nov 2010
Posts: 7
I understand others' interest in why PuTTY; but really, why not? And my interest is with the OSX X11 interaction. I have done the terminal and the iTerm. My preference is to continue to use the application I use elsewhere.

Additional information; I am now remote from the OSX system and have SSHed into it from PuTTY running under Windows (XP) with an Xming display server. I can display OSX X11 applications on my Windows system, though no real surprise in that.

Now at the OSX command line I putty and the PuTTY Configuration dialog displays. I select a Saved Session of one that cannot display to the OSX system. It [I should say; an X11 application within that sessions] displays with the Xming server.

So, it's not something intrinsic to the OSX Ports PuTTY! Points at the OSX X11 server - configuration probably. I had already experimented with xhost + and defaults write org.x.X11 nolisten_tcp 0 and a couple of other elements but having established PuTTY's functionality will need to systematically investigate the OSX X11 server config when I am no longer remote. Looks like the terminal and iTerm are using some built-for-OSX capability to communicate with the X11 server that the ported PuTTY lacks.

Last edited by m.g.daniel; 11-21-2010 at 05:09 PM. Reason: clarification
m.g.daniel is offline   Reply With Quote
Old 11-22-2010, 02:17 AM   #7
m.g.daniel
Prospect
 
Join Date: Nov 2010
Posts: 7
OK, to cut a long story a little shorter ...

Ports-built PuTTY (at least under Mac OS X 10.6.5 (10H574) and it's default X11) requires in the PuTTY X11 Configuration:
[x] Enable X11 forwarding
X display location [:0 ]
Remote X11 authentication protocol
[x] MIT-Magic-Cookie-1 [ ] XDM-Authorization-1
With the significant datum a display location of ":0" (i.e. colon zero).

This corresponds to an X11 DISPLAY host of default, display number of default, and screen number of zero.
http://www.xfree86.org/current/X.7.html
Why? I'm guessing something defaulted in the OSX DISPLAY that's a bit "non-standard" and throwing the PuTTY parser. On an OSX xterm run up under it the DISPLAY variable certainly looks a little unusual to me (and I'm guessing anyone brought up on a non-OSX diet):
bash-3.2$ echo $DISPLAY
/tmp/launch-j0aS4K/org.x:0
Entering ":0" makes PuTTY parse the config string rather than anything generated using the OSX system's DISPLAY data and allows a meaningful X11 display target to be generated rather than something from a PuTTY barf. Proof would probably require a PuTTY code analysis to see how it might process an OSX DISPLAY string - certainly time I won't be investing now I have a workaround :-)

How did I get to here? Lots of Googling and experimenting (mainly eliminating possibilities) and one of those I wonder turned into an a-ha experience.
m.g.daniel is offline   Reply With Quote
Old 11-22-2010, 08:09 AM   #8
fracai
MVP
 
Join Date: May 2004
Posts: 2,087
The "non-standard" DISPLAY variable is how OS X launches X11 on demand, instead of requiring X apps be run directly from the X11 application.
It's interesting that setting it to the standard ":0" allows PuTTY to find the display, usually this breaks X11 under OS X.

You should write this up and submit it as a hint.
fracai is offline   Reply With Quote
Old 11-22-2010, 03:08 PM   #9
m.g.daniel
Prospect
 
Join Date: Nov 2010
Posts: 7
Happy to do this. Might look more closely at the underlying mechanisms first (especially the OSX DISPLAY kludge).
m.g.daniel is offline   Reply With Quote
Old 11-23-2010, 05:17 AM   #10
m.g.daniel
Prospect
 
Join Date: Nov 2010
Posts: 7
I've isolated the issue by examining the PuTTY code and then confirmed the suspicion by making a code change.

It is the OSX DISPLAY kludge!

Traditionally DISPLAY has had three components:
host:display.screen
http://www.xfree86.org/current/X.7.html
where host is the domain name or IP address of the X Window display server host. When absent it essentially defaults to localhost.

With the OSX DISPLAY this parses to a host of
/tmp/launch-j0aS4K/org.x
Now PuTTY in module x11fwd.c function x11_init() parses the DISPLAY data and attempts to resolve the host name:

Code:
    if(!strcmp(host, "unix")) {
	/* use AF_UNIX sockets (doesn't make sense on all platforms) */
	addr = platform_get_x11_unix_address(displaynum,
					     &dummy_realhost);
	port = 0;		/* to show we are not confused */
    } else {
	port = 6000 + displaynum;
	
	/*
	 * Try to find host.
	 */
	addr = name_lookup(host, port, &dummy_realhost, cfg, ADDRTYPE_UNSPEC);
	if ((err = sk_addr_error(addr)) != NULL) {
	    sk_addr_free(addr);
	    return err;
	}
    }
Of course the string "/tmp/launch...blah" does not resolve returning an error.

Placing ":0" into the PuTTY X11 display location configuration overrides the OSX DISPLAY and avoids the name resolution.

It would seem the simplest code base workaround might be the same as PuTTY uses for Unix family sockets and just use the underlying host:

Code:
    if(!strcmp(host, "unix") || strstr(host, "/tmp/")) {
Of course a better (and more expensive) approach would be to test the host component to see if it looked like a domain name or IP address before name resolution but considering OSX is the odd man out here ...

PuTTY is not the only victim. In Googling over the past few days I have noticed a significant number of reports of the x11.app and associated DISPLAY in Leopard X11 having brought users and applications unstuck.

Hmmm.

Last edited by m.g.daniel; 11-23-2010 at 05:18 AM. Reason: typo
m.g.daniel is offline   Reply With Quote
Old 11-23-2010, 07:40 AM   #11
dmacks
All Star
 
Join Date: Dec 2004
Posts: 678
It's doing a lot of local processing of what seems like standard types of x11 operations. I don't know what putty's internals look like, but a program can just XOpenDisplay() and other libX11 functions, and it will do the right thing because libX11 on the local platform knows all about local platform weirdnesses.
dmacks is offline   Reply With Quote
Old 11-23-2010, 04:48 PM   #12
m.g.daniel
Prospect
 
Join Date: Nov 2010
Posts: 7
I'm not an X Window System programmer or a PuTTY developer so any further comment of mine regarding these is moot. I have been a X Window System user across a number of platforms for twenty-plus years and have only now experienced such DISPLAY weirdness (though I'm prepared to concede I may have lived a sheltered life). I only opened up PuTTY code to better understand why the workaround did. I do not intend to pursue it further.
m.g.daniel is offline   Reply With Quote
Reply

Tags
putty x11 forwarding

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:37 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.