02d9774
Name:           arpwatch
02d9774
Epoch:          14
f39649e
Version:        3.6
0888dc1
Release:        %autorelease
02d9774
Summary:        Network monitoring tools for tracking IP addresses on a network
02d9774
ae1d7fe
# SPDX matching with BSD-3-Clause confirmed at
ae1d7fe
# https://gitlab.com/fedora/legal/fedora-license-data/-/issues/49
ae1d7fe
#
ae1d7fe
# Any files under different licenses are part of the build system and do not
ae1d7fe
# contribute to the license of the binary RPM:
ae1d7fe
#   - config.guess and config.sub are GPL-3.0-or-later
ae1d7fe
#   - configure is FSFULL
ae1d7fe
#   - install-sh is X11
ae1d7fe
#   - mkdep is ??? (NTP-like)
ae1d7fe
License:        BSD-3-Clause
b66474e
URL:            https://ee.lbl.gov/
02d9774
1a6180f
Requires(pre):  shadow-utils
02d9774
9c99645
Requires:       /usr/sbin/sendmail
9f4ad01
Requires:       python3
02d9774
Igor Gnatenko 5ac988f
BuildRequires:  gcc
2ecbad6
BuildRequires:  make
9c99645
BuildRequires:  /usr/sbin/sendmail
1a6180f
BuildRequires:  systemd-rpm-macros
c0a7e9d
%{?sysuser_requires_compat}
54b9fdd
BuildRequires:  python3-devel
9f4ad01
BuildRequires:  libpcap-devel
6ced790
b66474e
# Note that https://ee.lbl.gov/ may not link to the latest version; the
b66474e
# directory listing at https://ee.lbl.gov/downloads/arpwatch/ shows all
b66474e
# available versions.
0411a6f
Source0:        https://ee.lbl.gov/downloads/arpwatch/arpwatch-%{version}.tar.gz
734a120
# This file comes from https://standards-oui.ieee.org/oui/oui.csv; it is used
734a120
# to generate ethercodes.dat. Because it is unversioned (and frequently
734a120
# updated), we store the file directly in the repository with the spec file;
734a120
# see the update-oui-csv script.
9f4ad01
#
cec1869
# File oui.csv last fetched 2024-03-28T13:35:28+00:00.
9f4ad01
Source1:        oui.csv
0411a6f
Source2:        arpwatch.service
0411a6f
Source3:        arpwatch.sysconfig
9f4ad01
Source4:        arp2ethers.8
9f4ad01
Source5:        massagevendor.8
c0a7e9d
Source6:        arpwatch.sysusers
9f4ad01
a56fca0
# The latest versions of all “arpwatch-3.1-*” patches were sent upstream by
a56fca0
# email 2021-04-24.
1801766
9f4ad01
# Fix section numbers in man page cross-references. With minor changes, this
9f4ad01
# patch dates all the way back to arpwatch-2.1a4-man.patch, from RHBZ #15442.
a56fca0
Patch:          arpwatch-3.1-man-references.patch
9f4ad01
# Add, and document, a -u argument to change to a specified unprivileged user
9f4ad01
# after establishing sockets. This combines and improves multiple previous
9f4ad01
# patches; see patch header and changelog for notes.
a56fca0
Patch:          arpwatch-3.2-change-user.patch
9f4ad01
# Fix nonstandard sort flags in arp2ethers script.
a56fca0
Patch:          arpwatch-3.1-arp2ethers-sort-invocation.patch
9f4ad01
# Fix stray rm (of an undefined variable) in example arpfetch script.
a56fca0
Patch:          arpwatch-3.1-arpfetch-stray-rm.patch
9f4ad01
# Do not add /usr/local/bin or /usr/local/sbin to the PATH in any scripts
a56fca0
Patch:          arpwatch-3.2-no-usr-local-path.patch
0411a6f
# Do not attempt to search for local libpcap libraries lying around in the
0411a6f
# parent of the build directory, or anywhere else random. This is not expected
0411a6f
# to succeed anyway, but it is better to be sure.
a56fca0
Patch:          arpwatch-3.1-configure-no-local-pcap.patch
9f4ad01
# RHBZ #244606: Correctly handle -n 0/32 to allow the user to disable reporting
9f4ad01
# bogons from 0.0.0.0.
a56fca0
Patch:          arpwatch-3.1-all-zero-bogon.patch
9f4ad01
# When arpwatch is terminated cleanly by a signal (INT/TERM/HUP) handler, the
9f4ad01
# exit code should be zero for success instead of nonzero for failure.
695a404
Patch:          arpwatch-3.5-exitcode.patch
9f4ad01
# When -i is not given, do not just try the first device found, but keep
9f4ad01
# checking devices until a usable one is found, if any is available.
9f4ad01
# Additionally, handle the case where a device provides both supported and
9f4ad01
# unsupported datalink types.
695a404
Patch:          arpwatch-3.5-devlookup.patch
6ced790
2e89479
# Replace _getshort(), “a glibc function that hasn't been declared in the
2e89479
# installed headers for many, many years,” with ns_get16(). Fixes C99
2e89479
# compatibility (https://bugzilla.redhat.com/show_bug.cgi?id=2166336). Sent
2e89479
# upstream by email 2023-02-01.
2e89479
Patch:          arpwatch-3.3-c99.patch
2e89479
6635277
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
6635277
ExcludeArch:    %{ix86}
6635277
0411a6f
%global pkgstatedir %{_sharedstatedir}/arpwatch
b544fb0
6ced790
%description
0411a6f
The arpwatch package contains arpwatch and arpsnmp. Arpwatch and arpsnmp are
02d9774
both network monitoring tools. Both utilities monitor Ethernet or FDDI network
02d9774
traffic and build databases of Ethernet/IP address pairs, and can report
02d9774
certain changes via email.
02d9774
0411a6f
Install the arpwatch package if you need networking monitoring devices which
02d9774
will automatically keep track of the IP addresses on your network.
6ced790
6ced790
6ced790
%prep
5e0c38e
%autosetup -p1
6ced790
d5977a8
# Substitute absolute paths to awk scripts in shell scripts
0411a6f
sed -r -i 's|(-f *)([^[:blank:]+]\.awk)|\1%{_datadir}/arpwatch/\2|' arp2ethers
9f4ad01
9f4ad01
# Fix default directory in man pages to match ARPDIR in build section. This was
9f4ad01
# formerly done by arpwatch-dir-man.patch. For thoroughness, do the same
9f4ad01
# replacement in update-ethercodes.sh.in and bihourly.sh, even though they are
9f4ad01
# not installed.
9f4ad01
sed -r -i 's|/usr/local/arpwatch|%{pkgstatedir}|g' *.8.in *.sh.in *.sh
d5977a8
854a670
# Fix Python interpreter path (but note that this script is not installed)
854a670
sed -r -i 's|/usr/local/bin/python|%{python3}|g' update-ethercodes.sh.in
854a670
aba0dcc
# Emailed upstream requesting a separate LICENSE/COPYING file 2022-07-30.
aba0dcc
# For now, we extract it from the main source file’s “header” comment.
aba0dcc
awk '/^ \* / { print substr($0, 4); } /^ \*\// { exit }' arpwatch.c |
aba0dcc
  tee LICENSE
