Status of Bugzilla #1153

Darren Tucker dtucker at zip.com.au
Wed Feb 22 23:58:07 EST 2006


On Wed, Feb 22, 2006 at 11:13:03AM +0100, Simon Vallet wrote:
> I see that there is strong opposition to this patch, because it breaks
> your setup, probably other ones too, and this is clearly undesirable. 
> We agree on this -- however I still think there is a bug, and that it
> should be fixed : Darren suggested an interesting alternative -- I
> think we might agree on this one.

Here's a quick patch that implements what was described.  It's not nice
in places, but should prove whether or not it works as expected.

BTW, we don't want it for X11UseLocalhost=yes as it will cause this:

$ echo $DISPLAY
gate.dtucker.net/unix:13
$ xterm
_X11TransSocketUNIXConnect: Can't connect: errno = 2


Index: session.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/session.c,v
retrieving revision 1.313
diff -u -p -r1.313 session.c
--- session.c	7 Feb 2006 23:17:44 -0000	1.313
+++ session.c	22 Feb 2006 12:54:15 -0000
@@ -1158,7 +1158,7 @@ static void
 do_rc_files(Session *s, const char *shell)
 {
 	FILE *f = NULL;
-	char cmd[1024];
+	char cmd[1024], dpy[1024];
 	int do_xauth;
 	struct stat st;
 
@@ -1213,10 +1213,39 @@ do_rc_files(Session *s, const char *shel
 			fprintf(f, "add %s %s %s\n",
 			    s->auth_display, s->auth_proto,
 			    s->auth_data);
-			pclose(f);
+			if (pclose(f) != 0)
+				error("%s failed.", options.xauth_location);
 		} else {
 			fprintf(stderr, "Could not run %s\n",
 			    cmd);
+			return;
+		}
+		if (options.x11_use_localhost)
+			return;
+		snprintf(cmd, sizeof cmd, "%s -q list %s",
+		    options.xauth_location, s->auth_display);
+		f = popen(cmd, "r");
+		if (f) {
+			if (fgets(cmd, sizeof(cmd), f) == NULL) {
+				error("Could not read xauth data: %s",
+				    strerror(errno));
+			} else {
+				if (sscanf(cmd, "%1024s %*s %*s", dpy) != 1) {
+					error("Bad xauth data");
+				} else {
+					debug("xauth returned display %s",
+					    s->display);
+					xfree(s->display);
+					s->display = xstrdup(dpy);
+					setenv("DISPLAY", s->display, 1);
+				}
+			}
+			if (pclose(f) != 0)
+				error("%s failed.", options.xauth_location);
+		} else {
+			fprintf(stderr, "Could not run %s list\n",
+			    cmd);
+			return;
 		}
 	}
 }

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.




More information about the openssh-unix-dev mailing list