Commit 38e93ce5 authored by Jan Včelák's avatar Jan Včelák 🚀

logging: error string always in parentheses

parent cf46c22f
......@@ -84,7 +84,7 @@ static void cf_print_error(void *scanner, const char *msg)
filename = new_config->filename;
}
log_error("config error in '%s' (line %d token '%s'): %s",
log_error("config error, file '%s', line %d, token '%s' (%s)",
filename, lineno, text, msg);
_parser_res = KNOT_EPARSEFAIL;
......
......@@ -140,17 +140,17 @@ int proc_update_privileges(int uid, int gid)
if ((uid_t)uid != getuid() || (gid_t)gid != getgid()) {
if (setgroups(0, NULL) < 0) {
log_warning("failed to drop supplementary groups for "
"UID '%d': %s", getuid(), strerror(errno));
"UID '%d' (%s)", getuid(), strerror(errno));
}
# ifdef HAVE_INITGROUPS
struct passwd *pw;
if ((pw = getpwuid(uid)) == NULL) {
log_warning("failed to get passwd entry for UID '%d': %s",
log_warning("failed to get passwd entry for UID '%d' (%s)",
uid, strerror(errno));
} else {
if (initgroups(pw->pw_name, gid) < 0) {
log_warning("failed to set supplementary groups "
"for UID '%d': %s", uid, strerror(errno));
"for UID '%d' (%s)", uid, strerror(errno));
}
}
# endif /* HAVE_INITGROUPS */
......
......@@ -657,7 +657,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
assert(tsig_rcode != NULL);
if (query->tsig_rr == NULL) {
log_info("TSIG: key required, query REFUSED");
log_info("TSIG, key required, query REFUSED");
*rcode = KNOT_RCODE_REFUSED;
return KNOT_TSIG_EBADKEY;
}
......@@ -667,7 +667,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
*/
knot_tsig_algorithm_t alg = tsig_rdata_alg(query->tsig_rr);
if (knot_tsig_digest_length(alg) == 0) {
log_info("TSIG: unsupported algorithm, query NOTAUTH");
log_info("TSIG, unsupported algorithm, query NOTAUTH");
/*! \todo [TSIG] It is unclear from RFC if I
* should treat is as a bad key
* or some other error.
......@@ -710,7 +710,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
if (mac_len > digest_max_size) {
*rcode = KNOT_RCODE_FORMERR;
log_info("TSIG: MAC length %zu exceeds maximum size %zu",
log_info("TSIG, MAC length %zu exceeds maximum size %zu",
mac_len, digest_max_size);
return KNOT_EMALF;
} else {
......
......@@ -44,7 +44,7 @@ static int init_dnssec_structs(const zone_contents_t *zone,
zone->apex->owner,
nsec3_enabled, zone_keys);
if (result != KNOT_EOK) {
log_zone_error(zone->apex->owner, "DNSSEC, failed to load keys: %s",
log_zone_error(zone->apex->owner, "DNSSEC, failed to load keys (%s)",
knot_strerror(result));
knot_free_zone_keys(zone_keys);
return result;
......@@ -92,7 +92,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
result = knot_zone_create_nsec_chain(zone, out_ch,
&zone_keys, &policy);
if (result != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, could not create NSEC(3) chain: %s",
log_zone_error(zone_name, "DNSSEC, could not create NSEC(3) chain (%s)",
knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
......@@ -104,7 +104,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
result = knot_zone_sign(zone, &zone_keys, &policy, out_ch,
refresh_at);
if (result != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, error while signing: %s",
log_zone_error(zone_name, "DNSSEC, zone sign failed (%s)",
knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
......@@ -129,7 +129,7 @@ static int zone_sign(zone_contents_t *zone, const conf_zone_t *zone_config,
new_serial, out_ch);
if (result != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, not signing, cannot update "
"SOA record: %s", knot_strerror(result));
"SOA record (%s)", knot_strerror(result));
knot_free_zone_keys(&zone_keys);
return result;
}
......@@ -195,7 +195,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_changeset(zone, in_ch, out_ch,
&zone_keys, &policy);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, failed to sign changeset: %s",
log_zone_error(zone_name, "DNSSEC, failed to sign changeset (%s)",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......@@ -204,7 +204,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
// Create NSEC(3) chain
ret = knot_zone_create_nsec_chain(zone, out_ch, &zone_keys, &policy);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, failed to create NSEC(3) chain: %s",
log_zone_error(zone_name, "DNSSEC, failed to create NSEC(3) chain (%s)",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......@@ -214,7 +214,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_nsecs_in_changeset(&zone_keys, &policy,
out_ch);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, failed to sign changeset: %s",
log_zone_error(zone_name, "DNSSEC, failed to sign changeset (%s)",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......@@ -226,7 +226,7 @@ int knot_dnssec_sign_changeset(const zone_contents_t *zone,
ret = knot_zone_sign_update_soa(&soa, &rrsigs, &zone_keys, &policy,
new_serial, out_ch);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, failed to sign SOA RR: %s",
log_zone_error(zone_name, "DNSSEC, failed to sign SOA record (%s)",
knot_strerror(ret));
knot_free_zone_keys(&zone_keys);
return ret;
......
......@@ -210,27 +210,23 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
UNUSED(written);
assert(written == path_len);
dbg_dnssec_detail("loading key '%s'\n", path);
knot_key_params_t params = { 0 };
int ret = knot_load_key_params(path, &params);
free(path);
if (ret != KNOT_EOK) {
log_zone_warning(zone_name, "DNSSEC, failed to load key '%s': %s",
log_zone_warning(zone_name, "DNSSEC, failed to load key '%s' (%s)",
entry->d_name, knot_strerror(ret));
knot_free_key_params(&params);
continue;
}
if (!knot_dname_is_equal(zone_name, params.name)) {
dbg_dnssec_detail("skipping key, different zone name\n");
knot_free_key_params(&params);
continue;
}
if (knot_get_key_type(&params) != KNOT_KEY_DNSSEC) {
dbg_dnssec_detail("skipping key, different purpose\n");
knot_free_key_params(&params);
continue;
}
......@@ -243,13 +239,11 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
memset(key, '\0', sizeof(*key));
set_zone_key_flags(&params, key);
dbg_dnssec_detail("next key event %" PRIu32 "\n", key->next_event);
if (!knot_dnssec_algorithm_is_zonesign(params.algorithm,
nsec3_enabled)
) {
log_zone_notice(zone_name, "DNSSEC, ignoring key %d (%s): "
"incompatible algorithm",
log_zone_notice(zone_name, "DNSSEC, ignoring key %5d, "
"file %s (incompatible algorithm)",
params.keytag, entry->d_name);
knot_free_key_params(&params);
free(key);
......@@ -257,8 +251,8 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
}
if (knot_get_zone_key(keys, params.keytag) != NULL) {
log_zone_notice(zone_name, "DNSSEC, ignoring key %d (%s): "
"duplicate keytag",
log_zone_notice(zone_name, "DNSSEC, ignoring key %5d, "
"file %s (duplicate keytag)",
params.keytag, entry->d_name);
knot_free_key_params(&params);
free(key);
......@@ -268,7 +262,7 @@ int knot_load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
ret = knot_dnssec_key_from_params(&params, &key->dnssec_key);
if (ret != KNOT_EOK) {
log_zone_error(zone_name, "DNSSEC, failed to process "
"key %d (%s): %s",
"key %5d, file %s (%s)",
params.keytag, entry->d_name,
knot_strerror(ret));
knot_free_key_params(&params);
......
......@@ -114,7 +114,7 @@ static void setup_capabilities(void)
/* Apply. */
if (capng_apply(CAPNG_SELECT_BOTH) < 0) {
log_error("couldn't set process capabilities: %s",
log_error("couldn't set process capabilities (%s)",
strerror(errno));
}
} else {
......@@ -267,7 +267,7 @@ int main(int argc, char **argv)
int res = conf_open(config_fn);
conf_t *config = conf();
if (res != KNOT_EOK) {
log_fatal("couldn't load configuration '%s': %s",
log_fatal("couldn't load configuration file '%s' (%s)",
config_fn, knot_strerror(res));
return EXIT_FAILURE;
}
......@@ -281,7 +281,7 @@ int main(int argc, char **argv)
server_t server;
res = server_init(&server, conf_bg_threads(config));
if (res != KNOT_EOK) {
log_fatal("could not initialize server: %s", knot_strerror(res));
log_fatal("could not initialize server (%s)", knot_strerror(res));
conf_free(conf());
log_close();
return EXIT_FAILURE;
......@@ -349,7 +349,7 @@ int main(int argc, char **argv)
log_info("starting server");
res = server_start(&server, config->async_start);
if (res != KNOT_EOK) {
log_fatal("failed to start server: %s", knot_strerror(res));
log_fatal("failed to start server (%s)", knot_strerror(res));
server_deinit(&server);
rcu_unregister_thread();
pid_cleanup(pidfile);
......
......@@ -26,7 +26,7 @@
#include "libknot/descriptor.h"
/* Defines. */
#define MODULE_ERR(msg...) log_zone_error("Module 'dnstap': " msg)
#define MODULE_ERR(msg...) log_error("module 'dnstap', " msg)
static int log_message(int state, const knot_pkt_t *pkt, struct query_data *qdata, void *ctx)
{
......@@ -204,7 +204,7 @@ int dnstap_load(struct query_plan *plan, struct query_module *self)
return KNOT_EOK;
fail:
MODULE_ERR("init(\"%s\") failed - %s", self->param, knot_strerror(ret));
MODULE_ERR("init failed, params '%s' (%s)", self->param, knot_strerror(ret));
return ret;
}
......
......@@ -23,7 +23,7 @@
/* Defines. */
#define ARPA_ZONE_LABELS 2
#define MODULE_ERR(msg...) log_error("module 'synth_record': " msg)
#define MODULE_ERR(msg...) log_error("module 'synth_record', " msg)
/*! \brief Supported answer synthesis template types. */
enum synth_template_type {
......
......@@ -359,7 +359,7 @@ static int ixfrin_finalize(struct answer_data *adata)
/* Write changes to journal. */
ret = zone_changes_store(ixfr->zone, &ixfr->changesets);
if (ret != KNOT_EOK) {
IXFRIN_LOG(LOG_ERR, "Failed to apply changes to zone - %s",
IXFRIN_LOG(LOG_ERR, "failed to write changes to journal (%s)",
knot_strerror(ret));
updates_rollback(&ixfr->changesets);
update_free_zone(&new_contents);
......
......@@ -112,7 +112,8 @@ static int process_answer(knot_pkt_t *pkt, knot_process_t *ctx)
/* Verify incoming packet. */
int ret = tsig_verify_packet(&data->param->tsig_ctx, pkt);
if (ret != KNOT_EOK) {
ANSWER_LOG(LOG_WARNING, data, "Response", "%s", knot_strerror(ret));
ANSWER_LOG(LOG_WARNING, data, "response", "denied (%s)",
knot_strerror(ret));
return NS_PROC_FAIL;
}
......
......@@ -106,7 +106,7 @@ static int check_prereqs(struct request_data *request,
uint16_t rcode = KNOT_RCODE_NOERROR;
int ret = ddns_process_prereqs(request->query, update, &rcode);
if (ret != KNOT_EOK) {
UPDATE_LOG(LOG_WARNING, "prerequisites not met - %s\n",
UPDATE_LOG(LOG_WARNING, "prerequisites not met (%s)",
knot_strerror(ret));
assert(rcode != KNOT_RCODE_NOERROR);
knot_wire_set_rcode(request->resp->wire, rcode);
......@@ -123,7 +123,7 @@ static int process_single_update(struct request_data *request,
uint16_t rcode = KNOT_RCODE_NOERROR;
int ret = ddns_process_update(zone, request->query, update, &rcode);
if (ret != KNOT_EOK) {
UPDATE_LOG(LOG_WARNING, "failed to apply - %s\n",
UPDATE_LOG(LOG_WARNING, "failed to apply (%s)",
knot_strerror(ret));
assert(rcode != KNOT_RCODE_NOERROR);
knot_wire_set_rcode(request->resp->wire, rcode);
......@@ -301,8 +301,8 @@ static int process_requests(zone_t *zone, list_t *requests)
}
gettimeofday(&t_end, NULL);
log_zone_info(zone->name, "DDNS, serial %u -> %u", old_serial, new_serial);
log_zone_info(zone->name, "DDNS, update finished in %.02f seconds",
log_zone_info(zone->name, "DDNS, update finished, serial %u -> %u, "
"%.02f seconds", old_serial, new_serial,
time_diff(&t_start, &t_end) / 1000.0);
zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW);
......
......@@ -346,7 +346,7 @@ static int journal_open_file(journal_t *j)
goto open_file_error;
}
if (memcmp(magic, magic_req, MAGIC_LENGTH) != 0) {
log_warning("journal '%s': version too old, purging", j->path);
log_warning("journal '%s', version too old, purging", j->path);
close(j->fd);
j->fd = -1;
ret = journal_create_file(j->path, JOURNAL_NCOUNT);
......@@ -376,7 +376,7 @@ static int journal_open_file(journal_t *j)
goto open_file_error;
}
} else {
log_warning("journal '%s': CRC error, purging", j->path);
log_warning("journal '%s', CRC error, purging", j->path);
close(j->fd);
j->fd = -1;
ret = journal_create_file(j->path, JOURNAL_NCOUNT);
......@@ -460,10 +460,10 @@ static int journal_open_file(journal_t *j)
}
qhead_free = (jnode_flags(j, qhead_free) <= JOURNAL_FREE);
if ((j->qhead != j->qtail) && (!qtail_free || !qhead_free)) {
log_warning("journal '%s': recovering metadata after crash", j->path);
log_warning("journal '%s', recovering metadata after crash", j->path);
ret = journal_recover(j);
if (ret != KNOT_EOK) {
log_error("journal '%s': unrecoverable corruption: %s",
log_error("journal '%s', unrecoverable corruption (%s)",
j->path, knot_strerror(ret));
goto open_file_error;
}
......
......@@ -57,7 +57,7 @@ int net_unbound_socket(int type, const struct sockaddr_storage *ss)
/* Create socket. */
int socket = socket_create(ss->ss_family, type, 0);
if (socket < 0) {
log_error("could not create socket for '%s': %s",
log_error("could not create socket '%s' (%s)",
addr_str, knot_strerror(socket));
return socket;
}
......@@ -96,7 +96,7 @@ int net_bound_socket(int type, const struct sockaddr_storage *ss)
int ret = bind(socket, (const struct sockaddr *)ss, sockaddr_len(ss));
if (ret < 0) {
ret = knot_map_errno(EADDRINUSE, EINVAL, EACCES, ENOMEM);
log_error("cannot bind to address '%s': %s",
log_error("cannot bind address '%s' (%s)",
addr_str, knot_strerror(ret));
close(socket);
return ret;
......
......@@ -493,7 +493,7 @@ static int reconfigure_threads(const struct conf_t *conf, server_t *server)
ret = server_init_handler(server, IO_UDP, conf_udp_threads(conf),
&udp_master, &udp_master_destruct);
if (ret != KNOT_EOK) {
log_error("failed to create UDP threads: %s",
log_error("failed to create UDP threads (%s)",
knot_strerror(ret));
return ret;
}
......@@ -503,7 +503,7 @@ static int reconfigure_threads(const struct conf_t *conf, server_t *server)
ret = server_init_handler(server, IO_TCP, conf_tcp_threads(conf),
&tcp_master, &tcp_master_destruct);
if (ret != KNOT_EOK) {
log_error("failed to create TCP threads: %s",
log_error("failed to create TCP threads (%s)",
knot_strerror(ret));
return ret;
}
......
......@@ -1082,7 +1082,7 @@ int zone_contents_adjust_pointers(zone_contents_t *contents)
int ret = zone_contents_load_nsec3param(contents);
if (ret != KNOT_EOK) {
log_zone_error(contents->apex->owner,
"failed to load NSEC3 parameters: %s",
"failed to load NSEC3 parameters (%s)",
knot_strerror(ret));
return ret;
}
......@@ -1119,7 +1119,7 @@ int zone_contents_adjust_full(zone_contents_t *zone,
int result = zone_contents_load_nsec3param(zone);
if (result != KNOT_EOK) {
log_zone_error(zone->apex->owner,
"failed to load NSEC3 parameters: %s",
"failed to load NSEC3 parameters (%s)",
knot_strerror(result));
return result;
}
......
......@@ -260,7 +260,7 @@ static int event_reload(zone_t *zone)
"to fit the changes");
} else {
log_zone_error(zone->name, "failed to store changes into "
"journal: %s", knot_strerror(result));
"journal (%s)", knot_strerror(result));
}
goto fail;
}
......
......@@ -110,7 +110,7 @@ int zone_load_journal(zone_t *zone, zone_contents_t *contents)
/* Apply changesets. */
ret = apply_changesets_directly(contents, &chgs);
log_zone_info(zone->name, "serial %u -> %u: %s",
log_zone_info(zone->name, "serial %u -> %u (%s)",
serial, zone_contents_serial(contents),
knot_strerror(ret));
......@@ -179,7 +179,7 @@ int zone_load_post(zone_contents_t *contents, zone_t *zone, uint32_t *dnssec_ref
ret = KNOT_EOK;
} else if (ret != KNOT_EOK) {
log_zone_error(zone->name, "failed to calculate "
"differences from the zone file update: %s",
"differences from the zone file update (%s)",
knot_strerror(ret));
return ret;
}
......
......@@ -220,7 +220,7 @@ int zone_flush_journal(zone_t *zone)
log_zone_info(zone->name, "zone file updated, serial %u -> %u",
zone->zonefile_serial, serial_to);
} else {
log_zone_warning(zone->name, "failed to update zone file: %s",
log_zone_warning(zone->name, "failed to update zone file (%s)",
knot_strerror(ret));
return ret;
}
......@@ -228,7 +228,7 @@ int zone_flush_journal(zone_t *zone)
/* Update zone version. */
struct stat st;
if (stat(zone->conf->file, &st) < 0) {
log_zone_warning(zone->name, "failed to update zone file: %s",
log_zone_warning(zone->name, "failed to update zone file (%s)",
knot_strerror(KNOT_EACCES));
return KNOT_EACCES;
}
......
......@@ -257,13 +257,13 @@ zone_contents_t *zonefile_load(zloader_t *loader)
assert(zc);
int ret = zs_scanner_parse_file(loader->scanner, loader->source);
if (ret != 0) {
log_zone_error(zname, "zone file '%s' could not be loaded: %s",
log_zone_error(zname, "zone file '%s' could not be loaded (%s)",
loader->source, zs_strerror(ret));
goto fail;
}
if (zc->ret != KNOT_EOK) {
log_zone_error(zname, "zone file '%s' could not be loaded: %s",
log_zone_error(zname, "zone file '%s' could not be loaded (%s)",
loader->source, knot_strerror(zc->ret));
goto fail;
}
......@@ -288,7 +288,7 @@ zone_contents_t *zonefile_load(zloader_t *loader)
int kret = zone_contents_adjust_full(zc->z,
&first_nsec3_node, &last_nsec3_node);
if (kret != KNOT_EOK) {
log_zone_error(zname, "failed to finalize zone contents: %s",
log_zone_error(zname, "failed to finalize zone contents (%s)",
knot_strerror(kret));
goto fail;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment