diff options
| author | Franz Schwartau <franz@electromail.org> | 2023-08-29 09:35:53 +0200 |
|---|---|---|
| committer | Franz Schwartau <franz@electromail.org> | 2023-08-29 09:46:50 +0200 |
| commit | ce96ef868a5ee14947b9e213e3c36917cdd9e786 (patch) | |
| tree | 67f5acaed72153685df01c9363a6304c865a3202 | |
| parent | 079c300dcc6479b53e1f84a6b9446c7f403a7612 (diff) | |
| download | monitoring-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.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 3990ad82..fc0ae2c4 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
| @@ -84,6 +84,7 @@ int eflags = 0; | |||
| 84 | int errcode, excode; | 84 | int errcode, excode; |
| 85 | 85 | ||
| 86 | int server_port = SMTP_PORT; | 86 | int server_port = SMTP_PORT; |
| 87 | int server_port_option = 0; | ||
| 87 | char *server_address = NULL; | 88 | char *server_address = NULL; |
| 88 | char *server_expect = NULL; | 89 | char *server_expect = NULL; |
| 89 | char *mail_command = NULL; | 90 | char *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 | ||