aba0dcc
02d9774
6ced790
%build
6f71ee9
%set_build_flags
6f71ee9
# Prior to version 3.4, this was handled by the configure script. If it is not
6f71ee9
# defined, the build failes because time.h is not included in report.c. This
6f71ee9
# regregression was reported upstream by email to arpwatch@ee.lbl.gov on
6f71ee9
# 2023-09-06.
6f71ee9
export CPPFLAGS="${CPPFLAGS-} -DTIME_WITH_SYS_TIME=1"
6f71ee9
854a670
%configure --with-sendmail=/usr/sbin/sendmail PYTHON=%{python3}
c960f8f
%make_build ARPDIR=%{pkgstatedir}
6ced790
6ced790
02d9774
%install
c0a7e9d
install -p -D -m 0644 %{SOURCE6} '%{buildroot}%{_sysusersdir}/arpwatch.conf'
c0a7e9d
9f4ad01
# The upstream Makefile does not create the directories it requires, so we must
9f4ad01
# do it manually. Additionally, it attempts to comment out the installation of
9f4ad01
# the init script on non-FreeBSD platforms, but this does not quite work as
2c3ce15
# intended. We just let it install the file, then remove it afterwards.
9f4ad01
install -d %{buildroot}%{_mandir}/man8 \
9e1fb1c
    %{buildroot}%{_sbindir} \
0411a6f
    %{buildroot}%{_datadir}/arpwatch \
9e1fb1c
    %{buildroot}%{pkgstatedir} \
9f4ad01
    %{buildroot}%{_unitdir} \
9f4ad01
    %{buildroot}%{_prefix}/etc/rc.d
9e1fb1c
9f4ad01
%make_install
6ced790
0411a6f
install -p -t %{buildroot}%{_datadir}/arpwatch -m 0644 *.awk
9f4ad01
install -p -t %{buildroot}%{_sbindir} arp2ethers
9f4ad01
install -p massagevendor.py %{buildroot}%{_sbindir}/massagevendor
6ced790
9f4ad01
install -p -t %{buildroot}%{pkgstatedir} -m 0644 *.dat
fbb9cdd
touch %{buildroot}%{pkgstatedir}/arp.dat- \
fbb9cdd
    %{buildroot}%{pkgstatedir}/arp.dat.new
9e1fb1c
9f4ad01
install -p -t %{buildroot}%{_unitdir} -m 0644 %{SOURCE2}
8042297
%{python3} massagevendor.py < %{SOURCE1} \
9f4ad01
    > %{buildroot}%{pkgstatedir}/ethercodes.dat
9f4ad01
touch -r %{SOURCE1} ethercodes.dat
9f4ad01
9f4ad01
# Add an environment/sysconfig file:
9f4ad01
install -d %{buildroot}%{_sysconfdir}/sysconfig
0411a6f
install -p -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/sysconfig/arpwatch
9f4ad01
9f4ad01
# Add extra man pages not provided upstream:
9f4ad01
install -p -t %{buildroot}%{_mandir}/man8 -m 0644 %{SOURCE4} %{SOURCE5}
9f4ad01
2c3ce15
# Remove legacy init scripts:
2c3ce15
rm -rvf %{buildroot}%{_prefix}/etc/rc.d
2c3ce15
9f4ad01
9f4ad01
%check
9f4ad01
# Verify the sed script in the prep section did not miss fixing the ARPDIR
9f4ad01
# anywhere
9f4ad01
if grep -FrnI '/usr/local/arpwatch' .
9f4ad01
then
9f4ad01
  echo 'Missed fixing ARPDIR in at least one file' 1>&2
9f4ad01
  exit 1
9f4ad01
fi
9f4ad01
0411a6f
# Verify we did not miss any PATH alterations in
0411a6f
# arpwatch-no-usr-local-path.patch.
9f4ad01
if grep -ErnI --exclude=mkdep --exclude='config.*' '^[^#].*/usr/local/s?bin' .
9f4ad01
then
9f4ad01
  echo 'Probably missed an uncommented PATH alteration with /usr/local' 1>&2
9f4ad01
  exit 1
9f4ad01
fi
6ced790
02d9774
6ced790
%post
0411a6f
%systemd_post arpwatch.service
6ced790
02d9774
6ced790
%pre
c0a7e9d
%sysusers_create_compat %{SOURCE6}
6ced790
02d9774
6ced790
%postun
0411a6f
%systemd_postun_with_restart arpwatch.service
6ced790
02d9774
6ced790
%preun
0411a6f
%systemd_preun arpwatch.service
6ced790
02d9774
6ced790
%files
aba0dcc
%license LICENSE
02d9774
%doc README
02d9774
%doc CHANGES
02d9774
%doc arpfetch
9f4ad01
9f4ad01
# make install uses mode 0555, which is unconventional
9f4ad01
%attr(0755,-,-) %{_sbindir}/arpwatch
9f4ad01
%attr(0755,-,-) %{_sbindir}/arpsnmp
9f4ad01
# manually-installed scripts
6ced790
%{_sbindir}/arp2ethers
6ced790
%{_sbindir}/massagevendor
9f4ad01
0411a6f
%dir %{_datadir}/arpwatch
0411a6f
%{_datadir}/arpwatch/*.awk
9f4ad01
9f4ad01
# make install uses mode 0444, which is unconventional
9f4ad01
%attr(0644,-,-) %{_mandir}/man8/*.8*
9f4ad01
0411a6f
%{_unitdir}/arpwatch.service
c0a7e9d
%{_sysusersdir}/arpwatch.conf
0411a6f
%config(noreplace) %{_sysconfdir}/sysconfig/arpwatch
9f4ad01
c0a7e9d
%attr(1775,-,arpwatch) %dir %{pkgstatedir}
c0a7e9d
%attr(0644,arpwatch,arpwatch) %verify(not md5 size mtime) %config(noreplace) %{pkgstatedir}/arp.dat
c0a7e9d
%attr(0644,arpwatch,arpwatch) %verify(not md5 size mtime) %config(noreplace) %{pkgstatedir}/arp.dat-
c0a7e9d
%attr(0600,arpwatch,arpwatch) %verify(not md5 size mtime) %ghost %{pkgstatedir}/arp.dat.new
c0a7e9d
%attr(0644,-,arpwatch) %verify(not md5 size mtime) %config(noreplace) %{pkgstatedir}/ethercodes.dat
6ced790
02d9774
6ced790
%changelog
0888dc1
%autochangelog