if (opt->name == param->name &&
doveadm_fill_param(
param, optarg, pool, &error) < 0) {
- i_error("Invalid parameter: %s",
- error);
+ e_error(cctx->event,
+ "Invalid parameter: %s", error);
doveadm_cmd_params_clean(pargv);
return -1;
}
}
break;
case '?':
- i_error("Unexpected or incomplete option: -%c", optopt);
+ e_error(cctx->event,
+ "Unexpected or incomplete option: -%c", optopt);
doveadm_cmd_params_clean(pargv);
return -1;
case ':':
- i_error("Option not followed by argument: -%c", optopt);
+ e_error(cctx->event,
+ "Option not followed by argument: -%c", optopt);
doveadm_cmd_params_clean(pargv);
return -1;
default:
doveadm_fill_param(
array_idx_modifiable(pargv, i),
optarg, pool, &error) < 0) {
- i_error("Invalid parameter: %s",
- error);
+ e_error(cctx->event,
+ "Invalid parameter: %s", error);
doveadm_cmd_params_clean(pargv);
return -1;
}
const char *error;
if (doveadm_fill_param(ptr, argv[optind], pool, &error) < 0) {
- i_error("Invalid parameter: %s",
+ e_error(cctx->event, "Invalid parameter: %s",
t_strarray_join(argv + optind, " "));
doveadm_cmd_params_clean(&pargv);
return -1;
break;
}
if (!found) {
- i_error("Extraneous arguments found: %s",
+ e_error(cctx->event, "Extraneous arguments found: %s",
t_strarray_join(argv + optind, " "));
doveadm_cmd_params_clean(&pargv);
return -1;
void doveadm_cmd_params_dump(const struct doveadm_cmd_context *cctx)
{
- i_debug("%s()", __func__);
+ e_debug(cctx->event, "%s()", __func__);
i_assert(cctx != NULL);
i_assert(cctx->argv != NULL);
const struct doveadm_cmd_param *argv = cctx->argv;
for (int index = 0; index < cctx->argc; index++, argv++) T_BEGIN {
const char *value = doveadm_cmd_param_tostring(argv);
- i_debug(" %c%c%c%c %02x/%02x -%c %s: %s",
+ e_debug(cctx->event, " %c%c%c%c %02x/%02x -%c %s: %s",
*value != '\0' ? 'S': '-',
argv->type == CMD_PARAM_ARRAY ? 'A': '-',
(argv->flags & CMD_PARAM_FLAG_POSITIONAL) != 0 ? 'P': '-',
}
static const char *const *
-get_ssh_cmd_args(const char *host, const char *login, const char *mail_user)
+get_ssh_cmd_args(const char *host, const char *login, const char *mail_user,
+ struct event *event)
{
static struct var_expand_table static_tab[] = {
{ 'u', NULL, "user" },
str_truncate(str2, 0);
if (var_expand(str, *args, tab, &error) <= 0 ||
var_expand(str2, *args, static_tab, &error) <= 0) {
- i_error("Failed to expand dsync_remote_cmd=%s: %s",
+ e_error(event,
+ "Failed to expand dsync_remote_cmd=%s: %s",
*args, error);
}
if (strcmp(str_c(str), str_c(str2)) == 0 &&
static bool mirror_get_remote_cmd(struct dsync_cmd_context *ctx,
const char *user,
+ struct event *event,
const char *const **cmd_args_r)
{
const char *p, *host, *const *argv = ctx->destination;
/* we'll assume virtual users, so in user@host it really means not to
give ssh a username, but to give dsync -u user parameter. */
- *cmd_args_r = get_ssh_cmd_args(host, "", user);
+ *cmd_args_r = get_ssh_cmd_args(host, "", user, event);
return TRUE;
}
}
static void cmd_dsync_log_remote_status(int status, bool remote_errors_logged,
- const char *const *remote_cmd_args)
+ const char *const *remote_cmd_args,
+ struct event *event)
{
if (status == -1)
;
else if (WIFSIGNALED(status)) {
- i_error("Remote command died with signal %d: %s", WTERMSIG(status),
+ e_error(event,
+ "Remote command died with signal %d: %s",
+ WTERMSIG(status),
t_strarray_join(remote_cmd_args, " "));
} else if (!WIFEXITED(status)) {
- i_error("Remote command failed with status %d: %s", status,
+ e_error(event,
+ "Remote command failed with status %d: %s", status,
t_strarray_join(remote_cmd_args, " "));
} else if (WEXITSTATUS(status) == EX_TEMPFAIL && remote_errors_logged) {
/* remote most likely already logged the error.
don't bother logging another line about it */
} else if (WEXITSTATUS(status) != 0) {
- i_error("Remote command returned error %d: %s", WEXITSTATUS(status),
+ e_error(event,
+ "Remote command returned error %d: %s",
+ WEXITSTATUS(status),
t_strarray_join(remote_cmd_args, " "));
}
}
}
static const char *const *
-parse_ssh_location(const char *location, const char *username)
+parse_ssh_location(const char *location, const char *username, struct event *event)
{
const char *host, *login;
host = location;
login = "";
}
- return get_ssh_cmd_args(host, login, username);
+ return get_ssh_cmd_args(host, login, username, event);
}
static struct dsync_ibc *
bool remote_errors_logged = ctx->err_stream->v_offset > 0;
i_stream_destroy(&ctx->err_stream);
cmd_dsync_log_remote_status(ctx->exit_status, remote_errors_logged,
- ctx->remote_cmd_args);
+ ctx->remote_cmd_args, ctx->ctx.cctx->event);
io_remove(&ctx->io_err);
i_close_fd(&ctx->fd_err);
}
break;
case DOVEADM_EX_NOREPLICATE:
if (doveadm_debug)
- i_debug("user is disabled for replication");
+ e_debug(ctx->ctx.cctx->event,
+ "user is disabled for replication");
break;
default:
ctx->error = p_strdup_printf(ctx->ctx.pool,
return 0;
}
*remote_cmd_args_r =
- parse_ssh_location(ctx->remote_name, cctx->username);
+ parse_ssh_location(ctx->remote_name, cctx->username, cctx->event);
return 0;
}
if ((_ctx->service_flags & MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP) != 0)
username = cctx->username;
- if (!mirror_get_remote_cmd(ctx, username, &remote_cmd_args)) {
+ if (!mirror_get_remote_cmd(ctx, username, cctx->event, &remote_cmd_args)) {
/* it's a mail_location */
if (ctx->destination[1] != NULL)
doveadm_mail_help_name(_ctx->cmd->name);