]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
trust anchors: implementation cleanup
authorVladimír Čunát <vladimir.cunat@nic.cz>
Sat, 19 Jan 2019 14:19:54 +0000 (15:19 +0100)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 23 Jan 2019 16:33:57 +0000 (16:33 +0000)
We don't need the trustanchor() lua function for root bootstrap
anymore, so let's get rid of it.  It was undocumented (internal).

.luacheckrc
daemon/engine.c
daemon/lua/trust_anchors.lua.in

index 992011fc961df0e6a57077604549f5196178c476..26f72e4761a2c21dfb2c80779ebc6782895af2e9 100644 (file)
@@ -37,7 +37,6 @@ new_read_globals = {
        'option',
        'env',
        'kres',
-       'trustanchor',
        'libknot_SONAME',
        'libzscanner_SONAME',
        'table_print',
index 5eebe3dd63ec37d8df8b2ffb6287ecd3c30c374b..af446a726f2a05d563a3263b80f3aec7b8bb9306 100644 (file)
@@ -299,59 +299,6 @@ static int l_moduledir(lua_State *L)
        return 1;
 }
 
-/** @internal for l_trustanchor: */
-static void ta_add(zs_scanner_t *zs)
-{
-       map_t *ta = zs->process.data;
-       if (!ta)
-               return;
-       if (kr_ta_add(ta, zs->r_owner, zs->r_type, zs->r_ttl, zs->r_data, zs->r_data_length))
-               zs->process.data = NULL; /* error signalling */
-}
-/** Enable/disable trust anchor. */
-static int l_trustanchor(lua_State *L)
-{
-       struct engine *engine = engine_luaget(L);
-       const char *anchor = lua_tostring(L, 1);
-       bool enable = lua_isboolean(L, 2) ? lua_toboolean(L, 2) : true;
-       if (!anchor || strlen(anchor) == 0) {
-               return 0;
-       }
-       /* If disabling, parse the owner string only. */
-       if (!enable) {
-               knot_dname_t *owner = knot_dname_from_str(NULL, anchor, KNOT_DNAME_MAXLEN);
-               if (!owner) {
-                       lua_pushstring(L, "invalid trust anchor owner");
-                       lua_error(L);
-               }
-               lua_pushboolean(L, kr_ta_del(&engine->resolver.trust_anchors, owner) == 0);
-               free(owner);
-               return 1;
-       }
-
-       /* Parse the record */
-       zs_scanner_t *zs = malloc(sizeof(*zs));
-       if (!zs || zs_init(zs, ".", 1, 0) != 0) {
-               free(zs);
-               lua_pushstring(L, "not enough memory");
-               lua_error(L);
-       }
-       zs_set_processing(zs, ta_add, NULL, &engine->resolver.trust_anchors);
-       bool ok = zs_set_input_string(zs, anchor, strlen(anchor)) == 0
-               && zs_parse_all(zs) == 0;
-       ok = ok && zs->process.data; /* reset to NULL on error in ta_add */
-
-       zs_deinit(zs);
-       free(zs);
-       /* Report errors */
-       if (!ok) {
-               lua_pushstring(L, "failed to process trust anchor RR");
-               lua_error(L);
-       }
-       lua_pushboolean(L, true);
-       return 1;
-}
-
 /** Load root hints from zonefile. */
 static int l_hint_root_file(lua_State *L)
 {
@@ -688,8 +635,6 @@ static int init_state(struct engine *engine)
        lua_setglobal(engine->L, "verbose");
        lua_pushcfunction(engine->L, l_setuser);
        lua_setglobal(engine->L, "user");
-       lua_pushcfunction(engine->L, l_trustanchor);
-       lua_setglobal(engine->L, "trustanchor");
        lua_pushcfunction(engine->L, l_hint_root_file);
        lua_setglobal(engine->L, "_hint_root_file");
        lua_pushliteral(engine->L, libknot_SONAME);
index e8499a015a1178fff4020eeb955c34a7026b1ea7..fdeb143632dd43b3e4126829859d503b8be69c49 100644 (file)
@@ -541,11 +541,8 @@ local add_file = function (path, unmanaged)
                        error(msg)
                end
                print(msg)
-               trustanchor(tas)
+               trust_anchors.add(tas)
                -- Fetch DNSKEY immediately
-               if not trust_anchors.keysets['\0'] then
-                       trust_anchors.keysets['\0'] = { owner = '\0' }
-               end
                local keyset = trust_anchors.keysets['\0']
                keyset.filename = path
                if keyset.refresh_ev then event.cancel(keyset.refresh_ev) end