From: Petr Špaček Date: Thu, 14 Mar 2019 16:54:33 +0000 (+0100) Subject: trust_anchors: get rid of double negation in add_file() X-Git-Tag: v4.0.0~15^2~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=373b42ed83a97366c6abcffc17e7458c81e67eb4;p=thirdparty%2Fknot-resolver.git trust_anchors: get rid of double negation in add_file() This simple change makes it easier to follow what the code does. --- diff --git a/daemon/lua/trust_anchors.lua.in b/daemon/lua/trust_anchors.lua.in index 98bd74f9a..dce6d0689 100644 --- a/daemon/lua/trust_anchors.lua.in +++ b/daemon/lua/trust_anchors.lua.in @@ -307,7 +307,8 @@ local refresh_plan = function(keyset, delay, is_initial) end local function add_file(path, unmanaged) - if not unmanaged then + local managed = not unmanaged + if managed then if not io.open(path .. '.lock', 'w') then error("[ ta ] ERROR: write access needed to keyfile dir '"..path.."'") end @@ -315,7 +316,7 @@ local function add_file(path, unmanaged) end -- Bootstrap if requested and keyfile doesn't exist - if not unmanaged and not io.open(path, 'r') then + if managed and not io.open(path, 'r') then log("[ ta ] keyfile '%s': doesn't exist, bootstrapping", path); local tas, msg = bootstrap(trust_anchors.bootstrap_url, trust_anchors.bootstrap_ca) if not tas then @@ -328,12 +329,13 @@ local function add_file(path, unmanaged) -- Fetch DNSKEY immediately local keyset = trust_anchors.keysets['\0'] keyset.filename = path + keyset.managed = true keyset_write(keyset) if keyset.refresh_ev then event.cancel(keyset.refresh_ev) end refresh_plan(keyset, 0, true) return end - if not unmanaged and path == (trust_anchors.keysets['\0'] or {}).filename then + if managed and path == (trust_anchors.keysets['\0'] or {}).filename then return end @@ -342,7 +344,7 @@ local function add_file(path, unmanaged) if not keyset then panic("[ ta ] ERROR: failed to read anchors from '%s' (%s)", path, err) end - if not unmanaged then keyset.filename = path end + if managed then keyset.filename = path end local owner = keyset.owner local owner_str = kres.dname2str(owner) @@ -360,7 +362,7 @@ local function add_file(path, unmanaged) end -- TODO: if failed and for root, try to rebootstrap? - if not unmanaged then refresh_plan(keyset, 0 * sec, false) end + if managed then refresh_plan(keyset, 0 * sec, false) end end local function ta_str(owner)