libast.so and /usr/lib/extendedFILE.so / was: Re: [request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-13 Thread casper....@sun.com

Casper.Dik at Sun.COM wrote:
 Due to the 32-bit ABI's stdio file descriptor limit, an interposer is
 being used to F_DUPFD non-stdio file descriptors to 256 and above. This
 mitigates a problem with 3rd party modules and plugins that use
 fopen(3C), et al. streams in processes such as Apache HTTP Server that
 open a large number of file descriptors. Unfortunately, using the
 interposer causes failures when a child process (e.g. CGI program)
 subsequently invokes telnet(1). If telnet passed the correct nfds value
 to select(3C), that failure would be eliminated.
 
 In build 39 of Nevada we provide a standard interposer,
 /usr/lib/extendedFILE.so, which has a similar, but different property.

Umpf... for the same reason we were thinking about making the
stdio-replacement API in libast public since it it supports an almost
unlimited number of stdio channels...

Note that /usr/lib/extendedFILE.so does *not* use F_DUPFD; it calls
enable_extended_FILE_stdio(-1, -1) which makes a gaurantee on behalf of
the application that it does not reference FILE._file and in return the
C Library allows for the use of file descriptors  255.

The kernel and the C library conspire such that any use of a FILE._file
for FILE's opened with a file descriptor over 255 will cause the application
to die with SIGABRT.

Casper



libast.so and /usr/lib/extendedFILE.so / was: Re: [request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-10 Thread Roland Mainz
Casper.Dik at Sun.COM wrote:
 Due to the 32-bit ABI's stdio file descriptor limit, an interposer is
 being used to F_DUPFD non-stdio file descriptors to 256 and above. This
 mitigates a problem with 3rd party modules and plugins that use
 fopen(3C), et al. streams in processes such as Apache HTTP Server that
 open a large number of file descriptors. Unfortunately, using the
 interposer causes failures when a child process (e.g. CGI program)
 subsequently invokes telnet(1). If telnet passed the correct nfds value
 to select(3C), that failure would be eliminated.
 
 In build 39 of Nevada we provide a standard interposer,
 /usr/lib/extendedFILE.so, which has a similar, but different property.

Umpf... for the same reason we were thinking about making the
stdio-replacement API in libast public since it it supports an almost
unlimited number of stdio channels...



Bye,
Roland

P.S.: Reply-To: set to ksh93-integration-discuss at opensolaris.org as this
is more or less libast-related

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, CJAVASunUnix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)



[request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-02 Thread James Carlson
Chris Elving writes:
 I'm seeking a sponsor for the following change to 
 /usr/src/cmd/cmd-inet/usr.bin/telnet/sys_bsd.c for telnet(1):
[...]
 +   int nfds = 0;

Since we know that tin and tout are 0 and 1 (fixed), the whole thing
can likely be reduced to just:

 -   if ((c = select(16, ibits, obits, xbits,
 +   if ((c = select(net + 1, ibits, obits, xbits,

But the bigger question is why this is needed.  It'd have to be some
situation in which telnet was exec'd with the first 16 descriptors
already open.  Does that happen?

Could you file a bug first?

-- 
James Carlson, KISS Networkjames.d.carlson at sun.com
Sun Microsystems / 1 Network Drive 71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677



[request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-02 Thread Jonathan Adams
On Tue, May 02, 2006 at 09:43:00AM -0400, James Carlson wrote:
 Chris Elving writes:
  I'm seeking a sponsor for the following change to 
  /usr/src/cmd/cmd-inet/usr.bin/telnet/sys_bsd.c for telnet(1):
 [...]
  +   int nfds = 0;
 
 Since we know that tin and tout are 0 and 1 (fixed), the whole thing
 can likely be reduced to just:
 
  -   if ((c = select(16, ibits, obits, xbits,
  +   if ((c = select(net + 1, ibits, obits, xbits,
 
 But the bigger question is why this is needed.  It'd have to be some
 situation in which telnet was exec'd with the first 16 descriptors
 already open.  Does that happen?

Couldn't you just start main() with:

closefrom(3);

to close any extra file descriptors?

Cheers,
- jonathan

-- 
Jonathan Adams, Solaris Kernel Development



[request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-02 Thread James Carlson
Jonathan Adams writes:
 Couldn't you just start main() with:
 
   closefrom(3);
 
 to close any extra file descriptors?

Yes, that'd be much better.

-- 
James Carlson, KISS Networkjames.d.carlson at sun.com
Sun Microsystems / 1 Network Drive 71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677



[request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-02 Thread Chris Elving
James Carlson wrote:

 But the bigger question is why this is needed.  It'd have to be some
 situation in which telnet was exec'd with the first 16 descriptors
 already open.  Does that happen?

Due to the 32-bit ABI's stdio file descriptor limit, an interposer is
being used to F_DUPFD non-stdio file descriptors to 256 and above. This
mitigates a problem with 3rd party modules and plugins that use
fopen(3C), et al. streams in processes such as Apache HTTP Server that
open a large number of file descriptors. Unfortunately, using the
interposer causes failures when a child process (e.g. CGI program)
subsequently invokes telnet(1). If telnet passed the correct nfds value
to select(3C), that failure would be eliminated.

 Could you file a bug first?

I submitted a bug report through
https://www.opensolaris.org/bug/report.jspa before mailing
request-sponsor at opensolaris.org, but I don't believe a corresponding CR
was opened.




[request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-02 Thread James Carlson
Chris Elving writes:
 Due to the 32-bit ABI's stdio file descriptor limit, an interposer is
 being used to F_DUPFD non-stdio file descriptors to 256 and above. This
 mitigates a problem with 3rd party modules and plugins that use
 fopen(3C), et al. streams in processes such as Apache HTTP Server that
 open a large number of file descriptors. Unfortunately, using the
 interposer causes failures when a child process (e.g. CGI program)
 subsequently invokes telnet(1). If telnet passed the correct nfds value
 to select(3C), that failure would be eliminated.

Thanks!  That's the key piece I was missing.

In that case, I suspect that closefrom() won't fix the problem, as the
socket() call will return a descriptor that's above the limit and run
into the problem again.

-- 
James Carlson, KISS Networkjames.d.carlson at sun.com
Sun Microsystems / 1 Network Drive 71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677



[request-sponsor] telnet(1) cannot handle more than 15 fds

2006-05-01 Thread Chris Elving
I'm seeking a sponsor for the following change to 
/usr/src/cmd/cmd-inet/usr.bin/telnet/sys_bsd.c for telnet(1):

--- sys_bsd.c   Sun Jun 12 16:00:08 2005
+++ sys_bsd.c.fixed Mon May  1 19:18:16 2006
@@ -756,2 +756,3 @@
 register int c;
+   int nfds = 0;
 /*
@@ -768,2 +769,4 @@
 FD_SET(net, obits);
+   if (nfds  net + 1)
+   nfds = net + 1;
 }
@@ -771,2 +774,4 @@
 FD_SET(tout, obits);
+   if (nfds  tout + 1)
+   nfds = tout + 1;
 }
@@ -774,2 +779,4 @@
 FD_SET(tin, ibits);
+   if (nfds  tin + 1)
+   nfds = tin + 1;
 }
@@ -781,3 +788,3 @@
 }
-   if ((c = select(16, ibits, obits, xbits,
+   if ((c = select(nfds, ibits, obits, xbits,
 (poll == 0) ? NULL : TimeValue))  0) {

The above modifies sys_bsd.c to work with file descriptors  15. A 
potentially superior but more invasive approach would be to switch from 
select(3C) to poll(2).