diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2023-02-06 18:51:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-06 18:51:40 +0100 |
commit | 5a50b260ee94df89f2e328affa93983bb0caff57 (patch) | |
tree | 2a660ceb8a8736058142523a60b11edf0444d690 | |
parent | dca0927b459ca7f1260d1d359865d3821297d81a (diff) | |
parent | e0dfb0622d19a4b4340dab9a315cb4b649f6f1e4 (diff) | |
download | monitoring-plugins-5a50b26.tar.gz |
Merge branch 'master' into gnulib_update_2023
-rwxr-xr-x | .github/prepare_debian.sh | 1 | ||||
-rw-r--r-- | NEWS | 38 | ||||
-rw-r--r-- | THANKS.in | 5 | ||||
-rw-r--r-- | doc/RELEASING.md | 8 | ||||
-rw-r--r-- | plugins/check_http.c | 8 | ||||
-rwxr-xr-x | plugins/tests/check_http.t | 70 |
6 files changed, 124 insertions, 6 deletions
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh index d8a76da6..5222659e 100755 --- a/.github/prepare_debian.sh +++ b/.github/prepare_debian.sh | |||
@@ -5,6 +5,7 @@ set -e | |||
5 | 5 | ||
6 | export DEBIAN_FRONTEND=noninteractive | 6 | export DEBIAN_FRONTEND=noninteractive |
7 | 7 | ||
8 | sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources | ||
8 | apt-get update | 9 | apt-get update |
9 | apt-get -y install software-properties-common | 10 | apt-get -y install software-properties-common |
10 | if [ $(lsb_release -is) = "Debian" ]; then | 11 | if [ $(lsb_release -is) = "Debian" ]; then |
@@ -1,5 +1,43 @@ | |||
1 | This file documents the major additions and syntax changes between releases. | 1 | This file documents the major additions and syntax changes between releases. |
2 | 2 | ||
3 | 2.3.3 2nd Feb 2023 | ||
4 | ENHANCEMENTS | ||
5 | using PRId64 and PRIu64 instead of %ld directly | ||
6 | check_http: Make faster with larger files | ||
7 | check_snmp: add 'multiplier' to modify current value | ||
8 | check_http: Implement chunked encoding decoding | ||
9 | check_http/check_curl: add chunked encoding test | ||
10 | check_log: Added --exclude to exclude patterns | ||
11 | check_log: Add tests | ||
12 | check_disk: Clarify usage possibilites | ||
13 | |||
14 | FIXES | ||
15 | fixed two PRId64 to PRIu64 in perfdata_uint64 | ||
16 | check_pgsql: Removing is_pg_dbname alltogether,using postgres API. | ||
17 | check_http: Remove superflous CRLF in HTTP-Requests | ||
18 | check_curl: detect ipv6 | ||
19 | check_icmp: fix parsing help/version long options | ||
20 | check_http: fix test plan | ||
21 | check_disk: Find accessible mount path if multiple are available | ||
22 | check_apt: Fix unknown escape sequence error output | ||
23 | check_curl: fix checking large bodys | ||
24 | check_snmp: Improve tests for check_snmp & multiply option | ||
25 | check_snmp: always apply format when applying multiplier | ||
26 | check_http: Use real booleans instead of ints | ||
27 | check_http: Document process_arguments a little bit better | ||
28 | check_http: Remove dead code | ||
29 | check_http: Fix several bug in the implementation of unchunking | ||
30 | check_http: Reformat a part to increase readability | ||
31 | check_apt: Put upgrade options in the root sections | ||
32 | check_apt: Fix comment | ||
33 | check_apt: Use real booleans | ||
34 | check_mailq: Fixing nullmailer regex | ||
35 | check_snmp: Fix regex matches | ||
36 | check_log: Fixed a bug when using --all | ||
37 | check_log: Cleaned up duplicated code in the args | ||
38 | check_http: Fix memory reallocation error in chunk decoding logic | ||
39 | check_http: Add space for ending NULL byte in array for chunked encoding | ||
40 | |||
3 | 2.3.2 20th Oct 2022 | 41 | 2.3.2 20th Oct 2022 |
4 | GENERAL | 42 | GENERAL |
5 | Use netcat-openbsd for debian explicitely (by @RincewindsHat #1704) | 43 | Use netcat-openbsd for debian explicitely (by @RincewindsHat #1704) |
@@ -400,3 +400,8 @@ Peter Newman | |||
400 | Tobias Fiebig | 400 | Tobias Fiebig |
401 | Tobias Wiese | 401 | Tobias Wiese |
402 | Wolfgang Karall-Ahlborn | 402 | Wolfgang Karall-Ahlborn |
403 | Danijel Tasov | ||
404 | Robert Bohne | ||
405 | Wolfgang Nieder | ||
406 | andrew bezella | ||
407 | Lorenz Gruenwald | ||
diff --git a/doc/RELEASING.md b/doc/RELEASING.md index 58ec3e16..432b1da1 100644 --- a/doc/RELEASING.md +++ b/doc/RELEASING.md | |||
@@ -2,7 +2,7 @@ Releasing a New Monitoring Plugins Version | |||
2 | ========================================== | 2 | ========================================== |
3 | 3 | ||
4 | Throughout this document, it is assumed that the current Monitoring | 4 | Throughout this document, it is assumed that the current Monitoring |
5 | Plugins version is 2.3.2, and that we're about to publish version 2.4. | 5 | Plugins version is 2.3.3, and that we're about to publish version 2.4. |
6 | It is also assumed that the official repository on GitHub is tracked | 6 | It is also assumed that the official repository on GitHub is tracked |
7 | using the remote name `monitoring-plugins` (rather than `origin`). | 7 | using the remote name `monitoring-plugins` (rather than `origin`). |
8 | 8 | ||
@@ -11,14 +11,14 @@ Before you start | |||
11 | 11 | ||
12 | - Check Github Actions status. | 12 | - Check Github Actions status. |
13 | - Update local Git repository to the current `master` tip. For a | 13 | - Update local Git repository to the current `master` tip. For a |
14 | maintenance release (e.g., version 2.3.2), update to the current | 14 | maintenance release (e.g., version 2.3.4), update to the current |
15 | `maint-2.3` tip, instead. | 15 | `maint-2.3` tip, instead. |
16 | 16 | ||
17 | Prepare and commit files | 17 | Prepare and commit files |
18 | ------------------------ | 18 | ------------------------ |
19 | 19 | ||
20 | - Update `configure.ac` and `NP-VERSION-GEN` with new version. | 20 | - Update `configure.ac` and `NP-VERSION-GEN` with new version. |
21 | - Update `NEWS` from `git log --reverse v2.3.1..` output, and specify | 21 | - Update `NEWS` from `git log --reverse v2.3.3..` output, and specify |
22 | the release version/date. | 22 | the release version/date. |
23 | - Update `AUTHORS` if there are new team members. | 23 | - Update `AUTHORS` if there are new team members. |
24 | - Update `THANKS.in` using `tools/update-thanks`. | 24 | - Update `THANKS.in` using `tools/update-thanks`. |
@@ -93,6 +93,6 @@ Announce new release | |||
93 | 93 | ||
94 | If you want to mention the number of contributors in the announcement: | 94 | If you want to mention the number of contributors in the announcement: |
95 | 95 | ||
96 | git shortlog -s v2.3.1..v2.4 | wc -l | 96 | git shortlog -s v2.3.3..v2.4 | wc -l |
97 | 97 | ||
98 | <!-- vim:set filetype=markdown textwidth=72: --> | 98 | <!-- vim:set filetype=markdown textwidth=72: --> |
diff --git a/plugins/check_http.c b/plugins/check_http.c index 5fa310f5..8dda046f 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -1462,7 +1462,13 @@ char *unchunk_content(const char *content) { | |||
1462 | memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk); | 1462 | memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk); |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | result[overall_size] = '\0'; | 1465 | if (overall_size == 0 && result == NULL) { |
1466 | // We might just have received the end chunk without previous content, so result is never allocated | ||
1467 | result = calloc(1, sizeof(char)); | ||
1468 | // No error handling here, we can only return NULL anyway | ||
1469 | } else { | ||
1470 | result[overall_size] = '\0'; | ||
1471 | } | ||
1466 | return result; | 1472 | return result; |
1467 | } | 1473 | } |
1468 | 1474 | ||
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index d766ac37..6078b274 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -9,12 +9,14 @@ use strict; | |||
9 | use Test::More; | 9 | use Test::More; |
10 | use NPTest; | 10 | use NPTest; |
11 | use FindBin qw($Bin); | 11 | use FindBin qw($Bin); |
12 | use IO::Socket::INET; | ||
12 | 13 | ||
13 | $ENV{'LC_TIME'} = "C"; | 14 | $ENV{'LC_TIME'} = "C"; |
14 | 15 | ||
15 | my $common_tests = 71; | 16 | my $common_tests = 71; |
16 | my $virtual_port_tests = 8; | 17 | my $virtual_port_tests = 8; |
17 | my $ssl_only_tests = 12; | 18 | my $ssl_only_tests = 12; |
19 | my $chunked_encoding_special_tests = 1; | ||
18 | # Check that all dependent modules are available | 20 | # Check that all dependent modules are available |
19 | eval "use HTTP::Daemon 6.01;"; | 21 | eval "use HTTP::Daemon 6.01;"; |
20 | plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@; | 22 | plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@; |
@@ -30,7 +32,7 @@ if ($@) { | |||
30 | plan skip_all => "Missing required module for test: $@"; | 32 | plan skip_all => "Missing required module for test: $@"; |
31 | } else { | 33 | } else { |
32 | if (-x "./$plugin") { | 34 | if (-x "./$plugin") { |
33 | plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests; | 35 | plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests + $chunked_encoding_special_tests; |
34 | } else { | 36 | } else { |
35 | plan skip_all => "No $plugin compiled"; | 37 | plan skip_all => "No $plugin compiled"; |
36 | } | 38 | } |
@@ -51,6 +53,7 @@ my $port_http = 50000 + int(rand(1000)); | |||
51 | my $port_https = $port_http + 1; | 53 | my $port_https = $port_http + 1; |
52 | my $port_https_expired = $port_http + 2; | 54 | my $port_https_expired = $port_http + 2; |
53 | my $port_https_clientcert = $port_http + 3; | 55 | my $port_https_clientcert = $port_http + 3; |
56 | my $port_hacked_http = $port_http + 4; | ||
54 | 57 | ||
55 | # This array keeps sockets around for implementing timeouts | 58 | # This array keeps sockets around for implementing timeouts |
56 | my @persist; | 59 | my @persist; |
@@ -72,6 +75,28 @@ if (!$pid) { | |||
72 | } | 75 | } |
73 | push @pids, $pid; | 76 | push @pids, $pid; |
74 | 77 | ||
78 | # Fork the hacked HTTP server | ||
79 | undef $pid; | ||
80 | $pid = fork; | ||
81 | defined $pid or die "Failed to fork"; | ||
82 | if (!$pid) { | ||
83 | # this is the fork | ||
84 | undef @pids; | ||
85 | my $socket = new IO::Socket::INET ( | ||
86 | LocalHost => '0.0.0.0', | ||
87 | LocalPort => $port_hacked_http, | ||
88 | Proto => 'tcp', | ||
89 | Listen => 5, | ||
90 | Reuse => 1 | ||
91 | ); | ||
92 | die "cannot create socket $!n" unless $socket; | ||
93 | my $local_sock = $socket->sockport(); | ||
94 | print "server waiting for client connection on port $local_sock\n"; | ||
95 | run_hacked_http_server ( $socket ); | ||
96 | die "hacked http server stopped"; | ||
97 | } | ||
98 | push @pids, $pid; | ||
99 | |||
75 | if (exists $servers->{https}) { | 100 | if (exists $servers->{https}) { |
76 | # Fork a normal HTTPS server | 101 | # Fork a normal HTTPS server |
77 | $pid = fork; | 102 | $pid = fork; |
@@ -207,6 +232,37 @@ sub run_server { | |||
207 | } | 232 | } |
208 | } | 233 | } |
209 | 234 | ||
235 | sub run_hacked_http_server { | ||
236 | my $socket = shift; | ||
237 | |||
238 | # auto-flush on socket | ||
239 | $| = 1; | ||
240 | |||
241 | |||
242 | while(1) | ||
243 | { | ||
244 | # waiting for a new client connection | ||
245 | my $client_socket = $socket->accept(); | ||
246 | |||
247 | # get information about a newly connected client | ||
248 | my $client_address = $client_socket->peerhost(); | ||
249 | my $client_portn = $client_socket->peerport(); | ||
250 | print "connection from $client_address:$client_portn"; | ||
251 | |||
252 | # read up to 1024 characters from the connected client | ||
253 | my $data = ""; | ||
254 | $client_socket->recv($data, 1024); | ||
255 | print "received data: $data"; | ||
256 | |||
257 | # write response data to the connected client | ||
258 | $data = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n"; | ||
259 | $client_socket->send($data); | ||
260 | |||
261 | # notify client that response has been sent | ||
262 | shutdown($client_socket, 1); | ||
263 | } | ||
264 | } | ||
265 | |||
210 | END { | 266 | END { |
211 | foreach my $pid (@pids) { | 267 | foreach my $pid (@pids) { |
212 | if ($pid) { print "Killing $pid\n"; kill "INT", $pid } | 268 | if ($pid) { print "Killing $pid\n"; kill "INT", $pid } |
@@ -222,6 +278,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
222 | my $result; | 278 | my $result; |
223 | my $command = "./$plugin -H 127.0.0.1"; | 279 | my $command = "./$plugin -H 127.0.0.1"; |
224 | 280 | ||
281 | run_chunked_encoding_special_test( {command => "$command -p $port_hacked_http"}); | ||
225 | run_common_tests( { command => "$command -p $port_http" } ); | 282 | run_common_tests( { command => "$command -p $port_http" } ); |
226 | SKIP: { | 283 | SKIP: { |
227 | skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https}; | 284 | skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https}; |
@@ -511,3 +568,14 @@ sub run_common_tests { | |||
511 | }; | 568 | }; |
512 | is( $@, "", $cmd ); | 569 | is( $@, "", $cmd ); |
513 | } | 570 | } |
571 | |||
572 | sub run_chunked_encoding_special_test { | ||
573 | my ($opts) = @_; | ||
574 | my $command = $opts->{command}; | ||
575 | |||
576 | $cmd = "$command -u / -s 'ChunkedEncodingSpecialTest'"; | ||
577 | eval { | ||
578 | $result = NPTest->testCmd( $cmd, 5 ); | ||
579 | }; | ||
580 | is( $@, "", $cmd ); | ||
581 | } | ||