dhcpd-pools/configure.ac
Enno Gröper ae7747db87 analyse: critical bug in the counting code
The problem is, that you simply count all lease occurrences in
dhcpd.leases, but only the last ones for each ip address are
valid.  The lease file is more like a logfile of what has been
done, than a real database.  To fix the counting issue, I'm using
a single hash (from uthash.h [1]) for the counting.  This way
only the last lease entry for each IP gets into my counting
structure.

When you remove the duplicates in prepare_data(), you don't have
the information anymore, if the active lease entry or the free
lease entry came last.  Simply deleting each ip from the touches
array, that is already in the leases array, gives you a big
chance to count wrong.  Another way of fixing this would be to
not only store the ips in your arrays, but a structure containing
the ip and a global lease entry counter.  Then you could delete
all entries except for the latest.

[1] http://uthash.sourceforge.net/

Reported-by: Huangy
Signed-off-by: Enno Gröper <groepeen@cms.hu-berlin.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-02 19:57:45 +02:00

99 lines
2.6 KiB
Text

# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.64)
AC_CONFIG_MACRO_DIR([m4])
AC_INIT([dhcpd-pools],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[kerolasa@iki.fi],,[http://dhcpd-pools.sourceforge.net/])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/dhcpd-pools.h])
AC_CONFIG_HEADERS([config.h])
AC_GNU_SOURCE
# Checks for programs
AC_PROG_AWK
AC_PROG_CC_C99
AC_C_RESTRICT
AC_PROG_CXX
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
# Checks for libraries.
LT_INIT
# Checks for header files.
AC_CHECK_HEADERS([\
arpa/inet.h \
fcntl.h \
langinfo.h \
libintl.h \
netinet/in.h \
stddef.h \
stdlib.h \
string.h \
strings.h \
sys/socket.h \
unistd.h \
])
AC_CHECK_HEADER(uthash.h, [], [AC_MSG_ERROR([Unable to find uthash.h])])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([\
inet_ntoa \
memset \
nl_langinfo \
strdup \
strerror \
strrchr \
strstr \
])
AC_CONFIG_FILES([Makefile
man/Makefile
src/Makefile
contrib/Makefile])
AC_MSG_CHECKING(whether program_invocation_short_name is defined)
AC_TRY_COMPILE([#include <argp.h>],
[program_invocation_short_name = "test";],
AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME, 1,
[Define if program_invocation_short_name is defined])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
AC_MSG_CHECKING([whether __progname is defined])
AC_LINK_IFELSE([AC_LANG_PROGRAM([extern char *__progname;],
[if (*__progname == 0) return;])],
AC_DEFINE(HAVE___PROGNAME, 1, [Define if __progname is defined])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
AC_ARG_WITH(dhcpd-conf,
[AC_HELP_STRING([--with-dhcpd-conf], [default path of dhcpd.conf])],
AC_DEFINE_UNQUOTED(DHCPDCONF_FILE,"$withval"),
AC_DEFINE(DHCPDCONF_FILE,["/etc/dhcpd.conf"],[default path of dhcpd.conf]))
AC_ARG_WITH(dhcpd-leases,
[AC_HELP_STRING([--with-dhcpd-leases], [default path of dhcpd.leases])],
AC_DEFINE_UNQUOTED(DHCPDLEASE_FILE,"$withval"),
AC_DEFINE(DHCPDLEASE_FILE,["/var/lib/dhcp/dhcpd.leases"],[default path of dhcpd.leases]))
AC_ARG_WITH(output-format,
[AC_HELP_STRING([--with-output-format], [default output format])],
AC_DEFINE_UNQUOTED(OUTPUT_FORMAT,"$withval"),
AC_DEFINE(OUTPUT_FORMAT,["text"],[default output format]))
AC_ARG_WITH(output-limit,
[AC_HELP_STRING([--with-output-limit], [default output limitations])],
AC_DEFINE_UNQUOTED(OUTPUT_LIMIT,"$withval"),
AC_DEFINE(OUTPUT_LIMIT,["77"],[default output limitations]))
AC_OUTPUT