Not all markups were quite right. The output_* functions must return an
int. The rest were as a matter of fact correct.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This make the table output good looking, and allows users to click table
headings to sort data by column without rerunning the analysis.
Unfortunately this change is breaking change, meaning the old CSS tags are
no longer supported, nor partial html output that printed only the table.
Proposed-by: Aaron Paetznick <aaronp@critd.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Alarm criteria based solely on percentage was found to be difficult to be
tricky to setup in environments that has small ranges and big shared-nets
mixed up together. These two new options should help making alarming more
useful.
Requested-by: Frank Bulk <fbulk@mypremieronline.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Some users may not want to have alarms about ranges that are part of a
shared-network, so allow them to suppress such.
Requested-by: Frank Bulk <fbulk@mypremieronline.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
src/getdata.c:248:22: warning: 'range_p' may be used uninitialized in this
function [-Wmaybe-uninitialized]
src/other.c:383:1: warning: control reaches end of non-void function
[-Wreturn-type]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use error(3) function, that has gnulib portability fixes, instead of err(3)
and warn(3) family.
Reported-by: Anton Tkachev <antont@bk.ru>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
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>
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>
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>
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>
==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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
For reasons see excellent paper 'Recursive Make Considered Harmful' by
Peter Miller.
References: http://miller.emu.id.au/pmiller/books/rmch/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The dhcpd.conf can contain single IP range definitions, such as
range 10.20.30.40;
and they must be understood similar way as the range definiton would have
two IP's that are the same IP, e.g.,
range 10.20.30.40 10.20.30.40;
Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The commit 805d353584 did not fix all
possible problem cases. This commit attempts to address remaining
issues.
Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When dhcpd.conf file got to be parsed such way that IP version could not
be determined the dhcpd.lease file parsing resulted to SIGSEGV.
Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Helmut reported run of 'make check' failing in debian pbuilder
environment. The posix_fadvise() functions were failing with a message
such as
dhcpd-pools: parse_config: fadvise ../tests/confs/complete: Cannot allocate memory
which to me is likely error in how an error is determined. Relying on
errno value not being mangled by libc is unreliable. Attempt to fix this
is simple, check return values of these function calls and ignore the
errno.
Reported-by: Helmut Grohne <h.grohne@cygnusnetworks.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
[src/dhcpd-pools.c:68]: (style) The scope of the variable 'c' can be reduced.
[src/getdata.c:210]: (style) The scope of the variable 'c' can be reduced.
[src/hash.c:102]: (style) The scope of the variable 'l' can be reduced.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This will fix eight warnings similar to the example below.
sort.c:104:5: warning: no previous declaration for 'comp_ip' [-Wmissing-declarations]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The prof. Xing Li in Tsinghua University, with LI Zimu, asked Cheer to
make the dhcpd-pools more usable for them which I, as a project
maintainer, could not be more pleased. Whils making the IPv6 analysis to
work Cheer also fixed various other issues. Kudos to him, and big thanks
to everyone.
CC: Xing Li <xing@cernet.edu.cn>
CC: LI Zimu <lzm@cernet.edu.cn>
CC: Cheer Xiao <xiaqqaix@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>