]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Improve error message when directory name is given
authorPetr Menšík <pemensik@redhat.com>
Mon, 29 Nov 2021 23:04:35 +0000 (00:04 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Fri, 10 Dec 2021 09:50:21 +0000 (10:50 +0100)
Surprising error IO error is returned when directory name
is given instead of named.conf file. It can be passed to named-checkconf
or include statement. Make a simple change to return Invalid file
instead. Still not precise, but much better error message is returned.

Fix of rhbz#490837.

lib/isc/errno2result.c
lib/isc/lex.c

index 623ac6dbe9e181aad582114bd8ffb3981c5344a7..0c465952bed573fb94b555123a22f7613d827dc4 100644 (file)
@@ -37,6 +37,8 @@ isc___errno2result(int posixerrno, bool dolog, const char *file,
        case ENAMETOOLONG:
        case EBADF:
                return (ISC_R_INVALIDFILE);
+       case EISDIR:
+               return (ISC_R_NOTFILE);
        case ENOENT:
                return (ISC_R_FILENOTFOUND);
        case EACCES:
index 8ab368287397aade4368be6f780fcd53ce85322a..b09c09635adbbdf2b9af358fa527e18b3367af2f 100644 (file)
@@ -27,6 +27,8 @@
 #include <isc/string.h>
 #include <isc/util.h>
 
+#include "errno2result.h"
+
 typedef struct inputsource {
        isc_result_t result;
        bool is_file;
@@ -425,7 +427,9 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
 #endif /* if defined(HAVE_FLOCKFILE) && defined(HAVE_GETC_UNLOCKED) */
                                if (c == EOF) {
                                        if (ferror(stream)) {
-                                               source->result = ISC_R_IOERROR;
+                                               source->result =
+                                                       isc__errno2result(
+                                                               errno);
                                                result = source->result;
                                                goto done;
                                        }