From 62242ddcf5caa09eee79c15a94a5d861b9be95c8 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 16 Nov 2025 15:27:19 +0100 Subject: check_by_ssh: do not incorrectly assume that ssh (1) succeeded --- plugins/check_by_ssh.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'plugins/check_by_ssh.c') diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 8036ffa4..ebe54b80 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -94,37 +94,18 @@ int main(int argc, char **argv) { mp_check overall = mp_check_init(); /* SSH returns 255 if connection attempt fails; include the first line of error output */ - mp_subcheck sc_ssh_execution = mp_subcheck_init(); + // we can sadly not detect other SSH errors if (child_result.cmd_error_code == 255 && config.unknown_timeout) { + mp_subcheck sc_ssh_execution = mp_subcheck_init(); xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s", child_result.stderr.lines > 0 ? child_result.stderr.line[0] : "(no error output)"); - sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); - mp_add_subcheck_to_check(&overall, sc_ssh_execution); - mp_exit(overall); - } else if (child_result.cmd_error_code != 0) { - xasprintf(&sc_ssh_execution.output, "SSH connection failed: "); - - if (child_result.stderr.lines > 0) { - for (size_t i = 0; i < child_result.stderr.lines; i++) { - xasprintf(&sc_ssh_execution.output, "%s\n%s", sc_ssh_execution.output, - child_result.stderr.line[i]); - } - } else { - xasprintf(&sc_ssh_execution.output, "%s %s", sc_ssh_execution.output, - "no output on stderr"); - } - sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); mp_add_subcheck_to_check(&overall, sc_ssh_execution); mp_exit(overall); } - xasprintf(&sc_ssh_execution.output, "SSH connection succeeded"); - sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_OK); - mp_add_subcheck_to_check(&overall, sc_ssh_execution); - if (verbose) { for (size_t i = 0; i < child_result.stdout.lines; i++) { printf("stdout: %s\n", child_result.stdout.line[i]); -- cgit v1.2.3-74-g34f1