From ce96ef868a5ee14947b9e213e3c36917cdd9e786 Mon Sep 17 00:00:00 2001 From: Franz Schwartau Date: Tue, 29 Aug 2023 09:35:53 +0200 Subject: check_smtp: Let port option always take precedence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise -s/--ssl would overwrite a port given with -p if it comes after it, e. g. check_smtp -H mailhost.example.com -p 4465 --ssl Found-By: Lorenz Kästle diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 3990ad8..fc0ae2c 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -84,6 +84,7 @@ int eflags = 0; int errcode, excode; int server_port = SMTP_PORT; +int server_port_option = 0; char *server_address = NULL; char *server_expect = NULL; char *mail_command = NULL; @@ -544,7 +545,7 @@ process_arguments (int argc, char **argv) break; case 'p': /* port */ if (is_intpos (optarg)) - server_port = atoi (optarg); + server_port_option = atoi (optarg); else usage4 (_("Port must be a positive integer")); break; @@ -719,6 +720,10 @@ process_arguments (int argc, char **argv) usage4 (_("Set either -s/--ssl/--tls or -S/--starttls")); } + if (server_port_option != 0) { + server_port = server_port_option; + } + return validate_arguments (); } -- cgit v0.10-9-g596f