Commit graph

2641 commits

Author SHA1 Message Date
Lorenz Kästle
78cb7b2288 check_snmp: fix typos 2025-08-27 19:12:56 +02:00
Lorenz Kästle
75f792bc6b check_snmp: declare internal functions static 2025-08-27 16:43:32 +02:00
Lorenz Kästle
faf794b401 check_snmp: remove leftover multiply function 2025-08-27 16:43:11 +02:00
Lorenz Kästle
015e4c0986 check_snmp: fix/adapt tests 2025-08-27 16:42:06 +02:00
Lorenz Kästle
e490c5f969 check_snmp: hopefully fix helpers 2025-08-27 16:41:46 +02:00
Lorenz Kästle
f976155863 check_snmp: Improve error handling 2025-08-27 16:41:02 +02:00
Lorenz Kästle
a27862a9c7 check_snmp: rebuild threshold parsing 2025-08-27 12:17:46 +02:00
Lorenz Kästle
7fe6ac8d08 rebuild check_snmp 2025-08-25 15:28:04 +02:00
Lorenz Kästle
7382fa90f8 Merge branch 'master' into refactor/check_users 2025-08-11 21:54:05 +02:00
Lorenz Kästle
fb39f96ac6 check_users: Use sd_get_uids instead of sd_get_session
Previously check_users in combination with systemd used
sd_get_sessions (3) to aquire the number of users, probably
with the idea that every users opens a session.
Turns out, that a user can have multiple sessions and we only really
want to know how many users there are.

This commit changes to sd_get_uids (3) to achieve that target.
2025-08-11 21:49:20 +02:00
Lorenz Kästle
2757550558 clang-format 2025-08-01 14:35:23 +02:00
Lorenz Kästle
a69dff1522 check_ssh: Put variable in the correct scope 2025-08-01 14:35:13 +02:00
Lorenz Kästle
3c53bf623d check_ssh: Fix format expression 2025-08-01 14:34:29 +02:00
Lorenz Kästle
69925c782b check_ssh: fix data type to allow for error checking 2025-08-01 14:34:01 +02:00
Lorenz Kästle
b05087d9aa
Merge pull request #2133 from rlaager/fix-check_ssh-buffer-overflow
Fix check ssh buffer overflow
2025-08-01 14:27:48 +02:00
Lorenz Kästle
c43135a5e5 check_ntp_peer: fix invalid conversion in printf 2025-07-14 09:37:51 +02:00
Richard Laager
1f2acfd1c6 check_ssh: Correct type on len variable
strlen() returns a size_t.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
2025-07-11 18:44:03 -05:00
Richard Laager
661ecff45c check_ssh: Fix buffer overflow
A buffer overflow was occurring when the server responded with:
Exceeded MaxStartups\r\n

glibc would then abort() with the following output:
*** buffer overflow detected ***: terminated

It was the memset() that was overflowing the buffer.  But the memmove()
needed fixing too.

First off, there was an off-by-one error in both the memmove() and
memset().  byte_offset was already set to the start of the data _past_
the newline (i.e. len + 1).  For the memmove(), incrementing that by 1
again lost the first character of the additional output.  For the
memset(), this causes a buffer overflow.

Second, the memset() has multiple issues.  The comment claims that it
was NULing (sic "null") the "rest".  However, it has no idea how long
the "rest" is, at this point.  It was NULing BUFF_SZ - byte_offset + 1.
After fixing the off-by-one / buffer overflow, it would be NULing
BUFF_SZ - byte_offset.  But that doesn't make any sense.  The length of
the first line has no relation to the length of the second line.

For a quick-and-dirty test, add something like this just inside the
while loop:
memcpy(output,
  "Exceeded MaxStartups\r\nnext blah1 blah2 blah3 blah4\0",
  sizeof("Exceeded MaxStartups\r\nnext blah1 blah2 blah3 blah4\0"));

And, after the memmove(), add:
  printf("output='%s'\n", output);

If you fix the memset() buffer overflow, it will output:
output='ext blah1 blah2 blah3 '

As you can see, the first character is lost.

If you then fix the memmove(), it will output:
output='next blah1 blah2 blah3'

Note that this is still losing the "blah4".

After moving the memset() after byte_offset is set to the new strlen()
of output, then it works correctly:
output='next blah1 blah2 blah3 blah4'

