]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
trust_anchor: propper error message when file cannot be read
authorVítězslav Kříž <vitezslav.kriz@nic.cz>
Mon, 4 Dec 2017 14:18:22 +0000 (15:18 +0100)
committerVítězslav Kříž <vitezslav.kriz@nic.cz>
Mon, 4 Dec 2017 15:48:05 +0000 (16:48 +0100)
daemon/lua/trust_anchors.lua.in

index feaad730824a184a225a33cb4bdc59189f253190..d21a34d2c95648ae40216f8206f8568281e1ee5c 100644 (file)
@@ -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