[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-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).