From 5e5611901dd57be9e65cf0cfa2db46245bfe5979 Mon Sep 17 00:00:00 2001 From: Marco Bettini Date: Thu, 25 Aug 2022 16:26:50 +0000 Subject: [PATCH] doveadm: Replace i_() with e_() client-connection-http client-connection-tcp doveadm-auth-server doveadm-dict doveadm-fs doveadm-mailbox-list-iter doveadm-master doveadm-mutf7 doveadm-penalty doveadm-pw doveadm-replicator doveadm-stats doveadm-sys --- src/doveadm/client-connection-http.c | 43 ++++++++++++++--------- src/doveadm/client-connection-tcp.c | 43 ++++++++++++++--------- src/doveadm/client-connection.c | 2 +- src/doveadm/doveadm-auth-server.c | 15 ++++---- src/doveadm/doveadm-auth.c | 27 +++++++++------ src/doveadm/doveadm-compress.c | 2 +- src/doveadm/doveadm-dict.c | 42 +++++++++++++--------- src/doveadm/doveadm-dsync.c | 46 ++++++++++++++++--------- src/doveadm/doveadm-fs.c | 23 +++++++------ src/doveadm/doveadm-instance.c | 12 +++---- src/doveadm/doveadm-log.c | 4 +-- src/doveadm/doveadm-mailbox-list-iter.c | 6 ++-- src/doveadm/doveadm-master.c | 28 +++++++-------- src/doveadm/doveadm-mutf7.c | 6 ++-- src/doveadm/doveadm-penalty.c | 2 +- src/doveadm/doveadm-pw.c | 2 +- src/doveadm/doveadm-replicator.c | 14 ++++---- src/doveadm/doveadm-sis.c | 2 +- src/doveadm/doveadm-stats.c | 8 ++--- src/doveadm/doveadm.h | 2 +- 20 files changed, 193 insertions(+), 136 deletions(-) diff --git a/src/doveadm/client-connection-http.c b/src/doveadm/client-connection-http.c index 6093724b2e..06e93be598 100644 --- a/src/doveadm/client-connection-http.c +++ b/src/doveadm/client-connection-http.c @@ -237,9 +237,8 @@ doveadm_http_server_command_execute(struct client_request_http *req) if ((cctx->cmd->flags & CMD_FLAG_NO_PRINT) == 0) doveadm_print_deinit(); if (o_stream_finish(doveadm_print_ostream) < 0) { - i_info("Error writing output in command %s: %s", - req->cmd->name, - o_stream_get_error(req->output)); + e_info(cctx->event, "Error writing output in command %s: %s", + req->cmd->name, o_stream_get_error(req->output)); doveadm_exit_code = EX_TEMPFAIL; } @@ -251,11 +250,14 @@ doveadm_http_server_command_execute(struct client_request_http *req) o_stream_nsend_str(req->output,","); if (cctx->referral != NULL) { - i_error("Command requested referral: %s", cctx->referral); + e_error(cctx->event, + "Command requested referral: %s", cctx->referral); doveadm_http_server_json_error(req, "internalError"); } else if (doveadm_exit_code != 0) { - if (doveadm_exit_code == 0 || doveadm_exit_code == EX_TEMPFAIL) - i_error("Command %s failed", req->cmd->name); + if (doveadm_exit_code == 0 || doveadm_exit_code == EX_TEMPFAIL) { + e_error(cctx->event, + "Command %s failed", req->cmd->name); + } doveadm_http_server_json_error(req, "exitCode"); } else { doveadm_http_server_json_success(req, is); @@ -583,7 +585,8 @@ request_json_parse_param_istream(struct client_request_http *req) } if (v_input->stream_errno != 0) { - i_error("read(%s) failed: %s", + e_error(req->conn->conn.event, + "read(%s) failed: %s", i_stream_get_name(v_input), i_stream_get_error(v_input)); req->method_err = 400; @@ -740,7 +743,8 @@ doveadm_http_server_read_request_v1(struct client_request_http *req) if (req->input->stream_errno != 0) { http_server_request_fail_close(http_sreq, 400, "Client disconnected"); - i_info("read(%s) failed: %s", + e_info(req->conn->conn.event, + "read(%s) failed: %s", i_stream_get_name(req->input), i_stream_get_error(req->input)); return; @@ -906,7 +910,8 @@ static void doveadm_http_server_send_response(struct client_request_http *req) if (req->output != NULL) { if (o_stream_finish(req->output) == -1) { - i_info("error writing output: %s", + e_info(req->conn->conn.event, + "error writing output: %s", o_stream_get_error(req->output)); o_stream_destroy(&req->output); http_server_request_fail(http_sreq, @@ -953,7 +958,7 @@ doveadm_http_server_request_destroy(struct client_request_http *req) if (agent == NULL) agent = ""; url = http_url_create(http_req->target.url); - i_info("doveadm: %s %s %s \"%s %s " + e_info(conn->conn.event, "doveadm: %s %s %s \"%s %s " "HTTP/%d.%d\" %d %"PRIuUOFF_T" \"%s\" \"%s\"", net_ip2addr(&conn->conn.remote_ip), "-", "-", http_req->method, http_req->target.url->path, @@ -988,7 +993,8 @@ doveadm_http_server_auth_basic(struct client_request_http *req, char *value; if (*set->doveadm_password == '\0') { - i_error("Invalid authentication attempt to HTTP API: " + e_error(conn->conn.event, + "Invalid authentication attempt to HTTP API: " "Basic authentication scheme not enabled"); return FALSE; } @@ -1000,7 +1006,8 @@ doveadm_http_server_auth_basic(struct client_request_http *req, if (creds->data != NULL && strcmp(creds->data, str_c(b64_value)) == 0) return TRUE; - i_error("Invalid authentication attempt to HTTP API " + e_error(conn->conn.event, + "Invalid authentication attempt to HTTP API " "(using Basic authentication scheme)"); return FALSE; } @@ -1014,7 +1021,8 @@ doveadm_http_server_auth_api_key(struct client_request_http *req, string_t *b64_value; if (*set->doveadm_api_key == '\0') { - i_error("Invalid authentication attempt to HTTP API: " + e_error(conn->conn.event, + "Invalid authentication attempt to HTTP API: " "X-Dovecot-API authentication scheme not enabled"); return FALSE; } @@ -1025,7 +1033,8 @@ doveadm_http_server_auth_api_key(struct client_request_http *req, if (creds->data != NULL && strcmp(creds->data, str_c(b64_value)) == 0) return TRUE; - i_error("Invalid authentication attempt to HTTP API " + e_error(conn->conn.event, + "Invalid authentication attempt to HTTP API " "(using X-Dovecot-API authentication scheme)"); return FALSE; } @@ -1041,7 +1050,8 @@ doveadm_http_server_auth_verify(struct client_request_http *req, if (strcasecmp(creds->scheme, "X-Dovecot-API") == 0) return doveadm_http_server_auth_api_key(req, creds); - i_error("Unsupported authentication scheme to HTTP API: %s", + e_error(req->conn->conn.event, + "Unsupported authentication scheme to HTTP API: %s", str_sanitize(creds->scheme, 128)); return FALSE; } @@ -1059,7 +1069,8 @@ doveadm_http_server_authorize_request(struct client_request_http *req) *conn->conn.set->doveadm_password == '\0') { http_server_request_fail(http_sreq, 500, "Internal Server Error"); - i_error("No authentication defined in configuration. " + e_error(conn->conn.event, + "No authentication defined in configuration. " "Add API key or password"); return FALSE; } diff --git a/src/doveadm/client-connection-tcp.c b/src/doveadm/client-connection-tcp.c index 6b5b775a28..cfab1d6203 100644 --- a/src/doveadm/client-connection-tcp.c +++ b/src/doveadm/client-connection-tcp.c @@ -181,8 +181,9 @@ doveadm_cmd_server_post(struct client_connection_tcp *conn, t_strdup_printf("\n-%s\n", str)); } else { o_stream_nsend_str(conn->output, "\n-\n"); - i_error("BUG: Command '%s' returned unknown error code %d", - cctx->cmd->name, doveadm_exit_code); + e_error(cctx->event, + "BUG: Command returned unknown error code %d", + doveadm_exit_code); } } @@ -206,7 +207,8 @@ static int doveadm_cmd_handle(struct client_connection_tcp *conn, const struct doveadm_cmd_ver2 *cmd_ver2; if ((cmd_ver2 = doveadm_cmdline_find_with_args(cmd_name, &argc, &argv)) == NULL) { - i_error("doveadm: Client sent unknown command: %s", cmd_name); + e_error(cctx->event, + "doveadm: Client sent unknown command: %s", cmd_name); return -1; } cctx->cmd = cmd_ver2; @@ -267,7 +269,7 @@ static bool client_handle_command_ctx(struct client_connection_tcp *conn, unsigned int argc = str_array_length(args); if (argc < 3) { - i_error("doveadm client: No command given"); + e_error(cctx->event, "doveadm client: No command given"); return FALSE; } doveadm_exit_code = 0; @@ -291,7 +293,8 @@ static bool client_handle_command_ctx(struct client_connection_tcp *conn, args++; argc--; break; default: - i_error("doveadm client: Unknown flag: %c", *flags); + e_error(cctx->event, + "doveadm client: Unknown flag: %c", *flags); return FALSE; } } @@ -304,7 +307,8 @@ static bool client_handle_command_ctx(struct client_connection_tcp *conn, } if (!doveadm_client_is_allowed_command(conn->conn.set, cmd_name)) { - i_error("doveadm client isn't allowed to use command: %s", + e_error(cctx->event, + "doveadm client isn't allowed to use command: %s", cmd_name); return FALSE; } @@ -357,8 +361,8 @@ client_connection_tcp_authenticate(struct client_connection_tcp *conn) } if (*set->doveadm_password == '\0') { - i_error("doveadm_password not set, " - "remote authentication disabled"); + e_error(conn->conn.event, + "doveadm_password not set, remote authentication disabled"); return -1; } @@ -373,13 +377,16 @@ client_connection_tcp_authenticate(struct client_connection_tcp *conn) /* FIXME: some day we should probably let auth process do this and support all kinds of authentication */ if (!str_begins(line, "PLAIN\t", &args)) { - i_error("doveadm client attempted non-PLAIN authentication: %s", line); + e_error(conn->conn.event, + "doveadm client attempted non-PLAIN authentication: %s", + line); return -1; } plain = t_buffer_create(128); if (base64_decode(args, strlen(args), plain) < 0) { - i_error("doveadm client sent invalid base64 auth PLAIN data"); + e_error(conn->conn.event, + "doveadm client sent invalid base64 auth PLAIN data"); return -1; } data = plain->data; @@ -387,14 +394,16 @@ client_connection_tcp_authenticate(struct client_connection_tcp *conn) if (size < 10 || data[0] != '\0' || memcmp(data+1, "doveadm", 7) != 0 || data[8] != '\0') { - i_error("doveadm client didn't authenticate as 'doveadm'"); + e_error(conn->conn.event + , "doveadm client didn't authenticate as 'doveadm'"); return -1; } pass = t_strndup(data + 9, size - 9); if (strlen(pass) != strlen(set->doveadm_password) || !mem_equals_timing_safe(pass, set->doveadm_password, strlen(pass))) { - i_error("doveadm client authenticated with wrong password"); + e_error(conn->conn.event, + "doveadm client authenticated with wrong password"); return -1; } return 1; @@ -410,7 +419,8 @@ static void client_log_disconnect_error(struct client_connection_tcp *conn) error = conn->input->stream_errno == 0 ? "EOF" : strerror(conn->input->stream_errno); } - i_error("doveadm client disconnected before handshake: %s", error); + e_error(conn->conn.event, + "doveadm client disconnected before handshake: %s", error); } static void @@ -431,7 +441,8 @@ client_connection_tcp_input(struct client_connection_tcp *conn) if (!version_string_verify_full(line, "doveadm-server", DOVEADM_SERVER_PROTOCOL_VERSION_MAJOR, &conn->minor_version)) { - i_error("doveadm client not compatible with this server " + e_error(conn->conn.event, + "doveadm client not compatible with this server " "(mixed old and new binaries?)"); client_connection_tcp_destroy(&conn); return; @@ -495,11 +506,11 @@ client_connection_tcp_init_ssl(struct client_connection_tcp *conn) if (master_service_ssl_init(master_service, &conn->input, &conn->output, &conn->ssl_iostream, &error) < 0) { - i_error("SSL init failed: %s", error); + e_error(conn->conn.event, "SSL init failed: %s", error); return -1; } if (ssl_iostream_handshake(conn->ssl_iostream) < 0) { - i_error("SSL handshake failed: %s", + e_error(conn->conn.event, "SSL handshake failed: %s", ssl_iostream_get_last_error(conn->ssl_iostream)); return -1; } diff --git a/src/doveadm/client-connection.c b/src/doveadm/client-connection.c index b76a8cd825..cee96725fb 100644 --- a/src/doveadm/client-connection.c +++ b/src/doveadm/client-connection.c @@ -49,7 +49,7 @@ static int client_connection_read_settings(struct client_connection *conn) if (master_service_settings_read(master_service, &input, &output, &error) < 0) { - i_error("Error reading configuration: %s", error); + e_error(conn->event, "Error reading configuration: %s", error); return -1; } set = master_service_settings_get_others(master_service)[0]; diff --git a/src/doveadm/doveadm-auth-server.c b/src/doveadm/doveadm-auth-server.c index 839d72b574..5188225853 100644 --- a/src/doveadm/doveadm-auth-server.c +++ b/src/doveadm/doveadm-auth-server.c @@ -161,7 +161,8 @@ static void auth_user_info_parse(struct auth_user_info *info, const char *arg) } static void -cmd_user_list(struct auth_master_connection *conn, +cmd_user_list(struct doveadm_cmd_context *cctx, + struct auth_master_connection *conn, const struct authtest_input *input, char *const *users) { @@ -195,7 +196,7 @@ cmd_user_list(struct auth_master_connection *conn, } } if (auth_master_user_list_deinit(&ctx) < 0) { - i_error("user listing failed"); + e_error(cctx->event, "user listing failed"); doveadm_exit_code = EX_DATAERR; } @@ -217,7 +218,7 @@ static void cmd_auth_cache_flush(struct doveadm_cmd_context *cctx) conn = doveadm_get_auth_master_conn(master_socket_path); if (auth_master_cache_flush(conn, users, &count) < 0) { - i_error("Cache flush failed"); + e_error(cctx->event, "Cache flush failed"); doveadm_exit_code = EX_TEMPFAIL; } else { doveadm_print_init("formatted"); @@ -388,17 +389,17 @@ static void cmd_user_ver2(struct doveadm_cmd_context *cctx) if (!doveadm_cmd_param_array(cctx, "user-mask", &optval)) { doveadm_exit_code = EX_USAGE; - i_error("No user(s) specified"); + e_error(cctx->event, "No user(s) specified"); return; } if (expand_field != NULL && userdb_only) { - i_error("-e can't be used with -u"); + e_error(cctx->event, "-e can't be used with -u"); doveadm_exit_code = EX_USAGE; return; } if (expand_field != NULL && show_field != NULL) { - i_error("-e can't be used with -f"); + e_error(cctx->event, "-e can't be used with -f"); doveadm_exit_code = EX_USAGE; return; } @@ -416,7 +417,7 @@ static void cmd_user_ver2(struct doveadm_cmd_context *cctx) } if (have_wildcards) { - cmd_user_list(conn, &input, (char*const*)optval); + cmd_user_list(cctx, conn, &input, (char*const*)optval); auth_master_deinit(&conn); return; } diff --git a/src/doveadm/doveadm-auth.c b/src/doveadm/doveadm-auth.c index 5604fc4ce2..6abc9fb34f 100644 --- a/src/doveadm/doveadm-auth.c +++ b/src/doveadm/doveadm-auth.c @@ -74,7 +74,8 @@ doveadm_get_auth_master_conn(const char *auth_socket_path) static int cmd_user_input(struct auth_master_connection *conn, const struct authtest_input *input, - const char *show_field, bool userdb) + const char *show_field, bool userdb, + struct event *event) { const char *lookup_name = userdb ? "userdb lookup" : "passdb lookup"; pool_t pool; @@ -92,9 +93,11 @@ cmd_user_input(struct auth_master_connection *conn, } if (ret < 0) { if (fields[0] == NULL) - i_error("%s failed for %s", lookup_name, input->username); + e_error(event, + "%s failed for %s", lookup_name, input->username); else { - i_error("%s failed for %s: %s", lookup_name, + e_error(event, + "%s failed for %s: %s", lookup_name, input->username, fields[0]); } ret = -1; @@ -339,7 +342,7 @@ static void cmd_auth_cache_flush(struct doveadm_cmd_context *cctx) conn = doveadm_get_auth_master_conn(master_socket_path); if (auth_master_cache_flush(conn, users, &count) < 0) { - i_error("Cache flush failed"); + e_error(cctx->event, "Cache flush failed"); doveadm_exit_code = EX_TEMPFAIL; } else { printf("%u cache entries flushed\n", count); @@ -498,7 +501,7 @@ static void cmd_auth_lookup(struct doveadm_cmd_context *cctx) else putchar('\n'); - ret = cmd_user_input(conn, &input, show_field, FALSE); + ret = cmd_user_input(conn, &input, show_field, FALSE, cctx->event); switch (ret) { case -1: doveadm_exit_code = EX_TEMPFAIL; @@ -562,7 +565,8 @@ cmd_user_mail_print_fields(const struct authtest_input *input, static int cmd_user_mail_input(struct mail_storage_service_ctx *storage_service, const struct authtest_input *input, - const char *show_field, const char *expand_field) + const char *show_field, const char *expand_field, + struct event *event) { struct mail_storage_service_input service_input; struct mail_storage_service_user *service_user; @@ -605,7 +609,7 @@ cmd_user_mail_input(struct mail_storage_service_ctx *storage_service, mail_user_var_expand_table(user), mail_user_var_expand_func_table, user, &error) <= 0) { - i_error("Failed to expand %s: %s", expand_field, error); + e_error(event, "Failed to expand %s: %s", expand_field, error); } else { printf("%s\n", str_c(str)); } @@ -641,12 +645,12 @@ static void cmd_user(struct doveadm_cmd_context *cctx) auth_cmd_help(cctx); if (expand_field != NULL && userdb_only) { - i_error("-e can't be used with -u"); + e_error(cctx->event, "-e can't be used with -u"); doveadm_exit_code = EX_USAGE; return; } if (expand_field != NULL && show_field != NULL) { - i_error("-e can't be used with -f"); + e_error(cctx->event, "-e can't be used with -f"); doveadm_exit_code = EX_USAGE; return; } @@ -693,8 +697,9 @@ static void cmd_user(struct doveadm_cmd_context *cctx) putchar('\n'); ret = !userdb_only ? - cmd_user_mail_input(storage_service, &input, show_field, expand_field) : - cmd_user_input(conn, &input, show_field, TRUE); + cmd_user_mail_input(storage_service, &input, show_field, + expand_field, cctx->event) : + cmd_user_input(conn, &input, show_field, TRUE, cctx->event); switch (ret) { case -1: doveadm_exit_code = EX_TEMPFAIL; diff --git a/src/doveadm/doveadm-compress.c b/src/doveadm/doveadm-compress.c index 6d114fa77c..15df39bc79 100644 --- a/src/doveadm/doveadm-compress.c +++ b/src/doveadm/doveadm-compress.c @@ -251,7 +251,7 @@ static void cmd_compress_connect(struct doveadm_cmd_context *cctx) if ((fd = net_connect_ip(&ips[0], port, NULL)) == -1) i_fatal("connect(%s, %u) failed: %m", host, port); - i_info("Connected to %s port %u.", net_ip2addr(&ips[0]), port); + e_info(cctx->event, "Connected to %s port %u.", net_ip2addr(&ips[0]), port); i_zero(&client); client.event = event_create(cctx->event); diff --git a/src/doveadm/doveadm-dict.c b/src/doveadm/doveadm-dict.c index 0ff3531ac7..ff50e9a82f 100644 --- a/src/doveadm/doveadm-dict.c +++ b/src/doveadm/doveadm-dict.c @@ -29,7 +29,7 @@ cmd_dict_init_full(struct doveadm_cmd_context *cctx, dopset_r->username = username; if (!doveadm_cmd_param_str(cctx, "dict-uri", &dict_uri)) { - i_error("dictionary URI must be specified"); + e_error(cctx->event, "dictionary URI must be specified"); doveadm_exit_code = EX_USAGE; return -1; } @@ -40,14 +40,16 @@ cmd_dict_init_full(struct doveadm_cmd_context *cctx, if (!str_begins_with(key, DICT_PATH_PRIVATE) && !str_begins_with(key, DICT_PATH_SHARED)) { - i_error("Key must begin with '"DICT_PATH_PRIVATE - "' or '"DICT_PATH_SHARED"': %s", key); + e_error(cctx->event, "Key must begin with " + "'"DICT_PATH_PRIVATE"' or '"DICT_PATH_SHARED"': %s", + key); doveadm_exit_code = EX_USAGE; return -1; } if (username[0] == '\0' && str_begins_with(key, DICT_PATH_PRIVATE)) { - i_error("-u must be specified for "DICT_PATH_PRIVATE" keys"); + e_error(cctx->event, + "-u must be specified for "DICT_PATH_PRIVATE" keys"); doveadm_exit_code = EX_USAGE; return -1; } @@ -56,7 +58,8 @@ cmd_dict_init_full(struct doveadm_cmd_context *cctx, i_zero(&dict_set); dict_set.base_dir = doveadm_settings->base_dir; if (dict_init(dict_uri, &dict_set, &dict, &error) < 0) { - i_error("dict_init(%s) failed: %s", dict_uri, error); + e_error(cctx->event, + "dict_init(%s) failed: %s", dict_uri, error); doveadm_exit_code = EX_TEMPFAIL; return -1; } @@ -121,7 +124,7 @@ static void cmd_dict_get(struct doveadm_cmd_context *cctx) struct dict_op_settings set; if (!doveadm_cmd_param_str(cctx, "key", &key)) { - i_error("dict-get: Missing key"); + e_error(cctx->event, "dict-get: Missing key"); doveadm_exit_code = EX_USAGE; return; } @@ -139,10 +142,11 @@ static void cmd_dict_get(struct doveadm_cmd_context *cctx) while (ctx.ret == -2) dict_wait(dict); if (ctx.ret < 0) { - i_error("dict_lookup(%s) failed: %s", key, ctx.error); + e_error(cctx->event, + "dict_lookup(%s) failed: %s", key, ctx.error); doveadm_exit_code = EX_TEMPFAIL; } else if (ctx.ret == 0) { - i_error("%s doesn't exist", key); + e_error(cctx->event, "%s doesn't exist", key); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } else { unsigned int i, values_count = str_array_length(ctx.values); @@ -165,7 +169,7 @@ static void cmd_dict_set(struct doveadm_cmd_context *cctx) if (!doveadm_cmd_param_str(cctx, "key", &key) || !doveadm_cmd_param_str(cctx, "value", &value)) { - i_error("dict set: Missing parameters"); + e_error(cctx->event, "dict set: Missing parameters"); doveadm_exit_code = EX_USAGE; return; } @@ -175,7 +179,8 @@ static void cmd_dict_set(struct doveadm_cmd_context *cctx) dict_set(trans, key, value); if (dict_transaction_commit(&trans, &error) <= 0) { - i_error("dict_transaction_commit() failed: %s", error); + e_error(cctx->event, + "dict_transaction_commit() failed: %s", error); doveadm_exit_code = EX_TEMPFAIL; } dict_deinit(&dict); @@ -189,7 +194,7 @@ static void cmd_dict_unset(struct doveadm_cmd_context *cctx) const char *key; if (!doveadm_cmd_param_str(cctx, "key", &key)) { - i_error("dict unset: Missing key"); + e_error(cctx->event, "dict unset: Missing key"); doveadm_exit_code = EX_USAGE; return; } @@ -199,7 +204,8 @@ static void cmd_dict_unset(struct doveadm_cmd_context *cctx) dict_unset(trans, key); if (dict_transaction_commit(&trans, &error) <= 0) { - i_error("dict_transaction_commit() failed: %s", error); + e_error(cctx->event, + "dict_transaction_commit() failed: %s", error); doveadm_exit_code = EX_TEMPFAIL; } dict_deinit(&dict); @@ -216,7 +222,7 @@ static void cmd_dict_inc(struct doveadm_cmd_context *cctx) if (!doveadm_cmd_param_str(cctx, "key", &key) || !doveadm_cmd_param_int64(cctx, "difference", &diff)) { - i_error("dict-inc: Missing parameters"); + e_error(cctx->event, "dict-inc: Missing parameters"); doveadm_exit_code = EX_USAGE; return; } @@ -227,10 +233,11 @@ static void cmd_dict_inc(struct doveadm_cmd_context *cctx) dict_atomic_inc(trans, key, diff); ret = dict_transaction_commit(&trans, &error); if (ret < 0) { - i_error("dict_transaction_commit() failed: %s", error); + e_error(cctx->event, + "dict_transaction_commit() failed: %s", error); doveadm_exit_code = EX_TEMPFAIL; } else if (ret == 0) { - i_error("%s doesn't exist", key); + e_error(cctx->event, "%s doesn't exist", key); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } dict_deinit(&dict); @@ -246,7 +253,7 @@ static void cmd_dict_iter(struct doveadm_cmd_context *cctx) struct dict_op_settings set; if (!doveadm_cmd_param_str(cctx, "prefix", &prefix)) { - i_error("dict-iter: Missing prefix"); + e_error(cctx->event, "dict-iter: Missing prefix"); doveadm_exit_code = EX_USAGE; return; } @@ -274,7 +281,8 @@ static void cmd_dict_iter(struct doveadm_cmd_context *cctx) } } if (dict_iterate_deinit(&iter, &error) < 0) { - i_error("dict_iterate_deinit(%s) failed: %s", prefix, error); + e_error(cctx->event, + "dict_iterate_deinit(%s) failed: %s", prefix, error); doveadm_exit_code = EX_TEMPFAIL; } dict_deinit(&dict); diff --git a/src/doveadm/doveadm-dsync.c b/src/doveadm/doveadm-dsync.c index 9ed60241c2..8a739c6b7c 100644 --- a/src/doveadm/doveadm-dsync.c +++ b/src/doveadm/doveadm-dsync.c @@ -405,7 +405,8 @@ get_dsync_verify_namespace(struct dsync_cmd_context *ctx, array_idx_elem(&ctx->namespace_prefixes, 0); ns = mail_namespace_find(user->namespaces, prefix); if (ns == NULL) { - i_error("Namespace not found: '%s'", prefix); + e_error(ctx->ctx.cctx->event, + "Namespace not found: '%s'", prefix); ctx->ctx.exit_code = DOVEADM_EX_NOTFOUND; return -1; } @@ -463,7 +464,8 @@ cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user, ctx->ctx.cur_service_user, &user2, &error); if (ret < 0) { - i_error("Failed to initialize user: %s", error); + e_error(ctx->ctx.cctx->event, + "Failed to initialize user: %s", error); ctx->ctx.exit_code = ret == -1 ? EX_TEMPFAIL : EX_CONFIG; return -1; } @@ -473,7 +475,8 @@ cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user, get_dsync_verify_namespace(ctx, user2, &ns2) < 0) return -1; if (mail_namespace_get_sep(ns) != mail_namespace_get_sep(ns2)) { - i_error("Mail locations must use the same hierarchy separator " + e_error(ctx->ctx.cctx->event, + "Mail locations must use the same hierarchy separator " "(specify namespace prefix=\"%s\" " "{ separator } explicitly)", ns->prefix); ctx->ctx.exit_code = EX_CONFIG; @@ -482,7 +485,8 @@ cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user, } if (paths_are_equal(ns, ns2, MAILBOX_LIST_PATH_TYPE_MAILBOX) && paths_are_equal(ns, ns2, MAILBOX_LIST_PATH_TYPE_INDEX)) { - i_error("Both source and destination mail_location " + e_error(ctx->ctx.cctx->event, + "Both source and destination mail_location " "points to same directory: %s (namespace " "prefix=\"%s\" { location } is set explicitly?)", mailbox_list_get_root_forced(user->namespaces->list, @@ -540,9 +544,11 @@ static void cmd_dsync_wait_remote(struct dsync_cmd_context *ctx) mail_storage_service_io_activate_user(ctx->ctx.cur_service_user); if (!ctx->exited) { - i_error("Remote command process isn't dying, killing it"); + e_error(ctx->ctx.cctx->event, + "Remote command process isn't dying, killing it"); if (kill(ctx->remote_pid, SIGKILL) < 0 && errno != ESRCH) { - i_error("kill(%ld, SIGKILL) failed: %m", + e_error(ctx->ctx.cctx->event, + "kill(%ld, SIGKILL) failed: %m", (long)ctx->remote_pid); } } @@ -639,7 +645,8 @@ dsync_replicator_notify(struct dsync_cmd_context *ctx, /* replicator not running on this server. ignore. */ return; } - i_error("net_connect_unix(%s) failed: %m", path); + e_error(ctx->ctx.cctx->event, + "net_connect_unix(%s) failed: %m", path); return; } fd_set_nonblock(fd, FALSE); @@ -653,12 +660,16 @@ dsync_replicator_notify(struct dsync_cmd_context *ctx, str_append_c(str, '\t'); str_append_tabescaped(str, state_str); str_append_c(str, '\n'); - if (write_full(fd, str_data(str), str_len(str)) < 0) - i_error("write(%s) failed: %m", path); + if (write_full(fd, str_data(str), str_len(str)) < 0) { + e_error(ctx->ctx.cctx->event, + "write(%s) failed: %m", path); + } /* we only wanted to notify replicator. we don't care enough about the answer to wait for it. */ - if (close(fd) < 0) - i_error("close(%s) failed: %m", path); + if (close(fd) < 0) { + e_error(ctx->ctx.cctx->event, + "close(%s) failed: %m", path); + } } static void dsync_errors_finish(struct dsync_cmd_context *ctx) @@ -726,7 +737,7 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) set.state = ctx->state_input; set.mailbox_alt_char = doveadm_settings->dsync_alt_char[0]; if (*doveadm_settings->dsync_hashed_headers == '\0') { - i_error("dsync_hashed_headers must not be empty"); + e_error(cctx->event, "dsync_hashed_headers must not be empty"); ctx->ctx.exit_code = EX_USAGE; return -1; } @@ -742,7 +753,7 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) array_foreach(&ctx->namespace_prefixes, strp) { ns = mail_namespace_find(user->namespaces, *strp); if (ns == NULL) { - i_error("Namespace not found: '%s'", *strp); + e_error(cctx->event, "Namespace not found: '%s'", *strp); ctx->ctx.exit_code = EX_USAGE; return -1; } @@ -818,7 +829,8 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user) /* don't log a warning when running via doveadm server (e.g. called by replicator) */ if (cctx->conn_type == DOVEADM_CONNECTION_TYPE_CLI) { - i_warning("Mailbox changes caused a desync. " + e_warning(cctx->event, + "Mailbox changes caused a desync. " "You may want to run dsync again: %s", changes_during_sync == NULL || (remote_only_changes && changes_during_sync2 != NULL) ? @@ -1122,8 +1134,10 @@ static void cmd_dsync_init(struct doveadm_mail_cmd_context *_ctx) container_of(_ctx, struct dsync_cmd_context, ctx); if (ctx->default_replica_location) { - if (*ctx->destination != NULL) - i_error("Don't give mail location with -d parameter"); + if (*ctx->destination != NULL) { + e_error(ctx->ctx.cctx->event, + "Don't give mail location with -d parameter"); + } } else { if (*ctx->destination == NULL) doveadm_mail_help_name(_ctx->cmd->name); diff --git a/src/doveadm/doveadm-fs.c b/src/doveadm/doveadm-fs.c index c156718171..95795b144a 100644 --- a/src/doveadm/doveadm-fs.c +++ b/src/doveadm/doveadm-fs.c @@ -70,11 +70,11 @@ static void cmd_fs_get(struct doveadm_cmd_context *cctx) doveadm_print_stream("", 0); i_assert(ret == -1); if (input->stream_errno == ENOENT) { - i_error("%s doesn't exist: %s", fs_file_path(file), + e_error(cctx->event, "%s doesn't exist: %s", fs_file_path(file), i_stream_get_error(input)); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } else if (input->stream_errno != 0) { - i_error("read(%s) failed: %s", fs_file_path(file), + e_error(cctx->event, "read(%s) failed: %s", fs_file_path(file), i_stream_get_error(input)); doveadm_exit_code = EX_TEMPFAIL; } @@ -124,7 +124,7 @@ static void cmd_fs_put(struct doveadm_cmd_context *cctx) o_stream_nsend_istream(output, input); i_stream_destroy(&input); if (fs_write_stream_finish(file, &output) < 0) { - i_error("fs_write_stream_finish() failed: %s", + e_error(cctx->event, "fs_write_stream_finish() failed: %s", fs_file_last_error(file)); doveadm_exit_code = EX_TEMPFAIL; } @@ -147,11 +147,11 @@ static void cmd_fs_copy(struct doveadm_cmd_context *cctx) dest_file = fs_file_init(fs, dest_path, FS_OPEN_MODE_REPLACE); if (fs_copy(src_file, dest_file) == 0) ; else if (errno == ENOENT) { - i_error("%s doesn't exist: %s", src_path, + e_error(cctx->event, "%s doesn't exist: %s", src_path, fs_file_last_error(dest_file)); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } else { - i_error("fs_copy(%s, %s) failed: %s", + e_error(cctx->event, "fs_copy(%s, %s) failed: %s", src_path, dest_path, fs_file_last_error(dest_file)); doveadm_exit_code = EX_TEMPFAIL; } @@ -182,11 +182,12 @@ static void cmd_fs_stat(struct doveadm_cmd_context *cctx) doveadm_print(fs_file_path(file)); doveadm_print(dec2str(st.st_size)); } else if (errno == ENOENT) { - i_error("%s doesn't exist: %s", fs_file_path(file), + e_error(cctx->event, + "%s doesn't exist: %s", fs_file_path(file), fs_file_last_error(file)); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } else { - i_error("fs_stat(%s) failed: %s", + e_error(cctx->event, "fs_stat(%s) failed: %s", fs_file_path(file), fs_file_last_error(file)); doveadm_exit_code = EX_TEMPFAIL; } @@ -219,11 +220,12 @@ static void cmd_fs_metadata(struct doveadm_cmd_context *cctx) doveadm_print(m->value); } } else if (errno == ENOENT) { - i_error("%s doesn't exist: %s", fs_file_path(file), + e_error(cctx->event, + "%s doesn't exist: %s", fs_file_path(file), fs_file_last_error(file)); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } else { - i_error("fs_stat(%s) failed: %s", + e_error(cctx->event, "fs_stat(%s) failed: %s", fs_file_path(file), fs_file_last_error(file)); doveadm_exit_code = EX_TEMPFAIL; } @@ -489,7 +491,8 @@ static void cmd_fs_iter_full(struct doveadm_cmd_context *cctx, doveadm_print(fname); } if (fs_iter_deinit(&iter, &error) < 0) { - i_error("fs_iter_deinit(%s) failed: %s", path, error); + e_error(cctx->event, + "fs_iter_deinit(%s) failed: %s", path, error); doveadm_exit_code = EX_TEMPFAIL; } fs_deinit(&fs); diff --git a/src/doveadm/doveadm-instance.c b/src/doveadm/doveadm-instance.c index cd3d55e07d..63b9b6a820 100644 --- a/src/doveadm/doveadm-instance.c +++ b/src/doveadm/doveadm-instance.c @@ -15,7 +15,7 @@ extern struct doveadm_cmd_ver2 doveadm_cmd_instance[]; static void instance_cmd_help(const struct doveadm_cmd_ver2 *cmd) ATTR_NORETURN; -static bool pid_file_read(const char *path) +static bool pid_file_read(const char *path, struct event *event) { char buf[32]; int fd; @@ -26,13 +26,13 @@ static bool pid_file_read(const char *path) fd = open(path, O_RDONLY); if (fd == -1) { if (errno != ENOENT) - i_error("open(%s) failed: %m", path); + e_error(event, "open(%s) failed: %m", path); return FALSE; } ret = read(fd, buf, sizeof(buf)); if (ret < 0) - i_error("read(%s) failed: %m", path); + e_error(event, "read(%s) failed: %m", path); else if (ret > 0 && buf[ret-1] == '\n') { buf[ret-1] = '\0'; if (str_to_pid(buf, &pid) == 0) { @@ -81,7 +81,7 @@ static void cmd_instance_list(struct doveadm_cmd_context *cctx) doveadm_print(inst->name); doveadm_print(unixdate2str(inst->last_used)); pidfile_path = t_strconcat(inst->base_dir, "/master.pid", NULL); - if (pid_file_read(pidfile_path)) + if (pid_file_read(pidfile_path, cctx->event)) doveadm_print("yes"); else doveadm_print("no"); @@ -106,10 +106,10 @@ static void cmd_instance_remove(struct doveadm_cmd_context *cctx) inst = master_instance_list_find_by_name(list, name); base_dir = inst != NULL ? inst->base_dir : name; if ((ret = master_instance_list_remove(list, base_dir)) < 0) { - i_error("Failed to remove instance"); + e_error(cctx->event, "Failed to remove instance"); doveadm_exit_code = EX_TEMPFAIL; } else if (ret == 0) { - i_error("Instance already didn't exist"); + e_error(cctx->event, "Instance already didn't exist"); doveadm_exit_code = DOVEADM_EX_NOTFOUND; } master_instance_list_deinit(&list); diff --git a/src/doveadm/doveadm-log.c b/src/doveadm/doveadm-log.c index cc89b9103f..6807389588 100644 --- a/src/doveadm/doveadm-log.c +++ b/src/doveadm/doveadm-log.c @@ -47,9 +47,9 @@ cmd_log_test(struct doveadm_cmd_context *cctx ATTR_UNUSED) } } -static void cmd_log_reopen(struct doveadm_cmd_context *cctx ATTR_UNUSED) +static void cmd_log_reopen(struct doveadm_cmd_context *cctx) { - doveadm_master_send_signal(SIGUSR1); + doveadm_master_send_signal(SIGUSR1, cctx->event); } struct log_find_file { diff --git a/src/doveadm/doveadm-mailbox-list-iter.c b/src/doveadm/doveadm-mailbox-list-iter.c index e140ccf1d1..f3dc754e89 100644 --- a/src/doveadm/doveadm-mailbox-list-iter.c +++ b/src/doveadm/doveadm-mailbox-list-iter.c @@ -151,8 +151,10 @@ int doveadm_mailbox_list_iter_deinit(struct doveadm_mailbox_list_iter **_iter) if (iter->iter == NULL) ret = 0; else if ((ret = mailbox_list_iter_deinit(&iter->iter)) < 0) { - i_error("Listing mailboxes failed: %s", - mailbox_list_get_last_internal_error(iter->user->namespaces->list, &error)); + const char *errtxt = mailbox_list_get_last_internal_error( + iter->user->namespaces->list, &error); + e_error(iter->ctx->cctx->event, + "Listing mailboxes failed: %s", errtxt); doveadm_mail_failed_error(iter->ctx, error); } array_free(&iter->patterns); diff --git a/src/doveadm/doveadm-master.c b/src/doveadm/doveadm-master.c index 51cdd8ede7..221c6bb77f 100644 --- a/src/doveadm/doveadm-master.c +++ b/src/doveadm/doveadm-master.c @@ -17,7 +17,7 @@ #define MASTER_PID_FILE_NAME "master.pid" -static bool pid_file_read(const char *path, pid_t *pid_r) +static bool pid_file_read(const char *path, pid_t *pid_r, struct event *event) { char buf[32]; int fd; @@ -34,7 +34,7 @@ static bool pid_file_read(const char *path, pid_t *pid_r) ret = read(fd, buf, sizeof(buf)-1); if (ret <= 0) { if (ret == 0) - i_error("Empty PID file in %s", path); + e_error(event, "Empty PID file in %s", path); else i_fatal("read(%s) failed: %m", path); found = FALSE; @@ -53,7 +53,7 @@ static bool pid_file_read(const char *path, pid_t *pid_r) return found; } -void doveadm_master_send_signal(int signo) +void doveadm_master_send_signal(int signo, struct event *event) { const char *pidfile_path; unsigned int i; @@ -62,7 +62,7 @@ void doveadm_master_send_signal(int signo) pidfile_path = t_strconcat(doveadm_settings->base_dir, "/"MASTER_PID_FILE_NAME, NULL); - if (!pid_file_read(pidfile_path, &pid)) + if (!pid_file_read(pidfile_path, &pid, event)) i_fatal("Dovecot is not running (read from %s)", pidfile_path); if (kill(pid, signo) < 0) @@ -74,7 +74,7 @@ void doveadm_master_send_signal(int signo) for (i = 0; i < 30; i++) { if (kill(pid, 0) < 0) { if (errno != ESRCH) - i_error("kill() failed: %m"); + e_error(event, "kill() failed: %m"); break; } i_sleep_msecs(100); @@ -82,14 +82,14 @@ void doveadm_master_send_signal(int signo) } } -static void cmd_stop(struct doveadm_cmd_context *cctx ATTR_UNUSED) +static void cmd_stop(struct doveadm_cmd_context *cctx) { - doveadm_master_send_signal(SIGTERM); + doveadm_master_send_signal(SIGTERM, cctx->event); } -static void cmd_reload(struct doveadm_cmd_context *cctx ATTR_UNUSED) +static void cmd_reload(struct doveadm_cmd_context *cctx) { - doveadm_master_send_signal(SIGHUP); + doveadm_master_send_signal(SIGHUP, cctx->event); } static struct istream *master_service_send_cmd(const char *cmd) @@ -141,14 +141,14 @@ static void cmd_service_stop(struct doveadm_cmd_context *cctx) alarm(5); if ((line = i_stream_read_next_line(input)) == NULL) { - i_error("read(%s) failed: %s", i_stream_get_name(input), + e_error(cctx->event, "read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); doveadm_exit_code = EX_TEMPFAIL; } else if (line[0] == '-') { doveadm_exit_code = DOVEADM_EX_NOTFOUND; - i_error("%s", line+1); + e_error(cctx->event, "%s", line+1); } else if (line[0] != '+') { - i_error("Unexpected input from %s: %s", + e_error(cctx->event, "Unexpected input from %s: %s", i_stream_get_name(input), line); doveadm_exit_code = EX_TEMPFAIL; } @@ -200,7 +200,7 @@ static void cmd_service_status(struct doveadm_cmd_context *cctx) } T_END; } if (line == NULL) { - i_error("read(%s) failed: %s", i_stream_get_name(input), + e_error(cctx->event, "read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); doveadm_exit_code = EX_TEMPFAIL; } @@ -240,7 +240,7 @@ static void cmd_process_status(struct doveadm_cmd_context *cctx) } T_END; } if (line == NULL) { - i_error("read(%s) failed: %s", i_stream_get_name(input), + e_error(cctx->event, "read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); doveadm_exit_code = EX_TEMPFAIL; } diff --git a/src/doveadm/doveadm-mutf7.c b/src/doveadm/doveadm-mutf7.c index 3f788f5524..7779e3bc7e 100644 --- a/src/doveadm/doveadm-mutf7.c +++ b/src/doveadm/doveadm-mutf7.c @@ -29,13 +29,15 @@ static void cmd_mailbox_mutf7(struct doveadm_cmd_context *cctx) str_truncate(str, 0); if (from_utf8) { if (imap_utf8_to_utf7(names[i], str) < 0) { - i_error("Mailbox name not valid UTF-8: %s", + e_error(cctx->event, + "Mailbox name not valid UTF-8: %s", names[i]); doveadm_exit_code = EX_DATAERR; } } else { if (imap_utf7_to_utf8(names[i], str) < 0) { - i_error("Mailbox name not valid mUTF-7: %s", + e_error(cctx->event, + "Mailbox name not valid mUTF-7: %s", names[i]); doveadm_exit_code = EX_DATAERR; } diff --git a/src/doveadm/doveadm-penalty.c b/src/doveadm/doveadm-penalty.c index b152b06f5e..8a098b3453 100644 --- a/src/doveadm/doveadm-penalty.c +++ b/src/doveadm/doveadm-penalty.c @@ -107,7 +107,7 @@ static void cmd_penalty(struct doveadm_cmd_context *cctx) if (doveadm_cmd_param_str(cctx, "netmask", &netmask)) { if (net_parse_range(netmask, &ctx.net_ip, &ctx.net_bits) != 0) { doveadm_exit_code = EX_USAGE; - i_error("Invalid netmask '%s' given", netmask); + e_error(cctx->event, "Invalid netmask '%s' given", netmask); return; } } diff --git a/src/doveadm/doveadm-pw.c b/src/doveadm/doveadm-pw.c index bdc983269c..c318ea75ce 100644 --- a/src/doveadm/doveadm-pw.c +++ b/src/doveadm/doveadm-pw.c @@ -75,7 +75,7 @@ static void cmd_pw(struct doveadm_cmd_context *cctx) plaintext = t_askpass("Enter new password: "); check = t_askpass("Retype new password: "); if (strcmp(plaintext, check) != 0) { - i_error("Passwords don't match!"); + e_error(cctx->event, "Passwords don't match!"); if (--lives == 0) lib_exit(1); plaintext = NULL; diff --git a/src/doveadm/doveadm-replicator.c b/src/doveadm/doveadm-replicator.c index 17af8b9cbc..bc7ce114d9 100644 --- a/src/doveadm/doveadm-replicator.c +++ b/src/doveadm/doveadm-replicator.c @@ -169,7 +169,7 @@ static void cmd_replicator_status(struct doveadm_cmd_context *cctx) } T_END; } if (line == NULL) { - i_error("Replicator disconnected unexpectedly"); + e_error(cctx->event, "Replicator disconnected unexpectedly"); doveadm_exit_code = EX_TEMPFAIL; } replicator_disconnect(ctx); @@ -238,10 +238,10 @@ static void cmd_replicator_replicate(struct doveadm_cmd_context *cctx) line = i_stream_read_next_line(ctx->input); if (line == NULL) { - i_error("Replicator disconnected unexpectedly"); + e_error(cctx->event, "Replicator disconnected unexpectedly"); doveadm_exit_code = EX_TEMPFAIL; } else if (line[0] != '+') { - i_error("Replicator failed: %s", line+1); + e_error(cctx->event, "Replicator failed: %s", line+1); doveadm_exit_code = EX_USAGE; } else { doveadm_print(t_strdup_printf("%s users updated", line+1)); @@ -267,10 +267,10 @@ static void cmd_replicator_add(struct doveadm_cmd_context *cctx) line = i_stream_read_next_line(ctx->input); if (line == NULL) { - i_error("Replicator disconnected unexpectedly"); + e_error(cctx->event, "Replicator disconnected unexpectedly"); doveadm_exit_code = EX_TEMPFAIL; } else if (line[0] != '+') { - i_error("Replicator failed: %s", line+1); + e_error(cctx->event, "Replicator failed: %s", line+1); doveadm_exit_code = EX_USAGE; } replicator_disconnect(ctx); @@ -294,10 +294,10 @@ static void cmd_replicator_remove(struct doveadm_cmd_context *cctx) line = i_stream_read_next_line(ctx->input); if (line == NULL) { - i_error("Replicator disconnected unexpectedly"); + e_error(cctx->event, "Replicator disconnected unexpectedly"); doveadm_exit_code = EX_TEMPFAIL; } else if (line[0] != '+') { - i_error("Replicator failed: %s", line+1); + e_error(cctx->event, "Replicator failed: %s", line+1); doveadm_exit_code = EX_USAGE; } replicator_disconnect(ctx); diff --git a/src/doveadm/doveadm-sis.c b/src/doveadm/doveadm-sis.c index de64447907..2b1f24edb3 100644 --- a/src/doveadm/doveadm-sis.c +++ b/src/doveadm/doveadm-sis.c @@ -315,7 +315,7 @@ static void cmd_sis_find(struct doveadm_cmd_context *cctx) } } if (closedir(dir) < 0) - i_error("closedir(%s) failed: %m", path); + e_error(cctx->event, "closedir(%s) failed: %m", path); } struct doveadm_cmd_ver2 doveadm_cmd_sis_deduplicate = { diff --git a/src/doveadm/doveadm-stats.c b/src/doveadm/doveadm-stats.c index ddb198b3dd..6bcf419a15 100644 --- a/src/doveadm/doveadm-stats.c +++ b/src/doveadm/doveadm-stats.c @@ -86,7 +86,7 @@ static void stats_exec_cmd(struct doveadm_cmd_context *cctx, const char *build_cmd_error; ctx.cctx = cctx; if (vfuncs->build_cmd(&ctx, &build_cmd_error) < 0) { - i_error("%s", build_cmd_error); + e_error(cctx->event, "%s", build_cmd_error); return; } stats_send_cmd(&ctx); @@ -96,7 +96,7 @@ static void stats_exec_cmd(struct doveadm_cmd_context *cctx, static void handle_disconnection(struct stats_cmd_context *ctx) { - i_error("read(%s) failed: %s", ctx->path, + e_error(ctx->cctx->event, "read(%s) failed: %s", ctx->path, i_stream_get_disconnect_reason(ctx->input)); } @@ -267,9 +267,9 @@ static void stats_modify_process_response(struct stats_cmd_context *ctx) return; } if (line[0] == '-') - i_error("%s", ++line); + e_error(ctx->cctx->event, "%s", ++line); else if (line[0] != '+') - i_error("Invalid response: %s", line); + e_error(ctx->cctx->event, "Invalid response: %s", line); } static int build_stats_remove_cmd(struct stats_cmd_context *ctx, diff --git a/src/doveadm/doveadm.h b/src/doveadm/doveadm.h index c0918544d1..f9037871aa 100644 --- a/src/doveadm/doveadm.h +++ b/src/doveadm/doveadm.h @@ -21,6 +21,6 @@ extern int doveadm_exit_code; void usage(void) ATTR_NORETURN; void help_ver2(const struct doveadm_cmd_ver2 *cmd) ATTR_NORETURN; -void doveadm_master_send_signal(int signo); +void doveadm_master_send_signal(int signo, struct event *event); #endif -- 2.47.3