Commit graph

445 commits

Author SHA1 Message Date
Sami Kerola
190df198a4 output: prefer thread safe function localtime_r()
While the dhcpd-pools might not be threading there is no reason why
software should use worse function when always correct alternative is
equally easy to use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-09 22:31:30 +00:00
Sami Kerola
e401c2c7e6 other: reduce variable scope
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-09 22:25:25 +00:00
Sami Kerola
0d2b30b62d getdata: fix buffer overflow [AddressSanitizer]
==12031==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61900000a980 at pc 0x0000004bca22 bp 0x7fff580dd6d0 sp 0x7fff580dd6c8
WRITE of size 1 at 0x61900000a980 thread T0
    #0 0x4bca21 in parse_config /home/src/dhcpd-pools/src/getdata.c:323:4
    #1 0x4bb332 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:266:2
    #2 0x7fe03ecc403f in __libc_start_main (/usr/lib/libc.so.6+0x2003f)
    #3 0x4b9c0c in _start (/home/src/dhcpd-pools/dhcpd-pools+0x4b9c0c)

0x61900000a980 is located 0 bytes to the right of 1024-byte region
[0x61900000a580,0x61900000a980) allocated by thread T0 here:
    #0 0x49c58b in __interceptor_malloc (/home/src/dhcpd-pools/dhcpd-pools+0x49c58b)
    #1 0x4cbc0d in xmalloc /home/src/dhcpd-pools/lib/xmalloc.c:41:13
    #2 0x4bbed8 in parse_config /home/src/dhcpd-pools/src/getdata.c:195:9
    #3 0x4bb332 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:266:2
    #4 0x7fe03ecc403f in __libc_start_main (/usr/lib/libc.so.6+0x2003f)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/src/dhcpd-pools/src/getdata.c:323 parse_config

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-02 21:56:43 +00:00
Sami Kerola
bd5877bf4f update bootstrap from gnulib
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-24 20:58:27 +01:00
Sami Kerola
15502d3c97 getdata: fix buffer-overflows reported by address sanitizer
These happen when input configuration or leases files are empty.

==12876==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x61900000a480 at pc 0x000000487442 bp 0x7fffbc3e16b0 sp 0x7fffbc3e0e70
READ of size 1025 at 0x61900000a480 thread T0
    #0 0x487441 in __interceptor_strlen (/home/src/dhcpd-pools/dhcpd-pools+0x487441)
    #1 0x4bbb10 in parse_leases /home/src/dhcpd-pools/src/getdata.c:112:35
    #2 0x4bb337 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:268:2
    #3 0x7f51909bf03f in __libc_start_main (/usr/lib/libc.so.6+0x2003f)
    #4 0x4b9c0c in _start (/home/src/dhcpd-pools/dhcpd-pools+0x4b9c0c)

0x61900000a480 is located 0 bytes to the right of 1024-byte region
[0x61900000a080,0x61900000a480)
allocated by thread T0 here:
    #0 0x49c58b in __interceptor_malloc (/home/src/dhcpd-pools/dhcpd-pools+0x49c58b)
    #1 0x4cbbcd in xmalloc /home/src/dhcpd-pools/lib/xmalloc.c:41:13
    #2 0x4bb801 in parse_leases /home/src/dhcpd-pools/src/getdata.c:96:9
    #3 0x4bb337 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:268:2
    #4 0x7f51909bf03f in __libc_start_main (/usr/lib/libc.so.6+0x2003f)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-24 20:57:57 +01:00
Sami Kerola
74c6ef2566 update kernel.org url in README
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-08-09 19:34:18 +01:00
Sami Kerola
e09f655a7b add appropriate sorting function for struct leases_t
The HASH_SORT in analyze needs this.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-08-09 19:28:23 +01:00
Sami Kerola
965875d20b declare global variables only once
Global variable declarations belong near main, and the header has to have
extern reference to them.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-08-09 19:09:04 +01:00
Sami Kerola
4392a5b917 reindent all files
And update the indent.pro to match with the style I like.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-20 18:05:00 +01:00
Sami Kerola
9090cfb1d7 news: add the note about .sig pgp key id
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-31 18:54:01 +01:00
Sami Kerola
6b267387cc release: 2.25
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-31 18:14:23 +01:00
Sami Kerola
6e680ee04f contrib: add release siging key to contrib/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-31 18:13:21 +01:00
Sami Kerola
502daf8306 build-sys: require automake 1.12 to get working test-driver
With older automake versions one can end up after ./bootstrap with
situation where test-driver script is missing, and subsequent compilation
fails.  Requiring automake 1.12 should usually help, but unfortunately
the case Dennis reported is different.

Something goes wrong with 1.13 and autoconf 2.69, in 32 bit RHEL system.
That sort of system seems to require AM_PROG_CC_C_O, and even when that
is added following error happens.  It is yet unknown to me why this is
the case.

parallel-tests: error: required file 'build-aux/test-driver' not found

Reference: http://git.savannah.gnu.org/cgit/automake.git/tree/NEWS?id=v1.12#n113
Reported-by: Dennis Ortsen <dortsen@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-04-13 21:14:42 +01:00
Sami Kerola
0f66becd57 build-sys: update bootstrap script
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-04-13 20:55:34 +01:00
Sami Kerola
eb55946595 output: use symbolic exit values for nagios commands
And ensure the exit values are set no matter how user will limit output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-24 21:56:34 +00:00
Sami Kerola
5454ab7086 build-sys: update gitinore file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-24 21:38:10 +00:00
Sami Kerola
f3e282f122 output: make nagios output have performance data
Just in case someone wants to graph what is going on.

Reference: http://nagios.sourceforge.net/docs/3_0/pluginapi.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-24 21:34:35 +00:00
Sami Kerola
ca0b1c3262 tests: fix testing error
The commit 7fc354827a introduced an symlink
that end up to update simple test causing it to break.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-17 18:39:47 +00:00
Sami Kerola
d089a19fb5 generic: use pure and const function attributes when possible
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-17 18:25:52 +00:00
Sami Kerola
affb3d70a3 thanks: add Fredrik Lysén & Conor McCarthy
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-08 21:01:21 +00:00
Sami Kerola
6b88e8d872 man: add tip analysis of include files can be useful
Reported-by: Fredrik Lysén <fredrik.lysen@uadm.uu.se>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-08 20:50:26 +00:00
Sami Kerola
7fc354827a getdata: fix consecutive range definition regression
The added test demonstrates the issue.  If a did not end with whitespace
it was skipped.

Reported-by: Fredrik Lysén <fredrik.lysen@uadm.uu.se>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-08 20:30:28 +00:00
Sami Kerola
48caf5fb42 getdata: add missing HAVE_POSIX_FADVISE protection
Reported-by: Conor McCarthy <mr.spuratic@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-08 19:21:19 +00:00
Sami Kerola
631bf0bf7c build-sys: use more strict method to check __builtin_expect
The problem with the detection of gcc's __builtin_expect, the autoconf
set up uses EX_COMPILE_IFELSE which only compiles the test code with gcc
-c, it does not link so a missing __builtin_expect is treated as a
missing symbol and is not detected.

Reported-by: Conor McCarthy <mr.spuratic@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-08 19:19:27 +00:00
Sami Kerola
1eca347196 release: 2.24
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-03 16:53:49 +00:00
Sami Kerola
6379ace9c7 getdata: fix one ip ranges when they have trailing spaces in definition
Ranges that defined single IP and followed each other, for example

range 10.20.30.40 ;
range 10.20.30.41 ;
range 10.20.30.42 ;

were misinterpreted, and every second (the .41 in example) were skipped.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-03 16:52:05 +00:00
Sami Kerola
d2d8abd660 various: fix memory leaks
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-03 14:30:37 +00:00
Sami Kerola
8da98bbc89 various: split functions to IPv4 and IPv6 versions
The code selection will be set with function pointer, which avoids
numerous IP version checks.  As a result with some inputs the analysis
runs quicker.  Most users will not notice much of difference.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-21 12:37:52 +01:00
Sami Kerola
97c6f0292f getdata: split busy function to segments used via function pointer
When it is known IPv4 is in use there is no need to spend time with if
statements checking whether IPv6 is in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-18 00:56:54 +01:00
Sami Kerola
5b8ad97611 getdata: memccpy() is better than own similar function
The memccpy() is maintained in libc so there is no reason to reimplement
similar functionality within this software.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-18 00:05:16 +01:00
Sami Kerola
5189333c95 analyze: remove unnecessary function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-17 22:58:53 +01:00
Sami Kerola
20ec1c2b42 getdata: use correct file caching advice
The POSIX_FADV_NOREUSE is more appropriate considering dhcpd-pools may
need cache, but not necessarily.

