From: Vítězslav Kříž Date: Mon, 4 Dec 2017 14:18:22 +0000 (+0100) Subject: trust_anchor: propper error message when file cannot be read X-Git-Tag: v1.5.1~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9711f1d85a4795fa90a0e795f831960ce727ec74;p=thirdparty%2Fknot-resolver.git trust_anchor: propper error message when file cannot be read --- diff --git a/daemon/lua/trust_anchors.lua.in b/daemon/lua/trust_anchors.lua.in index feaad7308..d21a34d2c 100644 --- a/daemon/lua/trust_anchors.lua.in +++ b/daemon/lua/trust_anchors.lua.in @@ -263,7 +263,10 @@ end local function keyset_read(path) -- First load the regular entries, trusting them. local zonefile = require('zonefile') - local tas = zonefile.file(path) + local tas, err = zonefile.file(path) + if not tas then + return tas, err + end keyset_parse_comments(tas, key_state.Valid) -- The untrusted keys are commented out but important to load. @@ -391,15 +394,18 @@ local add_file = function (path, unmanaged) end -- Parse the file and check its sanity - local keyset = keyset_read(path) + local keyset, err = keyset_read(path) if not unmanaged then keyset.filename = path end + if not keyset then + panic("[ ta ] ERROR: failed to read anchors from '%s' (%s)", path, err) + end if not keyset[1] then - error('[ ta ] ERROR: failed to read anchors from path ' .. path) + panic("[ ta ] ERROR: failed to read anchors from '%s'", path) end local owner = keyset[1].owner for _, ta in ipairs(keyset) do if ta.owner ~= owner then - error('[ ta ] ERROR: mixed owner names found in path ' .. path) + panic("[ ta ] ERROR: mixed owner names found in '%s'", path) end end keyset.owner = owner