bb_sanitize_stdio_maybe_daemonize faulty logic...

David Daney ddaney at avtrex.com
Wed Feb 14 10:54:43 PST 2007


Denis Vlasenko wrote:
> On Wednesday 14 February 2007 01:07, David Daney wrote:
>>>>>> Yes, I know. Have better ideas (apart from closing all fds from 
>>>>>> 9999999999 to 3)?
>>>>> It is a difficult problem.  In practice you don't have to go all the way 
>>>>> to 9999999999, the value returned by ulimit -n would be high enough.
>>>>>
>>>>> You could also set the close-on-exec flag on all descriptors that should 
>>>>> not leak from busybox, then you would not need this part.
>>> You see, this function isn't meant to be 100.00% watertight.
>>>
>>> It just tries to close some stray opne fds, but does not
>>> promise to do it reliably for all weird cases.
>>>
>> It could easily be made 100% by:
>>
>> struct rlimit rl;
>> int i;
>> getrlimit(RLIMIT_NOFILE, &rl);
>> for (i = 3; i < rl.rlim_cur; i++)
>>      close(i);
> 
> This is what I meant by "close all fds from 9999999 to 3".

Fine.  You are the maintainer.  1024 is quite a bit smaller than 
9999999, but if you think it is useful as it is then I will not get too 
worked up about it.

David Daney


More information about the busybox mailing list