rndc exits with error message "rndc: src/unix/core.c:580: uv__close: Assertion `fd > 2' failed." when STDIN is closed
Summary
When the 9.18.16 version of rndc is invoked when STDIN is closed, it panics with "rndc: src/unix/core.c:580: uv__close: Assertion `fd > 2' failed.". The 9.16.37 version, and all earlier versions, do not have this behavior.
BIND version used
BIND 9.18.16 (Extended Support Version) id:8193c9b running on Linux x86_64 3.10.0-1160.95.1.el7.x86_64 #1 SMP Fri Jun 23 08:44:55 EDT 2023 built by make with '--prefix=/opt/bind-9.18.16' '--disable-doh' compiled by GCC 4.8.5 20150623 (Red Hat 4.8.5-44) compiled with OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017 linked to OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017 compiled with libuv version: 1.43.0 linked to libuv version: 1.43.0 compiled with libxml2 version: 2.9.1 linked to libxml2 version: 20901 compiled with zlib version: 1.2.7 linked to zlib version: 1.2.7 threads support is enabled DNSSEC algorithms: RSASHA1 NSEC3RSASHA1 RSASHA256 RSASHA512 ECDSAP256SHA256 ECDSAP384SHA384 DS algorithms: SHA-1 SHA-256 SHA-384 HMAC algorithms: HMAC-MD5 HMAC-SHA1 HMAC-SHA224 HMAC-SHA256 HMAC-SHA384 HMAC-SHA512 TKEY mode 2 support (Diffie-Hellman): yes TKEY mode 3 support (GSS-API): yes
default paths: named configuration: /opt/bind-9.18.16/etc/named.conf rndc configuration: /opt/bind-9.18.16/etc/rndc.conf DNSSEC root key: /opt/bind-9.18.16/etc/bind.keys nsupdate session key: /opt/bind-9.18.16/var/run/named/session.key named PID file: /opt/bind-9.18.16/var/run/named/named.pid named lock file: /opt/bind-9.18.16/var/run/named/named.lock
Steps to reproduce
While this is an odd use case, it is critical to our disaster recovery process. rndc should not care if STDIN is open or not as it does not require it.
Code or rndctest.c that reproduces the issue. Compile with gcc -o rndctest rndctest.c
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <fcntl.h>
int main(argc,argv) int argc; char *argv[]; { int option; char *logdir = (char *)NULL; char *logfile = (char *)NULL; int status; int verbose = 0; int exit_code = 0; int ofd; int fd; char *rndcargs[4]; char rarg1="/u1/kwieman/rndc"; / Point this to the rndc binary */ char *rarg2="reload"; char rarg3="tstcloud.blackrock.com"; / Point this to a valid DNS zone */
close(1);
ofd = open("rndc.stdout",O_WRONLY|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
if (ofd == -1)
exit(-2);
close(2);
fd = open("rndc.stderr",O_WRONLY|O_CREAT,
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
if (fd == -1)
exit(-3);
close(0);
rndcargs[0] = rarg1;
rndcargs[1] = rarg2;
rndcargs[2] = rarg3;
rndcargs[3] = (char *)0;
if (execv("/u1/kwieman/rndc",rndcargs))
exit_code = 1;
exit(exit_code);
}
What is the current bug behavior?
rndc reload panics when STDIN is not open.
What is the expected correct behavior?
rndc should not panic.
Relevant configuration files
(Paste any relevant configuration files - please use code blocks (```)
to format console output. If submitting the contents of your
configuration file in a non-confidential Issue, it is advisable to
obscure key secrets: this can be done automatically by using
named-checkconf -px
.)
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code, as it's very hard to read otherwise.)
Possible fixes
(If you can, link to the line of code that might be responsible for the problem.)