The old socket code did something like

        int fd = socket(…);

        if (fd == -1) {
                error handling
        }

        if (fd < 100) {
                int newfd = fcntl(fd, F_DUPFD, 100);
                if (newfd == -1) {
                        error handling
                }
                close(fd);
                fd = newfd;
        }

to leave file descriptor space for stdio to work in where the descriptors where 
stored in a (char).

> On 14 Sep 2022, at 09:06, Casey Deccio <ca...@deccio.net> wrote:
> 
> 
>> On Sep 13, 2022, at 3:35 PM, Graham Clinch <g.cli...@lancaster.ac.uk> wrote:
>> 
>> I suspect nrpe-ng is closing stdin before launching nslookup.
>> 
>> 
>> With mac homebrew's build of bind 9.18.6 and a bit of shell redirection to 
>> close stdin, I get:
>> 
>> ---
>> $ /opt/homebrew/bin/nslookup -version
>> nslookup 9.18.6
>> 
>> $ /opt/homebrew/bin/nslookup example.net 0<&-
>> [... usual output snipped ...]
>> 
>> Assertion failed: (fd > STDERR_FILENO), function uv__close, file core.c, 
>> line 602.
>> Abort trap: 6
>> 
>> $ echo $?
>> 134
>> ---
>> 
> 
> Nice find!!
> 
>> This might count as a regression of sorts from the migration to libuv, as 
>> older nslookup doesn't fail in the same way:
> 
> Could be.  At the very least it's a behavioral difference, which affects some 
> packages that depend on it.  I'll leave it to the BIND devs to determine 
> if/how to handle it.
> 
>> (dig & delv are also affected in the same way)
>> 
>> The cmake group came across the same situation with libuv and open missing 
>> standard fds against /dev/null to compensate:
>> https://gitlab.kitware.com/cmake/cmake/-/merge_requests/3282
> 
> I've patched the code for nrpe_ng, and it works!
> 
> $ diff -u /usr/lib/python3/dist-packages/nrpe_ng/commands.py{.old,}
> --- /usr/lib/python3/dist-packages/nrpe_ng/commands.py.old    2017-08-08 
> 13:05:02.000000000 -0600
> +++ /usr/lib/python3/dist-packages/nrpe_ng/commands.py        2022-09-13 
> 17:00:36.767239885 -0600
> @@ -85,6 +85,7 @@
> 
>         proc = tornado.process.Subprocess(
>             run_args,
> +            stdin=subprocess.DEVNULL,
>             stdout=tornado.process.Subprocess.STREAM,
>             close_fds=True,
>             env=env)
> 
> I'll request that something get pushed upstream.  Many thanks for help 
> tracking that down!
> 
> Casey
> -- 
> Visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from 
> this list
> 
> ISC funds the development of this software with paid support subscriptions. 
> Contact us at https://www.isc.org/contact/ for more information.
> 
> 
> bind-users mailing list
> bind-users@lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users

-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742              INTERNET: ma...@isc.org

-- 
Visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from 
this list

ISC funds the development of this software with paid support subscriptions. 
Contact us at https://www.isc.org/contact/ for more information.


bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

Reply via email to