Reference: http://lwn.net/Articles/449420/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-10 21:36:46 +01:00
Sami Kerola
7c872ef8d7 build-sys: AC_PROG_CC_C99 is obsolete; use AC_PROG_CC
Reference: http://lists.gnu.org/archive/html/autoconf-commit/2012-10/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-07 16:56:46 +01:00
Sami Kerola
e8f8c04979 build-sys: update gnulib modules
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-07 16:55:31 +01:00
Sami Kerola
47582ed8d8 other: memcmp() is tiny bit quicker than strncmp()
With the large input samples I have use of memcmp makes run to take about
2-3% less time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-09-02 22:21:32 +01:00
Sami Kerola
06ffa5ed04 xstrstr: speed up analysis by avoiding string comparisons
With large input one should see cut 15% for overall run time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-08-31 00:30:28 +01:00
Sami Kerola
d70b08244f thanks: Dan Pritts
For good ideas how to improve alarming.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-12 20:01:20 +01:00
Sami Kerola
3944e289c8 docs: add an example how to use limits with alarming
Proposed-by: Dan Pritts <danno@umich.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-12 19:59:50 +01:00
Sami Kerola
57ddd4f785 tests: test small network alarm ignoring
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-12 19:32:27 +01:00
Sami Kerola
28f1e8c54c output: allow user to ignore small ranges and shared networks
Some have configuration which combines small ranges such as one host, and
greater address ranges that are important to monitor.  Especially the one
host ranges tend to cause a lot of false-positive alarms, as they are
immediately 100% full when a machine requests an address.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-12 19:29:44 +01:00
Sami Kerola
4becf97fb3 docs: inform how the limits affect to printing when alarming is in use
Proposed-by: Dan Pritts <danno@umich.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-11 20:47:09 +01:00
Sami Kerola
978ddeddeb tests: fix tests to use the new OK printing limit
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-11 20:37:55 +01:00
Sami Kerola
9f676f5276 output: allow alarming, in case of success, be silent
This will allow runnign dhcpd with cron, and when nothing is wrong emails
will not be sent.

Proposed-by: Dan Pritts <danno@umich.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-11 20:37:37 +01:00
Sami Kerola
c0e7b50bd3 tests: add alarming tests
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-10 22:42:25 +01:00
Sami Kerola
08c9bcc502 output: make output limits to apply to alarm return values
The earlier behavior made alarming nearly impossible to use for shared
networks only, as they often are expected to be whole lot less full than
ranges.  Unfortunately if a alarm level was exceeded either by range or
shared network the exit value changed.  In most of the cases that lead
alarms to be sent, without sensible message.

Reported-by: Dan Pritts <danno@umich.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-10 22:34:47 +01:00
Sami Kerola
7de719a80c build-sys: update configure.ac
Run autoupdate, and fix few items manually such as prefer AS_CASE rather
than shell case clause.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-06-23 13:07:27 +01:00
Sami Kerola
3f3d447ad8 release: 2.23
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-11 17:41:24 +01:00
Sami Kerola
824a6aec73 build-sys: update bootstrap from gnulib
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-11 17:35:38 +01:00
Sami Kerola
8dba1c749d gnulib: add gnulib modules
Some systems, such as freebsd, does not have program_invocation_short_name
available.  There are also problems finding AF_INET{,6} definitions.

CC: Peter Fraser <p_fraser@hotmail.com>
Reported-by: Ryan Steinmetz <zi@freebsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-05-11 17:09:25 +01:00
Sami Kerola
0002aa57e6 release: 2.22
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-24 22:46:21 +01:00