%define arpwatch_ver	2.1a15
%define	_vararpwatch	%{_localstatedir}/arpwatch
%define PCAP_UID 77
%define PCAP_GID 77

Summary: Network monitoring tools for tracking IP addresses on a network.
Summary(ja): ネットワークの IP アドレスを追跡する監視ツール
Name: arpwatch
Version: %{arpwatch_ver}
Release: 0vl1
Epoch: 1
License: BSD
Group: Applications/System

Source0: ftp://ftp.ee.lbl.gov/arpwatch-%{version}.tar.gz
Source3: arpwatch.init
Source5: arpwatch.sysconfig
Source6: arpwatch-ethercodes.dat 

Patch1: arpwatch-2.1a4-fhs.patch
Patch2: arpwatch-2.1a10-man.patch
Patch3: arpwatch-drop.patch
Patch4: arpwatch-drop-man.patch
Patch5: arp2ethers.patch
Patch6: arpwatch-addr.patch

BuildRequires: autoconf automake libpcap
Requires(post): chkconfig
Requires(postun): initscripts
Requires(pre): shadow-utils
Requires(preun): chkconfig initscripts
BuildRoot: %{_tmppath}/%{name}-%{version}-root

Vendor: Project Vine
Distribution: Vine Linux


%description
The arpwatch package contains arpwatch and arpsnmp. Arpwatch and
arpsnmp are both network monitoring tools. Both utilities monitor
Ethernet or FDDI network traffic and build databases of Ethernet/IP
address pairs, and can report certain changes via email.

Install the arpwatch package if you need networking monitoring devices
which will automatically keep track of the IP addresses on your
network.

%description -l ja
arpwatch パッケージには arpwatch と arpsnmp が含まれます。これらは
ネットワークの監視ツールです。これらのユーティリティはイーサネットや
FDDI ネットワークのトラフィックを監視し、イーサネットアドレスと IP
アドレスとの対応のデータベースを構築し、変化があったらメールで通知
することができます。

ネットワーク上の IP アドレスの変化を自動的に保持するようなデバイスを
監視したい場合、arpwatch パッケージをインストールして下さい。


%prep
%setup -q

%patch1 -p1 -b .fhs
%patch2 -p1 -b .arpsnmpman
%patch3 -p1 -b .droproot
%patch4 -p0 -b .droprootman
#patch5 -p1 -b .arp2ether
%patch6 -p1 -b .addr
chmod u+w ethercodes.dat
cp %SOURCE6 ethercodes.dat


%build
aclocal
autoconf
CFLAGS="$CFLAGS -I/usr/include/pcap" %configure
make ARPDIR=%{_vararpwatch}


