ssh localhost yes | true (follow up)

Kyle McKay mackyle at gmail.com
Thu Apr 23 23:22:08 EST 2009


I filed bug 6810722 with Apple and sent them a patch that makes the  
half-close fix work again without causing problems with shells (like  
Apple's bash that attempt to detect when they're being run by a remote  
shell daemon such as sshd by apparently checking standard input to see  
if it's a socket).

On Apr 21, 2009, at 01:27, Kyle McKay wrote:
> On Apr 20, 2009, at 23:53, Damien Miller wrote:
>> There may be differences depending on whether
>> Apple has modified their sshd to avoid using pipes (thwarting the
>> half-close fix in the process), but you will need to post a full  
>> debug
>> log from the server to tell.
>>
>> -d
>
> Yup, you're right.  Apple has disabled the USE_PIPES define in their  
> source code.


FYI, patch is below.

Again, thanks for all your help with this.

Kyle

Patch is against the version of session.c that has all of Apple's  
patches already applied and can be found at:

http://www.opensource.apple.com/darwinsource/10.5.6/OpenSSH-95.1.5/openssh/session.c

--- session.c	2008-08-13 17:40:56.000000000 -0700
+++ session.c	2009-04-23 04:39:14.000000000 -0700
@@ -424,9 +424,7 @@
	}
}

-#ifndef __APPLE__
#define USE_PIPES
-#endif
/*
  * This is called to fork and execute a command when we have no tty.   
This
  * will call do_child from the child, and server_loop from the parent  
after
@@ -440,11 +438,12 @@
#ifdef USE_PIPES
	int pin[2], pout[2], perr[2];

-	/* Allocate pipes for communicating with the program. */
-	if (pipe(pin) < 0) {
-		error("%s: pipe in: %.100s", __func__, strerror(errno));
+	/* Allocate socketpair for communicating with the program input. */
+	if (socketpair(AF_UNIX, SOCK_STREAM, 0, pin) < 0) {
+		error("%s: socketpair #1: %.100s", __func__, strerror(errno));
		return -1;
	}
+	/* Allocate pipes for communicating with the program output. */
	if (pipe(pout) < 0) {
		error("%s: pipe out: %.100s", __func__, strerror(errno));
		close(pin[0]);



More information about the openssh-unix-dev mailing list