Commit graph

309 commits

Author SHA1 Message Date
Sami Kerola
d8aef85d01 man: fix character class change
Debian package lint found going back to roman mode was broken.

Reported-by: Martijn van Brummelen <martijn@brumit.nl>
Signed-off-by: Sami Kerola <kerolasa@cloudflare.com>
2015-09-05 13:15:19 +01:00
Sami Kerola
cf26e17fe7 add hint about configure options to README
Proposed-by: Tim Cantin <tcantin@wellesley.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-29 09:18:08 +01:00
Sami Kerola
9d1241c006 improve html output
Remove unnecessary html indentation, so that there is less page content
to transfer.  Right align the network names, and IP's so that they are
easier to read.  And ensure quoting is done correctly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-02 19:40:06 +01:00
Sami Kerola
c4e5ef6198 add xml format check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-02 18:51:39 +01:00
Sami Kerola
0d6c61d437 add touched addresses counts to xml and json reports
For some reason missing information has been overlooked for years.
Perhaps there is aren't that many users who are interested of the touched
addresses.

Proposed-by: Aaron Paetznick <aaronp@critd.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-02 18:48:52 +01:00
Sami Kerola
73b357484d output: remove empty element from xml
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-02 18:00:10 +01:00
Sami Kerola
735c5db817 docs: remove todo items that will never happen
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-04-01 23:15:38 +01:00
Sami Kerola
34dd1dee6e docs: remove very basic git usage info
This is not a git beginner manual project.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-04-01 23:11:28 +01:00
Sami Kerola
c7379e3e25 release: 2.26
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-15 10:03:41 +00:00
Sami Kerola
cfbd69c20b maint: remove unnecessary braces, spaces, update gnulib .gitignore
Improve code readability, and small maintenance.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-15 09:44:28 +00:00
Sami Kerola
33894fba74 other: disallow unsigned counter ever to have minus value
src/other.c:398:4: runtime error: unsigned integer overflow: 0 - 1 cannot
be represented in type 'unsigned int'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-14 21:57:21 +00:00
Sami Kerola
8e076fcc4f output: avoid division by zero
This correction makes the shared networks alarming to work when all
available leases are used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-14 21:54:27 +00:00
Sami Kerola
0705b0c17f tests: add regression test to avoid shared-net off by one alarming issue
This tests ensures the problem fixed by Wolfgang Steudel cannot reoccur.
See the reference commit for details.

Reference: 5519763ba9
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-14 20:13:08 +00:00
Wolfgang Steudel
5519763ba9 alarming: include last shared network in alarming [off by one]
We have defined some shared networks with a couple of address ranges
and wanted to monitor the availability of free IP addresses in the
shared networks.  We were wondering why in some cases there was no
warning, although one shared network's usage was above the threshold.

We found the reason.  In output_alarming() the code was not skipping
"All networks", but missing the last shared network in the list.
Moving "shared_p++" to the beginning of the loop seems to solve the
bug.

Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Wolfgang Steudel <wolfgang.steudel@tu-ilmenau.de>
2014-11-14 19:41:21 +00:00
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