Subject: Re: Strange behavious of getpeername(2) on pipe
To: Unprivileged user <nobody@emsi.priv.at>
From: Martin J. Laubach <mjl@emsi.priv.at>
List: tech-kern
Date: 03/27/2001 15:22:05
| >   No. The problem is _IN_ the FCGI module.
| 
| Why FastCGI want to know whether the fd is pipe or socket? 
| Isn't that ok to know whether the fd is local or inet socket, for example?

  The FCGI perl module tries to be smart and helpful. Thus,
it tries to find out whether your script was actually invoked
as fastcgi or normal cgi, and then sets up things accordingly,
so that you can run the same cgi script in both environments.

  It does this by doing a

	if(getpeername(fd) != 0 && errno == ENOTCONN)
		{
		... fastcgi, input comes via socket and special protocol ...
		}
	else
		{
		... normal cgi, input comes via pipe ...
		}

  Unfortunately, this works on all tested unixoid systems (Solaris 7,
AIX, SINIS, FreeBSD, even OpenBSD!) but not on NetBSD.

  Therefore: ist our behaviour correct, and if so, what work-arounds
are possible?

	mjl