From 6cd097921f0c5016fcae60b38dfb88c412e4bb20 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 10 Mar 2025 21:27:50 +0100 Subject: Allow setting of port independent of argument position again --- plugins/check_smtp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index fd492294..44b735f9 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -517,6 +517,7 @@ check_smtp_config_wrapper process_arguments(int argc, char **argv) { int command_size = 0; int response_size = 0; bool implicit_tls = false; + int server_port_option = 0; while (true) { int opt_index = getopt_long(argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:sSD:F:A:U:P:q", longopts, &option); @@ -534,7 +535,7 @@ check_smtp_config_wrapper process_arguments(int argc, char **argv) { break; case 'p': /* port */ if (is_intpos(optarg)) { - result.config.server_port = atoi(optarg); + server_port_option = atoi(optarg); } else { usage4(_("Port must be a positive integer")); } @@ -710,6 +711,10 @@ check_smtp_config_wrapper process_arguments(int argc, char **argv) { } } + if (server_port_option != 0) { + result.config.server_port = server_port_option; + } + return result; } -- cgit v1.2.3-74-g34f1