Name:           tcpdump
Epoch:          14
Version:        4.9.3
Release:        4 
Summary:        A network traffic monitoring tool
License:        BSD with advertising
URL:            http://www.tcpdump.org

Source0:        http://www.tcpdump.org/release/tcpdump-%{version}.tar.gz
Source1:        ftp://ftp.ee.lbl.gov/tcpslice-1.2a3.tar.gz
Source2:        http://www.tcpdump.org/release/tcpdump-%{version}.tar.gz.sig

Patch0002:      0002-Use-getnameinfo-instead-of-gethostbyaddr.patch
Patch0003:      0003-Drop-root-priviledges-before-opening-first-savefile-.patch
Patch0004:      0004-tcpslice-update-tcpslice-patch-to-1.2a3.patch
Patch0005:      0005-tcpslice-remove-unneeded-include.patch
Patch0006:      0006-tcpslice-don-t-test-the-pointer-but-pointee-for-NULL.patch
Patch0007:      0007-Introduce-nn-option.patch
Patch0009:      0009-Change-n-flag-to-nn-in-TESTonce.patch
Patch0011:      0011-Evp-cipher-buffers.patch
Patch0012:      0012-Add-printing-support-for-vsockmon-devices.patch
Patch0013:	CVE-2020-8037.patch

Requires(pre):  shadow-utils
BuildRequires:  automake openssl-devel libpcap-devel git-core gcc

%define tcpslice_dir tcpslice-1.2a3

%description
Tcpdump is a command-line tool for monitoring network traffic.
Tcpdump can capture and display the packet headers on a particular
network interface or on all interfaces.  Tcpdump can display all of
the packet headers, or just the ones that match particular criteria.

Install tcpdump if you need a program to monitor network traffic.

%package help
Summary:        Help documents for tcpdump

%description    help
Man pages and other related help documents for tcpdump.

%prep
%autosetup -a 1 -S git

%build
export CFLAGS="$RPM_OPT_FLAGS $(getconf LFS_CFLAGS) -fno-strict-aliasing"

pushd %{tcpslice_dir}
# update config.{guess,sub}
automake -a -f 2> /dev/null || :
%configure
make %{?_smp_mflags}
popd

%configure --with-crypto --with-user=tcpdump --without-smi
make %{?_smp_mflags}

%install
mkdir -p ${RPM_BUILD_ROOT}%{_libdir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8
mkdir -p ${RPM_BUILD_ROOT}%{_sbindir}

pushd %{tcpslice_dir}
install -m755 tcpslice ${RPM_BUILD_ROOT}%{_sbindir}
install -m644 tcpslice.1 ${RPM_BUILD_ROOT}%{_mandir}/man8/tcpslice.8
popd

install -m755 tcpdump ${RPM_BUILD_ROOT}%{_sbindir}
install -m644 tcpdump.1 ${RPM_BUILD_ROOT}%{_mandir}/man8/tcpdump.8

# fix section numbers
sed -i 's/\(\.TH[a-zA-Z ]*\)[1-9]\(.*\)/\18\2/' \
	${RPM_BUILD_ROOT}%{_mandir}/man8/*

%pre
/usr/sbin/groupadd -g 72 tcpdump 2> /dev/null
/usr/sbin/useradd -u 72 -g 72 -s /sbin/nologin -M -r \
	-d / tcpdump 2> /dev/null
exit 0

%files
%doc README.md CHANGES CREDITS
%license LICENSE
%{_sbindir}/tcpdump
%{_sbindir}/tcpslice

%files help
%{_mandir}/man8/tcpslice.8*
%{_mandir}/man8/tcpdump.8*

%changelog
* Mon Dec 21 2020 wangxp006 <wangxp006@163.com> - 4.9.3-4
- Type:CVE
- ID:CVE-2020-8037
- SUG:NA
- DESC:fix CVE-2020-8037

* Tue Dec 31 2019 openEuler Buildteam <buildteam@openeuler.org> - 4.9.3-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:optimization the spec

* Sat Dec 21 2019 openEuler Buildteam <buildteam@openeuler.org> - 4.9.3-2
- Package init
