mirror of
https://gitlab.nic.cz/knot/knot-dns.git
synced 2026-05-28 04:02:31 -04:00
libknot: remove no longer needed knot_error_from_libdnssec()
This commit is contained in:
parent
4b54add0f7
commit
0b0821dc2e
13 changed files with 24 additions and 61 deletions
|
|
@ -181,7 +181,6 @@ libknot.so.16 libknot16 #MINVER#
|
|||
knot_edns_set_version@Base 3.5.0
|
||||
knot_edns_zoneversion_parse@Base 3.5.0
|
||||
knot_edns_zoneversion_write@Base 3.5.0
|
||||
knot_error_from_libdnssec@Base 3.5.0
|
||||
knot_eth_mtu@Base 3.5.0
|
||||
knot_eth_name_from_addr@Base 3.5.0
|
||||
knot_eth_queues@Base 3.5.0
|
||||
|
|
|
|||
|
|
@ -64,13 +64,13 @@ static int params2dnskey(const knot_dname_t *dname, key_params_t *params,
|
|||
dnssec_key_t *key = NULL;
|
||||
ret = dnssec_key_new(&key);
|
||||
if (ret != KNOT_EOK) {
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = dnssec_key_set_dname(key, dname);
|
||||
if (ret != KNOT_EOK) {
|
||||
dnssec_key_free(key);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dnssec_key_set_algorithm(key, params->algorithm);
|
||||
|
|
@ -78,7 +78,7 @@ static int params2dnskey(const knot_dname_t *dname, key_params_t *params,
|
|||
ret = dnssec_key_set_pubkey(key, ¶ms->public_key);
|
||||
if (ret != KNOT_EOK) {
|
||||
dnssec_key_free(key);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = dnskey_guess_flags(key, params->keytag);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ int keystore_load(const char *config, unsigned backend,
|
|||
}
|
||||
if (ret != KNOT_EOK) {
|
||||
free(fixed_config);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
if (fixed_config == NULL) {
|
||||
dnssec_keystore_deinit(*keystore);
|
||||
|
|
@ -63,7 +63,7 @@ int keystore_load(const char *config, unsigned backend,
|
|||
free(fixed_config);
|
||||
dnssec_keystore_deinit(*keystore);
|
||||
*keystore = NULL;
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = dnssec_keystore_open(*keystore, fixed_config);
|
||||
|
|
@ -71,7 +71,7 @@ int keystore_load(const char *config, unsigned backend,
|
|||
if (ret != KNOT_EOK) {
|
||||
dnssec_keystore_deinit(*keystore);
|
||||
*keystore = NULL;
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return KNOT_EOK;
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ int key_records_sign(const zone_key_t *key, key_records_t *r, const kdnssec_ctx_
|
|||
dnssec_sign_ctx_t *sign_ctx;
|
||||
int ret = dnssec_sign_new(&sign_ctx, key->key);
|
||||
if (ret != KNOT_EOK) {
|
||||
ret = knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!knot_rrset_empty(&r->dnskey) && knot_zone_sign_use_key(key, &r->dnskey)) {
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ static int generate_salt(dnssec_binary_t *salt, uint16_t length)
|
|||
if (length > 0) {
|
||||
int r = dnssec_binary_alloc(&new_salt, length);
|
||||
if (r != KNOT_EOK) {
|
||||
return knot_error_from_libdnssec(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = dnssec_random_binary(&new_salt);
|
||||
if (r != KNOT_EOK) {
|
||||
dnssec_binary_free(&new_salt);
|
||||
return knot_error_from_libdnssec(r);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -525,7 +525,6 @@ static int load_private_keys(kdnssec_ctx_t *ctx, zone_keyset_t *keyset)
|
|||
case KNOT_EEXIST:
|
||||
break;
|
||||
default:
|
||||
ret = knot_error_from_libdnssec(ret);
|
||||
log_zone_error(ctx->zone->dname,
|
||||
"DNSSEC, key %d, failed to load private key (%s)",
|
||||
dnssec_key_get_keytag(key->key), knot_strerror(ret));
|
||||
|
|
@ -685,7 +684,6 @@ int zone_key_calculate_ds(zone_key_t *for_key, dnssec_key_digest_t digesttype,
|
|||
if (for_key->precomputed_ds.data == NULL || for_key->precomputed_digesttype != digesttype) {
|
||||
dnssec_binary_free(&for_key->precomputed_ds);
|
||||
ret = dnssec_key_create_ds(for_key->key, digesttype, &for_key->precomputed_ds);
|
||||
ret = knot_error_from_libdnssec(ret);
|
||||
for_key->precomputed_digesttype = digesttype;
|
||||
}
|
||||
|
||||
|
|
@ -795,18 +793,18 @@ int dnssec_key_from_rdata(dnssec_key_t **key, const knot_dname_t *owner,
|
|||
dnssec_key_t *new_key = NULL;
|
||||
int ret = dnssec_key_new(&new_key);
|
||||
if (ret != KNOT_EOK) {
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
ret = dnssec_key_set_rdata(new_key, &binary_key);
|
||||
if (ret != KNOT_EOK) {
|
||||
dnssec_key_free(new_key);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
if (owner != NULL) {
|
||||
ret = dnssec_key_set_dname(new_key, owner);
|
||||
if (ret != KNOT_EOK) {
|
||||
dnssec_key_free(new_key);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ int knot_create_nsec3_owner(uint8_t *out, size_t out_size,
|
|||
|
||||
int ret = dnssec_nsec3_hash(&data, params, &hash);
|
||||
if (ret != KNOT_EOK) {
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = knot_nsec3_hash_to_dname(out, out_size, hash.data, hash.size, zone_apex);
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ static int backup_key(key_params_t *parm, const knot_dname_t *zname, bool restor
|
|||
dnssec_key_t *key = NULL;
|
||||
int ret = dnssec_key_new(&key);
|
||||
if (ret != KNOT_EOK) {
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
dnssec_key_set_algorithm(key, parm->algorithm);
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ static int backup_key(key_params_t *parm, const knot_dname_t *zname, bool restor
|
|||
}
|
||||
|
||||
dnssec_key_free(key);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static conf_val_t get_zone_policy(conf_t *conf, const knot_dname_t *zone)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ int zone_contents_digest(const zone_contents_t *contents, int algorithm,
|
|||
int ret = dnssec_digest_init(algorithm, &ctx.digest_ctx);
|
||||
if (ret != KNOT_EOK) {
|
||||
free(ctx.buf);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
zone_tree_t *conts = contents->nodes;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "libknot/attribute.h"
|
||||
#include "libknot/error.h"
|
||||
#include "libknot/dnssec/error.h"
|
||||
|
||||
struct error {
|
||||
int code;
|
||||
|
|
@ -202,28 +201,6 @@ static const char *lookup_message(int code)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
_public_
|
||||
int knot_error_from_libdnssec(int libdnssec_errcode)
|
||||
{
|
||||
switch (libdnssec_errcode) {
|
||||
case KNOT_ERROR:
|
||||
return KNOT_ERROR;
|
||||
case KNOT_EMALF:
|
||||
return KNOT_EMALF;
|
||||
case KNOT_ENOENT:
|
||||
return KNOT_ENOENT;
|
||||
case KNOT_NO_PUBLIC_KEY:
|
||||
case KNOT_NO_PRIVATE_KEY:
|
||||
return KNOT_DNSSEC_ENOKEY;
|
||||
// EOK, EINVAL, ENOMEM and ENOENT are identical, no need to translate
|
||||
case KNOT_INVALID_PUBLIC_KEY ... KNOT_INVALID_KEY_NAME:
|
||||
return libdnssec_errcode
|
||||
- KNOT_INVALID_PUBLIC_KEY + KNOT_INVALID_PUBLIC_KEY;
|
||||
default:
|
||||
return libdnssec_errcode;
|
||||
}
|
||||
}
|
||||
|
||||
_public_
|
||||
const char *knot_strerror(int code)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,15 +25,4 @@
|
|||
*/
|
||||
const char *knot_strerror(int code);
|
||||
|
||||
/*!
|
||||
* \brief Translates error code from libdnssec into libknot.
|
||||
*
|
||||
* This is just temporary until everything from libdnssec moved to libknot.
|
||||
*
|
||||
* \param libdnssec_errcode Error code from libdnssec
|
||||
*
|
||||
* \return Error code.
|
||||
*/
|
||||
int knot_error_from_libdnssec(int libdnssec_errcode);
|
||||
|
||||
/*! @} */
|
||||
|
|
|
|||
|
|
@ -1078,7 +1078,7 @@ static int opt_cookie(const char *arg, void *query)
|
|||
|
||||
int ret = dnssec_random_buffer(q->cc.data, q->cc.len);
|
||||
if (ret != KNOT_EOK) {
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ int keymgr_import_bind(kdnssec_ctx_t *ctx, const char *import_file, bool pub_onl
|
|||
fail:
|
||||
dnssec_key_free(key);
|
||||
free(keyid);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void err_import_key(char *keyid, const char *file)
|
||||
|
|
@ -638,7 +638,7 @@ static int import_key(kdnssec_ctx_t *ctx, unsigned backend, const char *param,
|
|||
fail:
|
||||
dnssec_key_free(key);
|
||||
free(keyid);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int keymgr_import_pem(kdnssec_ctx_t *ctx, const char *import_file, int argc, char *argv[])
|
||||
|
|
@ -781,20 +781,20 @@ int keymgr_generate_tsig(const char *tsig_name, const char *alg_name, int bits)
|
|||
int r = dnssec_binary_alloc(&key, bits / CHAR_BIT);
|
||||
if (r != KNOT_EOK) {
|
||||
ERR2("failed to allocate memory");
|
||||
return knot_error_from_libdnssec(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = gnutls_rnd(GNUTLS_RND_KEY, key.data, key.size);
|
||||
if (r != 0) {
|
||||
ERR2("failed to generate secret the key");
|
||||
return knot_error_from_libdnssec(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
_cleanup_binary_ dnssec_binary_t key_b64 = { 0 };
|
||||
r = dnssec_binary_to_base64(&key, &key_b64);
|
||||
if (r != KNOT_EOK) {
|
||||
ERR2("failed to convert the key to Base64");
|
||||
return knot_error_from_libdnssec(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
print_tsig(alg, tsig_name, &key_b64);
|
||||
|
|
@ -1172,7 +1172,7 @@ static int create_and_print_ds(const knot_dname_t *zone_name,
|
|||
_cleanup_binary_ dnssec_binary_t rdata = { 0 };
|
||||
int r = dnssec_key_create_ds(key, digest, &rdata);
|
||||
if (r != KNOT_EOK) {
|
||||
return knot_error_from_libdnssec(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
return print_ds(zone_name, &rdata);
|
||||
|
|
@ -1210,7 +1210,7 @@ int keymgr_generate_dnskey(const knot_dname_t *dname, const knot_kasp_key_t *key
|
|||
int ret = dnssec_key_get_pubkey(dnskey, &pubkey);
|
||||
if (ret != KNOT_EOK) {
|
||||
free(name);
|
||||
return knot_error_from_libdnssec(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t *base64_output = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue