From add5bfb1e4029e406f7f331407c9d0f28d6d789b Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 25 Feb 2025 11:32:18 +0100 Subject: check_ssh: Move default SSH constant around a bit --- plugins/check_ssh.c | 7 ++----- plugins/check_ssh.d/config.h | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index 0f1c0835..b73cdf24 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c @@ -44,7 +44,6 @@ const char *email = "devel@monitoring-plugins.org"; # define MSG_DONTWAIT 0 #endif -#define SSH_DFL_PORT 22 #define BUFF_SZ 256 static bool verbose = false; @@ -219,9 +218,7 @@ process_arguments_wrapper process_arguments(int argc, char **argv) { result.errorcode = ERROR; return result; } - if (result.config.port == -1) { /* funky, but allows -p to override stray integer in args */ - result.config.port = SSH_DFL_PORT; - } + return result; } @@ -398,7 +395,7 @@ int ssh_connect(mp_check *overall, char *haddr, int hport, char *desired_remote_ void print_help(void) { char *myport; - xasprintf(&myport, "%d", SSH_DFL_PORT); + xasprintf(&myport, "%d", default_ssh_port); print_revision(progname, NP_VERSION); diff --git a/plugins/check_ssh.d/config.h b/plugins/check_ssh.d/config.h index d739c57c..c150fd30 100644 --- a/plugins/check_ssh.d/config.h +++ b/plugins/check_ssh.d/config.h @@ -3,6 +3,8 @@ #include #include "../../lib/monitoringplug.h" +const int default_ssh_port = 22; + typedef struct check_ssh_config { int port; char *server_name; @@ -15,7 +17,7 @@ typedef struct check_ssh_config { check_ssh_config check_ssh_config_init(void) { check_ssh_config tmp = { - .port = -1, + .port = default_ssh_port, .server_name = NULL, .remote_version = NULL, .remote_protocol = NULL, -- cgit v1.2.3-74-g34f1