From 929bbe192d92905bcafa8b818fac6e90f0a07c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Tue, 30 Nov 2021 00:04:35 +0100 Subject: [PATCH] Improve error message when directory name is given 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 | 2 ++ lib/isc/lex.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/isc/errno2result.c b/lib/isc/errno2result.c index 623ac6dbe9..0c465952be 100644 --- a/lib/isc/errno2result.c +++ b/lib/isc/errno2result.c @@ -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: diff --git a/lib/isc/lex.c b/lib/isc/lex.c index 8ab3682873..b09c09635a 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -27,6 +27,8 @@ #include #include +#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; }