%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{_libdir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man{3,8}
mkdir -p ${RPM_BUILD_ROOT}%{_sbindir}

make DESTDIR=${RPM_BUILD_ROOT} install install-man
mkdir -p ${RPM_BUILD_ROOT}%{_vararpwatch}
for n in arp2ethers arpfetch massagevendor massagevendor-old; do
	install -m755 $n ${RPM_BUILD_ROOT}%{_vararpwatch}
done
for n in *.awk *.dat; do
	install -m644 $n ${RPM_BUILD_ROOT}%{_vararpwatch}
#for n in *.awk *.dat missingcodes.txt; do
#	install -m644 $n ${RPM_BUILD_ROOT}%{_vararpwatch}
done
( cd ${RPM_BUILD_ROOT}
  mkdir -p .%{_initdir}
  install -c -m755 $RPM_SOURCE_DIR/arpwatch.init .%{_initdir}/arpwatch
  mkdir -p .%{_sysconfdir}/sysconfig
  install -c -m644 $RPM_SOURCE_DIR/arpwatch.sysconfig .%{_sysconfdir}/sysconfig/arpwatch
)


%clean
rm -rf ${RPM_BUILD_ROOT}

%post
/sbin/chkconfig --add arpwatch

%pre
/usr/sbin/groupadd -g %{PCAP_GID} pcap  2> /dev/null || :  
/usr/sbin/useradd -u %{PCAP_UID} -g %{PCAP_GID} \
        -s /bin/nologin -M -r -d %{_vararpwatch} pcap 2> /dev/null || :

%postun
if [ "$1" -ge "1" ]; then
  /sbin/service arpwatch condrestart >/dev/null 2>&1
fi

%preun
if [ $1 = 0 ]; then
	/sbin/service arpwatch stop > /dev/null 2>&1
	/sbin/chkconfig --del arpwatch
fi


%files
%defattr(-,root,root)
%doc README CHANGES
%{_sbindir}/arpwatch
%{_sbindir}/arpsnmp
%{_mandir}/man8/arpwatch.8*
%{_mandir}/man8/arpsnmp.8*
%config	%{_initdir}/arpwatch
%config(noreplace) %{_sysconfdir}/sysconfig/arpwatch
%defattr(-,pcap,pcap)
%dir	%{_vararpwatch}
%config	%{_vararpwatch}/arp.dat
%config	%{_vararpwatch}/ethercodes.dat
#config	%{_vararpwatch}/missingcodes.txt
%{_vararpwatch}/*.awk
%{_vararpwatch}/arp2ethers
%{_vararpwatch}/arpfetch
%{_vararpwatch}/massagevendor
%{_vararpwatch}/massagevendor-old

%changelog
* Sun Sep  2 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1:2.1a15-0vl1
- s/Serial/Epoch/
- s/Copyright/License/
- updated to 2.1a15
- dropped Patch5 (merged into new upstream)

* Fri Feb 21 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 1:2.1a11-13vl3
- arpwatch standalone package splitted from tcpdump.
- merge 2.1a11-9vl2 changes
  * Thu May 21 2002 Seiya Nishizawa <seiya@kugi.kyoto-u.ac.jp> 3.6.2-9vl2
    change arpwatch.init to use /etc/sysconfig/arpwatch

* Fri Feb 21 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 1:3.7.1-0vl1
- update to new upstream release tcpdump 3.7.1
- drop unneeded patches
- use autoconf213, automake14
- split arpwatch from tcpdump package

* Fri Feb 21 2003 Daisuke SUZUKI <daisuke@linux.or.jp> 1:3.6.2-13vl2
- add patch16 to fix  print_bgp security bug
  - errata 20030221-3

* Wed Jun 12 2002 Daisuke SUZUKI <daisuke@linux.or.jp> 1:3.6.2-13vl1
- merged with 3.6.2-13
- fix buffer overflow for errata
  * Thu May 16 2002 Harald Hoyer <harald@redhat.de> 12:3.6.2-13
  - added official 3.6.3 fix
  - fixed 6.2 compat #63113
  * Wed Jan 23 2002 Harald Hoyer <harald@redhat.de> 12:3.6.2-12
  - tcpdump-3.6.2-snaplen.patch added to fix #55145
  * Tue Dec 18 2001 Harald Hoyer <harald@redhat.de> 12:3.6.2-10
  - took old purge patch for filters
  - fixed #54225,#58346
  - drop root by default #49635
  - fixed #54593
  - fixed #57711

* Thu Oct 25 2001 IWAI Masaharu <iwaim@cc.mbn.or.jp>
- 3.6.2-9vl1
- used PRM macros
- changed File Name to Package Name in Prereq tag
- marged 3.6.2-9 (RedHat7.2)

  * Tue Jan 23 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
  - 3.4-19vl2
  - use better macros
  
  * Thu Sep 21 2000 Yoshihiro Kajiki <kajiki@ylug.org>
  - add libpcap-0.4-guy-gerald.patch to fix the timeout problem (by Ethereal)
  - add Japanese summarys and descriptions
  - modify spec file to build as a normal user
  
  * Thu Feb 17 2000 Bernhard Rosenkraenzer <bero@redhat.com>
  - Compile shared libpcap with -fPIC (Bug #6342)
  
  * Wed Feb 02 2000 Cristian Gafton <gafton@redhat.com>
  - fix descriptions
  - man pages are compressed
  
  * Wed Dec 22 1999 Jeff Johnson <jbj@redhat.com>
  - remove sparc64 SIOCGIFNAME hack, not needed with (at least) kernel 2.2.12-40.
  - upgrade to ANK ss991030 snapshot with pcap magic fix (#6773).
  - add getprotobyname lookup (#6725).
  - getservbyname port lookup appears functional (#7569).
  - remove uid 2090 backdoor (sorry Dave) (#7116).
  
  * Thu Sep 09 1999 Cristian Gafton <gafton@redhat.com>
  - fox the pcap.h header
  
  * Fri Aug 20 1999 Jeff Johnson <jbj@redhat.com>
  - prevent segfault on obscure spoofed ip header (#4634).
  
  * Wed Aug 18 1999 Jeff Johnson <jbj@redhat.com>
  - add defattr to arpwatch (#4591).
  
  * Mon Aug 16 1999 Bill Nottingham <notting@redhat.com>
  - initscript munging

  * Sun Aug  8 1999 Jeff Johnson <jbj@redhat.com>
  - add -DWORDS_BIGINDIAN to tcpdump compile on sparc sparc61.
  
  * Tue Aug  3 1999 Jeff Johnson <jbj@redhat.com>
  - include A. Kuznetsov's patches to libpcap/tcpdump.
  - added arpsnmp to package (#3258).
  - arp2ethers written for different of awk (#4326).

  * Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
  - auto rebuild in the new build environment (release 10)

  * Fri Mar 19 1999 Jeff Johnson <jbj@redhat.com>
  - strip binaries.
  
  * Wed Jan 13 1999 Bill Nottingham <notting@redhat.com>
  - autoconf fixes for arm

  * Tue Sep 29 1998 Jeff Johnson <jbj@redhat.com>
  - libpcap description typo.

  * Sat Sep 19 1998 Jeff Johnson <jbj@redhat.com>
  - fix arpwatch summary line.
  
  * Mon Aug 17 1998 Jeff Johnson <jbj@redhat.com>
  - enable arpwatch
  
  * Mon Aug  3 1998 Jeff Johnson <jbj@redhat.com>
  - separate package for libpcap.
  - update tcpdump to 3.4, libpcap to 0.4.
  - added arpwatch (but disabled for now)
  
  * Thu May 07 1998 Prospector System <bugs@redhat.com>
  - translations modified for de, fr, tr
  
  * Sat May  2 1998 Alan Cox <alan@rehat.com>
  - Added the SACK printing fix so you can dump Linux 2.1+.
  
  * Tue Oct 21 1997 Erik Troan <ewt@redhat.com>
  - updated to release 3.4a5
  - uses a buildroot and %attr 
  
  * Thu Jul 17 1997 Erik Troan <ewt@redhat.com>
  - built against glibc

* Fri Aug 31 2001 Harald Hoyer <harald@redhat.de> 12:3.6.2-9
- took better fix for #52654 from tcpdump cvs

* Thu Aug 30 2001 Harald Hoyer <harald@redhat.de> 11:3.6.2-8
- fixed #52654

* Thu Jul 19 2001 Harald Hoyer <harald@redhat.de> 10:3.6.2-7
- added shared library to libpcap (#47174)
- afs printing security patch (#49294)

* Wed Jun 20 2001 Harald Hoyer <harald@redhat.de>
- use initgroups, instead of setgroups

* Mon Jun 18 2001 Harald Hoyer <harald@redhat.de>
- added dropgroup patches (#44563)

* Mon May 07 2001 Harald Hoyer <harald@redhat.de>
- switched to Pekka's tcpdump-3.6.2 package
- incremented epoch

* Sat Apr 14 2001 Pekka Savola <pekkas@netcore.fi>
- fix building of tcpslice on glibc 2.2.2 (time.h)
- disable /etc/init.d requirement and fix %post scripts in arpwatch

* Wed Feb 14 2001 Harald Hoyer <harald@redhat.de>
- glibc sys/time -> time include patch

* Wed Feb  7 2001 Trond Eivind Glomsr <teg@redhat.com>
- Add space to this check

* Wed Feb 07 2001 Harald Hoyer <harald@redhat.com>
- added check for presence of /etc/sysconfig/arpwatch (#23172)

* Wed Feb  7 2001 Pekka Savola <pekkas@netcore.fi>
- update to 3.6.2, 0.6.2 and new CVS of tcpslice.
- i18n'ize arpwatch init script

* Fri Feb  2 2001 Trond Eivind Glomsr <teg@redhat.com>
- i18nize initscript

* Mon Jan 29 2001 Harald Hoyer <harald@redhat.com>
- fixed EINTR stopping for e.g. SIGSTOP. (#22008)
- added -u option for tcpdump (#20231)
- new arpwatch version (#23172)
- added "all" and "one" interface for -i (#20907)
- added arpwatch sysconfig (#23172)

* Mon Jan 22 2001 Harald Hoyer <harald@redhat.com>
- more (potential) overflows in libpcap. #21373
- documentation fix for #20906

* Sun Jan 14 2001 Pekka Savola <pekkas@netcore.fi>
- use --enable-ipv6
- Add two patches from CVS to enhance 802.2 printing, and more importantly,
  to be able to specify 'no stp'

* Sat Jan 13 2001 Pekka Savola <pekkas@netcore.fi>
- Make SMB printing output a lot more quiet unless in verbose mode.
- Make -n resolve port/protocol numbers but not hostnames, -nn for no
  resolving at all
- Separate droproot patch from a more generic man/usage fix one
- Add non-promiscuous mode -by default patch, but don't apply it by default

* Thu Jan 11 2001 Pekka Savola <pekkas@netcore.fi>
- Update to tcpdump 3.6.1 and libpcap 0.6.1 releases.

* Mon Jan  8 2001 Pekka Savola <pekkas@netcore.fi>
- Update to 20010108 CVS, disable some upstreamed patches.
- Change some additional .1 pages to .8.
- Add droproot patch, some --usage and man page fixes.

* Mon Jan  1 2001 Pekka Savola <pekkas@netcore.fi>
- Initial packaging with latest tcpdump.org CVS tcpdump-3.6 and libpcap-0.6.
- add earlier print-domain.c, the latest is segfaulting
- don't unnecesessarily include snprintf.o, it didn't compile with gcc 2.96 anyway
- don't use savestr, require openssl, tweak tweak tweak
- add tcpslice, patch it a bit for egcs detection

* Sun Dec 31 2000 Pekka Savola <pekkas@netcore.fi>
- tcpdump: spice up the manpage about interfaces
- tcpdump: add 'all' and 'any' keywords to -i, saner default behaviour.
- upgrade arpwatch to 2.1a10

* Sun Nov 26 2000 Jeff Johnson <jbj@redhat.com>
- more (potential) overflows in libpcap.

* Sun Nov 12 2000 Jeff Johnson <jbj@redhat.com>
- eliminate still more buffer overflows (from FreeBSD) (#20069).

* Thu Nov  2 2000 Jeff Johnson <jbj@redhat.com>
- eliminate more buffer overflows (from FreeBSD) (#20069).
- 802.1q ether type incorrect (#19850).
- add -u flag to drop arpwatch privs (#19696).

* Sun Oct 15 2000 Jeff Johnson <jbj@redhat.com>
- updated ethercodes.dat

* Thu Oct 12 2000 Jeff Johnson <jbj@redhat.com>
- fix arpwatch tmp race (#18943).

* Fri Aug 11 2000 Bill Nottingham <notting@redhat.com>
- fix condrestart

* Fri Aug 11 2000 Jeff Johnson <jbj@redhat.com>
- correct arpsnmp man pages (#15442).
- don't print harmless ENOPROTOOPT message (#13518).

* Fri Aug  4 2000 Jeff Johnson <jbj@redhat.com>
- rebuild with final kernel headers (#13518).

* Sat Jul 22 2000 Jeff Johnson <jbj@redhat.com>
- add STP patch (#14112).

* Fri Jul 14 2000 Matt Wilson <msw@redhat.com>
- source /etc/init.d/functions
- back out /etc/init.d/arpwatch, place file in /etc/rc.d
- move initscript to /etc/init.d
- changed initscript to use start() and stop() functions
- added condrestart to init script
- added %%post %%preun %%postun scripts to register arpwatch script
- added Prereq: for all things needed in post/preun/postun

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Tue Jul 11 2000 Jeff Johnson <jbj@redhat.com>
- updated man page and help (pekkas@netcore.fi) (#10739 et al).

* Sun Jun 18 2000 Jeff Johnson <jbj@redhat/com>
- FHS packaging.

* Tue May  9 2000 Bill Nottingham <notting@redhat.com>
- minor tweaks for ia64 (prototypes)

* Thu Feb 17 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Compile shared libpcap with -fPIC (Bug #6342)

* Wed Feb 02 2000 Cristian Gafton <gafton@redhat.com>
- fix descriptions
- man pages are compressed

* Wed Dec 22 1999 Jeff Johnson <jbj@redhat.com>
- remove sparc64 SIOCGIFNAME hack, not needed with (at least) kernel 2.2.12-40.
- upgrade to ANK ss991030 snapshot with pcap magic fix (#6773).
- add getprotobyname lookup (#6725).
- getservbyname port lookup appears functional (#7569).
- remove uid 2090 backdoor (sorry Dave) (#7116).

* Thu Sep 09 1999 Cristian Gafton <gafton@redhat.com>
- fox the pcap.h header

* Fri Aug 20 1999 Jeff Johnson <jbj@redhat.com>
- prevent segfault on obscure spoofed ip header (#4634).

* Wed Aug 18 1999 Jeff Johnson <jbj@redhat.com>
- add defattr to arpwatch (#4591).

* Mon Aug 16 1999 Bill Nottingham <notting@redhat.com>
- initscript munging

* Sun Aug  8 1999 Jeff Johnson <jbj@redhat.com>
- add -DWORDS_BIGINDIAN to tcpdump compile on sparc sparc61.

* Tue Aug  3 1999 Jeff Johnson <jbj@redhat.com>
- include A. Kuznetsov's patches to libpcap/tcpdump.
- added arpsnmp to package (#3258).
- arp2ethers written for different of awk (#4326).

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 10)

* Fri Mar 19 1999 Jeff Johnson <jbj@redhat.com>
- strip binaries.

* Wed Jan 13 1999 Bill Nottingham <notting@redhat.com>
- autoconf fixes for arm

* Tue Sep 29 1998 Jeff Johnson <jbj@redhat.com>
- libpcap description typo.

* Sat Sep 19 1998 Jeff Johnson <jbj@redhat.com>
- fix arpwatch summary line.

* Mon Aug 17 1998 Jeff Johnson <jbj@redhat.com>
- enable arpwatch

* Mon Aug  3 1998 Jeff Johnson <jbj@redhat.com>
- separate package for libpcap.
- update tcpdump to 3.4, libpcap to 0.4.
- added arpwatch (but disabled for now)

* Thu May 07 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Sat May  2 1998 Alan Cox <alan@rehat.com>
- Added the SACK printing fix so you can dump Linux 2.1+.

* Tue Oct 21 1997 Erik Troan <ewt@redhat.com>
- updated to release 3.4a5
- uses a buildroot and %attr 

* Thu Jul 17 1997 Erik Troan <ewt@redhat.com>
- built against glibc
