Denis Ovsienko [Sun, 12 Feb 2023 11:55:02 +0000 (11:55 +0000)]
Autoconf: Fix formatting of IPv6 results. [skip appveyor]
Output of the IPv6 part of ./configure used to look OK on Linux:
checking whether the operating system supports IPv6... yes
checking ipv6 stack type... linux-glibc
But it was not OK on most other systems, for example, on FreeBSD:
checking whether the operating system supports IPv6... yes
checking ipv6 stack type... checking how to run the C preprocessor... cc
-E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
kame
You do not have inet6 library, using libc
Get the sequence of these messages right. Now on Linux this is:
checking whether the operating system supports IPv6... yes
checking how to run the C preprocessor... gcc -E
checking for egrep... (cached) /usr/bin/grep -E
checking ipv6 stack type... linux-glibc
And on FreeBSD it is:
checking whether the operating system supports IPv6... yes
checking how to run the C preprocessor... cc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking ipv6 stack type... kame
You do not have inet6 library, using libc
Guy Harris [Sun, 12 Feb 2023 10:23:18 +0000 (02:23 -0800)]
configure: don't use egrep, use $EGREP.
POSIX does not require that a system support egrep; it requires that it
support grep -E. In AC_LBL_LIBPCAP, use AC_PROG_EGREP to check for a
command that supports egrep-style expressions, and use $EGREP rather
than egrep in subsequent commands.
This squelches warnings on platforms where egrep prints a warning
suggesting that grep -E be used instead.
It is not clear why the os-proto.h symlink management logic is
conditional on the .devel file, but it is clear that nowadays supported
platforms tend not to need a custom header file. Thus absence of the
file should not generate a warning, also it would be useful to note its
presence. With this in mind, convert the warning into a template
message:
(config.guess prints "x86_64-pc-linux-gnu" on a Linux PC.)
checking whether to use an os-proto.h header... no
(config.guess prints "sparc-sun-solaris2.10" on a Solaris 10 host.)
checking whether to use an os-proto.h header... yes, at
"lbl/os-solaris2.h"
Denis Ovsienko [Sat, 11 Feb 2023 22:17:33 +0000 (22:17 +0000)]
Autoconf: Fix --with-user and --with-chroot. [skip appveyor]
Refine two blocks in configure.ac such that each option correctly
handles both of the Autoconf-supplied values ("yes" and "no") and, when
the option is properly enabled, the message is easier to understand.
See also commit 9aca99a. While at it, use $withval more to unify the
code and squelch the following warnings from Autoconf 2.71:
configure.ac:188: warning: back quotes and double quotes must not be
escaped in: $as_me:${as_lineno-$LINENO}: result: to \"$withval\"
configure.ac:188: warning: back quotes and double quotes must not be
escaped in: to \"$withval\"
configure.ac:198: warning: back quotes and double quotes must not be
escaped in: $as_me:${as_lineno-$LINENO}: result: to \"$withval\"
configure.ac:198: warning: back quotes and double quotes must not be
escaped in: to \"$withval\"
User experience before:
./configure
checking whether to drop root privileges by default... no
checking whether to chroot... no
./configure --with-user=someuser --with-chroot=/some/dir/
checking whether to drop root privileges by default... to "someuser"
checking whether to chroot... to "/some/dir/"
./configure --without-user --without-chroot
checking whether to drop root privileges by default... to "no"
checking whether to chroot... no
./configure --with-user
checking whether to drop root privileges by default... to "yes"
./configure --with-chroot
checking whether to chroot... to "yes"
User experience after:
./configure
checking whether to drop root privileges by default... no
checking whether to chroot... no
./configure --with-user=someuser --with-chroot=/some/dir/
checking whether to drop root privileges by default... yes, to user
"someuser"
checking whether to chroot... yes, to directory "/some/dir/"
./configure --without-user --without-chroot
checking whether to drop root privileges by default... no
checking whether to chroot... no
./configure --with-user
configure: error: --with-user requires a username
./configure --with-chroot
configure: error: --with-chroot requires a directory
Denis Ovsienko [Sat, 11 Feb 2023 19:01:01 +0000 (19:01 +0000)]
NFLOG: Use correct AF code points on all OSes.
On Haiku R1/beta4 "make check" failed the "nglog-e" test case because
the printer did not recognize address family 2 as IPv4:
- 1 18:31:59.615994 version 0, resource ID 20, family IPv4 (2),
+ 1 18:31:59.615994 version 0, resource ID 20, family Unknown (2),
Fix print-nflog.c to use the wire encoding AF code points rather than
the OS libc AF constants. This fixes "make check" on Haiku and likely
fixes IPv6 NFLOG decoding on a few non-Linux OSes.
Denis Ovsienko [Wed, 8 Feb 2023 23:05:58 +0000 (23:05 +0000)]
autoconf: Retire AC_LBL_C_INLINE. [skip appveyor]
In 2002 this macro implemented a workaround for HP C compiler because
the latter did not work with the implementation of AC_C_INLINE in
Autoconf 2.13 (see commit b1263c6). Since then the required kind of
inline very likely became available in every supported compiler of every
supported OS, but just in case there is still an exception, use
AC_C_INLINE from Autoconf 2.69 (or later) and trust it to work right.
In other words, if the original problem still exists, this will have to
be proven.
This squelches one more warning from Autoconf 2.71:
configure.ac:32: warning: The macro `AC_TRY_COMPILE' is obsolete.
Guy Harris [Sun, 5 Feb 2023 21:23:57 +0000 (13:23 -0800)]
Makefile.in: don't remove configure and config.h.in in make distclean.
In the GNU makefile standards, "make distclean" removes everything
that's not part of the source distribution; this does *not* include the
configure script or the config.h.in file, as those are in the release
tarball, so that building from a source tarball doesn't require having
autoconf. This allows somebody building from the source tarball to do a
"make distclean" and then reconfigure.
Do, however, remove any release tarball in make distclean, by having
distclean depend on clean.
Guy Harris [Sun, 5 Feb 2023 20:12:22 +0000 (12:12 -0800)]
tcpdump: plug a memory leak.
If the -V flag is used, and not all files in the -V file have the same
link-layer type, when the filter is recompiled for a new link-layer
type, the old filter program is leaked. Free the old filter before
compiling the new filter.
Guy Harris [Tue, 31 Jan 2023 07:03:16 +0000 (23:03 -0800)]
Have a common routine for converting dates and times to strings.
Have a routine that takes a buffer, a strftime format, and a struct tm *
as arguments, and:
* checks whether the struct tm * is null and, if so, returns a string
indicating that the date and time couldn't be converted;
* otherwise, passes it to strftime(), along with the buffer and the
format argument and, if strftime() returns 0, meaning the string didn't
fit into the buffer and thus that the buffer's contents are undefined,
returns a string indicating that the date and time didn't fit into the
buffer;
* otherwise, returns a pointer to the buffer.
Call that routine instead of directly calling strftime() in printers;
that prevents printing a buffer with undefined data if the buffer isn't
big enough for the string.
Also, when generating file names using an strftime format, check the
return value of strftime() to make sure the buffer didn't overflow.
Francois-Xavier Le Bail [Tue, 31 Jan 2023 10:11:12 +0000 (11:11 +0100)]
autoconf: Add autogen.sh, remove configure and config.h.in
Put autoconf-generated files in the release tarball.
The minimum required version of autoconf is currently 2.69.
If version 2.69 or later is already installed and there is no
autoconf default, it may be necessary to set the AUTORECONF
environment variable to enable the one to use, like:
AUTORECONF=autoreconf-2.69 ./autogen.sh
or
AUTORECONF=autoreconf-2.71 ./autogen.sh
Denis Ovsienko [Tue, 31 Jan 2023 12:38:49 +0000 (12:38 +0000)]
Remove unused missing/snprintf.c. [skip ci]
The file could be compiled on demand using "make snprintf.o", although
with many warnings, but tcpdump build would never use the file
regardless of the variety of the build.
Some of the code there has been commented out since commit 45aef49 in
2001, and the rest became unused after commit 1ed63b5 in 2019.
Guy Harris [Mon, 30 Jan 2023 20:46:44 +0000 (12:46 -0800)]
configure, CMakeLists.txt: don't check for snprintf().
It's specified by the C90 standard (and, as I remember, by the C89
standard, although I no longer have my paper copy); no need to worry
about ancient environments that lack it, and we have some cases where we
call it in code not protected by #ifdef HAVE_STRFTIME/#endif and haven't
seen any reports of problems.
Denis Ovsienko [Fri, 20 Jan 2023 19:35:04 +0000 (19:35 +0000)]
Reduce aclocal.m4 a little bit more. [skip ci]
Remove a copyright boilerplate that stood for IPv6 macros added via
commit c9d84d1 in 1999 and removed via commit 11f73ad in 2015. Remove
AC_LBL_SSLEAY, which is unused and obsolete. This change does not
result in any changes in any other files.
Denis Ovsienko [Thu, 19 Jan 2023 21:26:39 +0000 (21:26 +0000)]
Remove some unused declarations from aclocal.m4. [skip ci]
AC_LBL_FIXINCLUDES, AC_LBL_UNION_WAIT and AC_LBL_HAVE_RUN_PATH have no
purpose in this source tree. AC_LBL_SHLIBS_INIT does not exist. This
change does not introduce meaningful changes in any other files.
Francois-Xavier Le Bail [Mon, 16 Jan 2023 19:05:20 +0000 (20:05 +0100)]
LSP ping: Fix "Unused value" warnings from Coverity
This change should fix the following Coverity Scan issues:
CID 1397795 (#1 of 1): Unused value (UNUSED_VALUE)
assigned_pointer: Assigning value from tlv_tptr + 4UL to tlv_tptr here,
but that stored value is overwritten before it can be used.
CID 1397796 (#1 of 1): Unused value (UNUSED_VALUE)
assigned_value: Assigning value from tlv_tlen - 4UL to tlv_tlen here,
but that stored value is overwritten before it can be used.
Denis Ovsienko [Sat, 14 Jan 2023 22:25:18 +0000 (22:25 +0000)]
Remove init_crc10_table() and the entourage.
As Guy Harris points out in bug report GH #1022, the function has been a
busy no-op since commit e6c39e6 in 2010. While at it, fixup the Python
code to work on Python 3:
for i in range(len(crc_table)/8):
TypeError: 'float' object cannot be interpreted as an integer
Guy Harris [Sat, 14 Jan 2023 11:21:06 +0000 (03:21 -0800)]
configure: check for gethostbyaddr(), not gethostbyname().
We use gethostbyaddr() to translate IP addresses in packets to names; we
don't use gethostbyname() to translate names to IP addresses (libpcap
does the latter when compiling filters, so we leave that up to it, and
nothing's left for us to do).
This probably has the same effect as checking for gethostbyname(), but
it makes it a bit clearer why we'd check for it.
Denis Ovsienko [Sat, 31 Dec 2022 03:04:58 +0000 (03:04 +0000)]
CHANGES: Refine the 4.99.2 section. [skip ci]
List user-visible changes that have been made but did not appear in the
change log. Remove entries that are duplicate (including EIGRP from
4.99.1) or have been superseded by later changes (make releasetar).
Francois-Xavier Le Bail [Wed, 30 Nov 2022 11:05:07 +0000 (12:05 +0100)]
CI: Introduce and use TCPDUMP_CMAKE_TAINTED
The new environment variable provides means to declare all or some libpcap
cmake run of a specific environment (CI or a working copy) as tainted.
Add explicit conditions to exempt the cmake run that emit warnings
now and request the compiler to treat warnings as errors *iff* the cmake
run is not tainted. This way if a cmake run that is warning-free now
degrades later, CI will fail it.
The treat warnings as errors cmake option used is:
-Werror=dev
Make developer warnings errors.
Make warnings that are meant for the author of the CMake-
Lists.txt files errors. By default this will also turn on depre-
cated warnings as errors.
Francois-Xavier Le Bail [Fri, 25 Nov 2022 14:49:52 +0000 (15:49 +0100)]
cmake: Update the minimum required version to 2.8.12 (except Windows)
Windows minimum required is already 3.12.
This change avoids this warning:
CMake Deprecation Warning at CMakeLists.txt:7 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
Francois-Xavier Le Bail [Mon, 31 Oct 2022 16:20:18 +0000 (17:20 +0100)]
Remove the release candidate rcX targets
These tricky targets used "autoreconf -f" (via "make releasetar") and
they changed the VERSION and configure files locally.
If building a release candidate tar archive is needed, it's better to:
Update VERSION with rcX suffix and configure via "autoreconf -f",
commit them, add a tag and build the archive via "make releasetar".
It should display: Archive build from tag tcpdump-...rcX.
Note: the "autoreconf -f" command changes the configure file in an
uncontrolled way (runstatedir, #define LARGE_OFF_T, etc.) depending on
the autoconf version.
It is necessary to choose the parts that will be added in the commit
with "git add -i".
Francois-Xavier Le Bail [Fri, 28 Oct 2022 16:34:55 +0000 (18:34 +0200)]
Use "git archive" for the "make releasetar" process
Use the release tag if it exists or use HEAD.
Remove the "autoreconf -f" command, because it changes the configure file
locally in an uncontrolled way (runstatedir, #define LARGE_OFF_T, etc.)
depending on the autoconf version. This command is run in the release
process before a commit and we can choose the parts that will be added
in the commit.
Note:
The following target (rcX) must be updated ou removed in a next step
because it was using "autoreconf -f" (via "make releasetar") and it
changes the VERSION and configure files locally.
This change
1) Ensures that we only release files from tag/HEAD, not locally
modified ones.
2) Avoids disclosing personal data such as the username/group of the
local user.
3) Puts by default a umask of 0002, which turns off the world write bit
on files in the archive.
4) Avoids problems on some OSes (no more tar, Git builtin tar.gz
handling).
Guy Harris [Fri, 30 Sep 2022 23:29:34 +0000 (16:29 -0700)]
configure: use pcap-config --static-pcap-only if available.
If we're linking with a libpcap in ../libpcap*, it's static, but we only
need to link with the libraries on wich it immediately depends, we don't
need to link with the libraries on which those libraries depend, etc..
So, if ../libpcap*/pcap-config supports --static-pcap-only, use that.