Signed-off-by: Richard Laager <rlaager@wiktel.com>
2025-07-11 18:43:59 -05:00
Lorenz Kästle
b191a8a055 check_load: fix tests 2025-07-06 23:16:34 +02:00
Lorenz Kästle
92c7b91002 Merge branch 'master' into refactor/check_load 2025-07-06 22:49:04 +02:00
Lorenz Kästle
351b104894 check_load some number type fixes 2025-07-06 22:46:41 +02:00
Lorenz Kästle
b002a6870b check_load: Add top x functionality to output 2025-07-06 21:58:55 +02:00
Lorenz Kästle
4ef8af0d9a check_load: remove useless code and do some formatting 2025-07-06 21:46:54 +02:00
Lorenz Kästle
882ef5015f Merge branch 'master' into refactor/check_procs 2025-06-28 09:53:59 +02:00
Lorenz Kästle
b8580c18e3
Merge pull request #2125 from RincewindsHat/refactor/check_icmp
Refactor check_icmp:

 - Far less global variables
 - Proper IPv6/legacy IP dual stack functionality (allowed mixed v4/v6 hosts)
 - Improved readability/understandability
 - General cleanup
2025-06-20 11:29:07 +02:00
Lorenz Kästle
a669b2531d Remove options if fping version is too low and die directly 2025-06-12 13:33:50 +02:00
Lorenz Kästle
19f409ac55 Remove unnecessary newline 2025-06-12 13:26:55 +02:00
Lorenz Kästle
f2c6ce08e3 check_fping: small style improvement 2025-06-12 11:53:06 +02:00
Lorenz Kästle
7247fc656a Implement new fping options for fping 5.2 and 5.3
fping 5.2 and 5.3 add some new useful command line options
which this commit add to check_fping.

These are:

 * --fwmark - sets a firewall mark in the packages to make them
   identifiable (fping 5.2)
 * --icmp-timestamp - fping uses ICMP timestamp instead of ICMP
   Echo (fping 5.2)
 * --check-source - fping discards replies which originate not from
   the target address (fping 5.2)

The fping release notes describe theses options ( https://github.com/schweikert/fping/releases )
in a little bit more detail.
Currently the help display for those options is only shown
when fping was available in the appropriate version during
compilation.
2025-06-12 11:13:59 +02:00
Lorenz Kästle
dd93b1403a utils: Make fmt function for compiler 2025-05-18 19:19:23 +02:00
William
1fb9300a2f Remove un-needed flags 2025-05-07 13:17:47 +10:00
William
58a3424511 Improve logic 2025-05-07 13:15:51 +10:00
William
a1472be883 Harden check with unspec 2025-05-07 13:15:51 +10:00
William
4acba2b3ec Improve handling of -4/-6
If fping is used with a target that has dual stack v4/v6, then due to
the logic during command construction, ipv4 will never be checked as v6
is preferred by fping.

This explicitly flags -4/-6 when it is requested by the user.
2025-05-07 13:15:51 +10:00
Jan Wagner
14169fe5a1 check_http: Adding deprecation text 2025-04-21 10:55:23 +02:00
Lorenz Kästle
4924bc877f
Merge pull request #2113 from RincewindsHat/refactor/check_disk
Refactor/check disk
2025-03-31 23:58:02 +02:00
Lorenz Kästle
13c9de8c77 Try fixing some tests 2025-03-31 23:40:22 +02:00
Lorenz Kästle
24a50b9421 check_disk: decrease precision to avoid false negatives with small measurement changes 2025-03-31 22:18:19 +02:00
Lorenz Kästle
1b0085c2e7 Fixes problems after a4cf2e79f7 2025-03-31 00:46:10 +02:00
Lorenz Kästle
d6d394fb0e Fix some typos with units 2025-03-31 00:10:56 +02:00
Lorenz Kästle
d1d6ba6706 Add debugging to tests for CI 2025-03-30 23:42:50 +02:00
Lorenz Kästle
a4cf2e79f7 Remove cool, comfy c23 functionality for some dirty old hacks 2025-03-30 23:30:51 +02:00
Lorenz Kästle
c4fd34ed79 Codespell fixes 2025-03-30 22:46:09 +02:00
Lorenz Kästle
76971dea75 Address check_disk changes in tests 2025-03-30 22:38:12 +02:00
Lorenz Kästle
908aed4e6f Refactor check_disk and library functions 2025-03-30 22:37:48 +02:00
Lorenz Kästle
a0710dbd72 check_disk: Remove unnecessary NULL checks 2025-03-18 16:26:14 +01:00
Lorenz Kästle
42531fa92a Refactor test_check_disk.c 2025-03-18 16:23:33 +01:00
Lorenz Kästle
75cf0d3072 Remove some unused code 2025-03-18 16:23:06 +01:00
Lorenz Kästle
59e0a258f9 Migrate disk tests from lib, tool 2025-03-18 15:57:44 +01:00
Lorenz Kästle
29d946b9b5 Refactor check_disk, no more global variables 2025-03-18 14:37:49 +01:00