summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFranz Schwartau <franz@electromail.org>2023-08-29 07:35:53 (GMT)
committerFranz Schwartau <franz@electromail.org>2023-08-29 07:46:50 (GMT)
commitce96ef868a5ee14947b9e213e3c36917cdd9e786 (patch)
tree67f5acaed72153685df01c9363a6304c865a3202
parent079c300dcc6479b53e1f84a6b9446c7f403a7612 (diff)
downloadmonitoring-plugins-ce96ef868a5ee14947b9e213e3c36917cdd9e786.tar.gz
check_smtp: Let port option always take precedence
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
-rw-r--r--plugins/check_smtp.c7
1 files changed, 6 insertions, 1 deletions
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;
84int errcode, excode; 84int errcode, excode;
85 85
86int server_port = SMTP_PORT; 86int server_port = SMTP_PORT;
87int server_port_option = 0;
87char *server_address = NULL; 88char *server_address = NULL;
88char *server_expect = NULL; 89char *server_expect = NULL;
89char *mail_command = NULL; 90char *mail_command = NULL;
@@ -544,7 +545,7 @@ process_arguments (int argc, char **argv)
544 break; 545 break;
545 case 'p': /* port */ 546 case 'p': /* port */
546 if (is_intpos (optarg)) 547 if (is_intpos (optarg))
547 server_port = atoi (optarg); 548 server_port_option = atoi (optarg);
548 else 549 else
549 usage4 (_("Port must be a positive integer")); 550 usage4 (_("Port must be a positive integer"));
550 break; 551 break;
@@ -719,6 +720,10 @@ process_arguments (int argc, char **argv)
719 usage4 (_("Set either -s/--ssl/--tls or -S/--starttls")); 720 usage4 (_("Set either -s/--ssl/--tls or -S/--starttls"));
720 } 721 }
721 722
723 if (server_port_option != 0) {
724 server_port = server_port_option;
725 }
726
722 return validate_arguments (); 727 return validate_arguments ();
723} 728}
724 729