#
# spec file for package iputils
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           iputils
BuildRequires:  docbook_3
BuildRequires:  iso_ent
BuildRequires:  libcap-devel
BuildRequires:  libopenssl-devel
BuildRequires:  pkgconfig(libidn)
BuildRequires:  opensp
BuildRequires:  perl-SGMLS
Summary:        IPv4 and IPv6 Networking Utilities
License:        BSD-3-Clause and GPL-2.0+
Group:          Productivity/Networking/Other
Version:        s20150815
Release:        66.3
Url:            https://github.com/iputils/iputils
Source:         https://github.com/iputils/iputils/archive/%{version}.tar.gz
# XXX: from linux/Documentation/networking/ifenslave.c
Source1:        ifenslave.c
Patch2:         iputils-traceroute6-stdint.diff
Patch3:         iputils-ifenslave.diff
Patch8:         iputils-sec-ping-unblock.diff
Patch9:         iputils-ping-interrupt.diff
# PATCH-FIX-UPSTREAM iputils-remove-bogus-check-required-for-2.4.9-kernels.patch tiwai@suse.de - boo#927831
Patch10:        iputils-remove-bogus-check-required-for-2.4.9-kernels.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         permissions

%description
This package contains some small network tools for IPv4 and IPv6 like
rdisc, ping6, traceroute6, tracepath, and tracepath6.

%prep
%setup -q
cp -a %SOURCE1 . 
%patch2 -p1
%patch3
%patch8 -p1
%patch9 -p1
%patch10 -p1

%build
make %{?_smp_mflags} CFLAGS='%{optflags} -fPIC' KERNEL_INCLUDE=$PWD \
	CCOPT='%optflags -fno-strict-aliasing -fpie -D_GNU_SOURCE' \
	LDLIBS='-Wl,-z,relro,-z,now -pie -lcap -lresolv' \
	CAPABILITIES=1 LDFLAG_GNUTLS='-lcrypto -lssl'
gcc $RPM_OPT_FLAGS -o ifenslave ifenslave.c

make man

%install
mkdir -p $RPM_BUILD_ROOT/%_sbindir
mkdir -p $RPM_BUILD_ROOT/%_bindir
install arping		$RPM_BUILD_ROOT/%{_sbindir}
install ifenslave	$RPM_BUILD_ROOT/%{_sbindir}
install clockdiff	$RPM_BUILD_ROOT/%{_sbindir}
install rdisc		$RPM_BUILD_ROOT/%{_sbindir}/in.rdisc
install tracepath	$RPM_BUILD_ROOT/%{_sbindir}
install tracepath6	$RPM_BUILD_ROOT/%{_sbindir}
install traceroute6 $RPM_BUILD_ROOT/%{_sbindir}
install ping		$RPM_BUILD_ROOT/%{_bindir}
install ipg			$RPM_BUILD_ROOT/%{_bindir}
install tftpd       $RPM_BUILD_ROOT/%{_bindir}
install rarpd       $RPM_BUILD_ROOT/%{_bindir}
#UsrMerge
mkdir -p $RPM_BUILD_ROOT/{bin,sbin}
ln -sf %{_sbindir}/arping       $RPM_BUILD_ROOT/sbin
ln -sf %{_sbindir}/ifenslave    $RPM_BUILD_ROOT/sbin
ln -sf %{_sbindir}/clockdiff    $RPM_BUILD_ROOT/sbin
ln -sf %{_sbindir}/in.rdisc     $RPM_BUILD_ROOT/sbin
ln -sf %{_sbindir}/tracepath    $RPM_BUILD_ROOT/sbin
ln -sf %{_sbindir}/tracepath6   $RPM_BUILD_ROOT/sbin
ln -sf %{_bindir}/ping          $RPM_BUILD_ROOT/bin
ln -sf %{_bindir}/ping6         $RPM_BUILD_ROOT/bin
ln -sf %{_bindir}/ipg           $RPM_BUILD_ROOT/bin
#EndUsrMerge


mkdir -p $RPM_BUILD_ROOT%_mandir/man8
install  -m 644 doc/*.8		$RPM_BUILD_ROOT%_mandir/man8/
install  -m 644 doc/ping.8		$RPM_BUILD_ROOT%_mandir/man8/ping6.8

%post
%set_permissions %{_bindir}/ping %{_bindir}/ping6

%verifyscript
%verify_permissions %{_bindir}/ping %{_bindir}/ping6

%files
%defattr(-,root,root)
%doc RELNOTES
%verify(not mode caps) %attr(4755,root,root) %{_bindir}/ping
%{_bindir}/ipg
%{_bindir}/rarpd
%{_bindir}/tftpd
%{_sbindir}/arping
%{_sbindir}/ifenslave
%{_sbindir}/clockdiff
%{_sbindir}/tracepath
%{_sbindir}/tracepath6
%{_sbindir}/traceroute6
%{_sbindir}/in.rdisc
#UsrMerge
/bin/*
/sbin/*
#EndUsrMerge
%attr(644,root,root) %_mandir/man8/*

%changelog
* Tue Dec  1 2015 p.drouand@gmail.com
- Update to version s20150815
  * use syntax compatible with busybox date in Makefile
  * Makefile: use #define as in previous code changes
  * ping: status() now returns received/transmitted instead of trans/recv
  * ping: don't mess with internals of struct msghdr
  * tracepath,doc: fix corrupted tag
  * made ping functions protocol independent
  * Allow ping to use IPv6 addresses
  * if IPv4 resolving fails fallback to ping6
  * ping: in usage print the 'ping -6' options as well
  * ping: allow option -4 which forces IPv4
  * combine sock and errno into a single structure
  * This patch allows running ping and ping6 without root privileges on
  * use better names for socket variables
  * travis.yml: install nettle-dev
  * Allow using nettle instead of libgcrypt for MD5
  * avoid compiler warning caused by snapshot.h
  * make `getaddrinfo()` and `getnameinfo()` usage consistent
  * enable IDN by default
  * ping: perform dual-stack ping by default
  * remove IPV4_TARGETS and IPV6_TARGETS
  * ping: remove obsolete preprocessor directives
  * ping: avoid name clashes between IPv4 and IPv6 code
  * ping: merge all ping header files into a single one
  * ping: merge `ping6` command into `ping`
  * ping: refactor ping options
  * ping: refactor ping socket code
  * ping: merge IPv4 and IPv6 `pr_addr()`
  * Use svg instead of png to get better image quality
  * iputils ping/ping6: Add a function to check if a packet is ours
  * ping: Add <linux/types.h> to fix compilation error.
  * ping6: Use GNUTLS API directly for MD5. (v2)
  * ping6: Use libgcrypt instead of gnutls for MD5.
  * ninfod: Regenerate configure by autoconf-2.69.
  * ninfod: libgcrypt support.
  * spec: Configure before building ninfod.
  * spec: Fix date in %%changelog.
  * make,spec: Add rpm target.
  * ping,ping6 doc: More description on CAP_NET_RAW usage.
- Update patches
  * iputils-s20101006-ping-interrupt.diff > iputils-ping-interrupt.diff
  * iputils-s20101006-sec-ping-unblock.diff > iputils-sec-ping-unblock.diff
  * iputils-remove-bogus-check-required-for-2.4.9-kernels.patch
- Update home project page and download Url
- Remove obsolete %%clean section
- Remove UsrMerge process; it has been done for more than two
  openSUSE releases now
* Mon Apr 20 2015 tiwai@suse.de
- Fix a bogus kernel version check (boo#927831):
  iputils-remove-bogus-check-required-for-2.4.9-kernels.patch
* Tue Jan 28 2014 hare@suse.de
- Fixed ping segfaults (bnc#860616,bnc#860655)
  * Removed iputils-pingnamelookuponce.diff
* Thu Jan 23 2014 hare@suse.de
- Update to upstream version s20121221 (FATE#316211)
  - See RELNOTES for full changelog
- Removed merges patches:
  * iputils-pingtypo.diff
  * iputils-s20101006-capabilities.diff
- Updated patches for apply
- Remove libsysfs dependency (FATE#316211)
* Wed Nov 13 2013 meissner@suse.com
- also do the usr move with the permissions handlers bnc#841533
* Tue Jul 23 2013 ms@suse.de
- ping denpend on SIGALRM to exit sometime, so we mask it UNBLOCK (bnc #674304)
* Fri Mar  8 2013 crrodriguez@opensuse.org
- Build everythiong with full RELRO here. SUID code around..
* Sat Mar  2 2013 coolo@suse.com
- update license to new format
* Fri Feb 17 2012 rschweikert@suse.com
- place binaries in /usr tree (UsrMerge project)
* Tue May 31 2011 ms@suse.de
- fixed typo in ping output. Since 11.4 sequence tag is icmp_req
  instead of icmp_seq beause of that for example cacti ping script
  does not work anymore (bnc #696720)
* Fri Nov 19 2010 coolo@novell.com
- remove no longer needed patches
* Tue Nov 16 2010 lnussel@suse.de
- don't verify caps as that's done by chkstat as well
- use new %%set_permissions macro
* Mon Nov  8 2010 lnussel@suse.de
- fix capabilities patch: first switch uid then drop caps.
* Wed Nov  3 2010 lnussel@suse.de
- update to version s20100418
  * ping,ping6: avoid gethostbyaddr during ping flood.
  * arping: Set correct broadcast address.
  * tracepath: Fix some small typos in tracepath.sgml.
  * ping: Fix resource consumption triggered by specially crafted ICMP
    Echo Reply (CVE-2010-2529)
- don't install fscaps, rely on /etc/permissions handling instead
- compile using -fno-strict-aliasing
- drop capabilities unconditionally (bnc#645423)
- spec file cleanup
* Mon Oct 11 2010 reddwarf@opensuse.org
- Use POSIX capabilities instead of SUID for ping
* Tue Sep  7 2010 aj@suse.de
- BuildRequire sysfsutils-devel
* Wed Jul 14 2010 ms@suse.de
- fixed device broadcast setup (bnc #614389)
- upstream maintainer has changed. new maintainer is
  YOSHIFUJI Hideaki. Along with this change the versioning
  of the package also changed. Current version is: s20100418
  from 18-Apr-2010
- many patches upstream now, reduced patch set
* Tue Jul 13 2010 ms@suse.de
- reverted arping-infiniband.diff, it breaks arping
  (bnc #614389) and (bnc #610839)
* Thu Jul  8 2010 ms@suse.de
- security fix: replies by a malicious system can
  make ping run into an endless loop (bnc #620837)
* Fri Jun  4 2010 ms@suse.de
- fixed arping buffer overflow on Infiniband (bnc #610839)
* Fri Apr 23 2010 ms@suse.de
- ifenslave: fixed detach/attach code of bonds (bnc #595474)
- ifenslave: fixed output of the IP address - in hex: (bnc #595474)
* Tue Dec 22 2009 jengelh@medozas.de
- enable parallel build
* Mon Oct  6 2008 ms@suse.de
- fixed compiler warning in ifenslave.c:
  * ordered comparison of pointer with integer zero (bnc #431910)
* Thu Sep  4 2008 ms@suse.de
- fixed ping signal handling during address lookup (bnc #416404)
* Wed Dec 12 2007 rguenther@suse.de
- use sysconf(_SC_OPEN_MAX) instead of OPEN_MAX to fix build
* Tue Mar  6 2007 ms@suse.de
- fixed overbound ttab2 array access (#251195)
* Wed Dec  6 2006 ms@suse.de
- ping_common.c: added check for oversized packages (-s) (#222010)
* Thu Nov 23 2006 olh@suse.de
- move ifenslave.c to the first patch to allow quilt setup *.spec
* Wed Nov 22 2006 ms@suse.de
- ping6: use getaddrinfo() instead of gethostbyname2 (#221745)
* Fri Nov 10 2006 ro@suse.de
- fix manpage permissions
* Mon Aug  7 2006 aj@suse.de
- use sysconf(_SC_CLK_TCK) instead of HZ
* Wed Mar  1 2006 schwab@suse.de
- ifenslave: fix display of interface address.
- Don't strip binaries.
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Jan 23 2006 mmj@suse.de
- Fix ping6 [#143932]
* Fri Jul  8 2005 mmj@suse.de
- Patch from ak which allows to use the standard ping6
  link-local-addr%%interface syntax instead of ping6 -I interface
  link-local-addr.
* Thu Jun 16 2005 mmj@suse.de
- Compile with -fpie, link with -pie
* Fri Sep  3 2004 kukuk@suse.de
- Fix compiling with new glibc headers
* Fri Mar 19 2004 mmj@suse.de
- Use correct permissions for manpages [#36321]
* Wed Mar 17 2004 mmj@suse.de
- Add Olaf Kirch patch to only do name lookup once in ping [#36161]
* Mon Jan 12 2004 mmj@suse.de
- Update ifenslave.c to the one from linux-2.6.1
* Thu Oct 16 2003 mmj@suse.de
- Don't build as root
- Cleanup a bit
* Wed Jun  4 2003 kukuk@suse.de
- Don't include net/if.h and linux/if.h at the same time
* Mon May 12 2003 mmj@suse.de
- Update to newest snapshot, ss021109
* Mon Feb 24 2003 schwab@suse.de
- Fix use of kernel headers.
* Wed Oct 30 2002 mmj@suse.de
- Apply patch for the ping/ping6 manpage to mention the -R option
  is for IPv4 only.
- Clean up the specfile a bit.
* Fri Oct 25 2002 mmj@suse.de
- Apply patch for setuid() return value check from Thomas Biege
* Wed Oct  2 2002 mmj@suse.de
- Add the ifenslave binary from the kernel Documentation directory
  [#20372]
* Tue Oct  1 2002 mmj@suse.de
- Update to snapshot 020927 which among other things should have
  below fix merged.
* Thu Aug  8 2002 mmj@suse.de
- Apply other patch to fix the dynamic IP problem and still allows
  the from address to be printed. Thanks to Olaf Kirch. [#17519]
* Sun Jul 28 2002 kukuk@suse.de
- remove unused tetex from neededforbuild
* Thu Jul 25 2002 mmj@suse.de
- Disabled traceroute6
* Fri Jul  5 2002 bk@suse.de
- fix build on ia64(use glibc kernel headers, not /usr/src/linux)
- add optflags
* Thu Jul  4 2002 bk@suse.de
- add fix for buffer overflow problem in traceroute6.c(datalen.patch)
- add fix for ipv6 error printing problem (ping6-errorprinting.patch)
- add patch to activate the rdisc server  (rdisc-server.patch)
* Mon Jun 17 2002 mmj@suse.de
- Revert back to the ping from iputils, and apply patch to fix
  the dynamic ip problem.
* Mon Jun 10 2002 mmj@suse.de
- Use old nkitb ping which works with dynamic IP [#12568]
* Mon Feb  4 2002 mmj@suse.de
- Update to snapshot from January 24th 2002
* Tue Jan 22 2002 mmj@suse.de
- Update to snapshot from December 2nd 2001
* Mon Dec 10 2001 bjacke@suse.de
- move arping to /sbin/
* Wed Oct 10 2001 mmj@suse.de
- Update to snapshot from October 2 2001
* Thu Sep  6 2001 kukuk@suse.de
- Remove wrong warning about to old kernel and warning about
  problems with the clock from ping (ping has a special handler
  for this, so it is okay). Both only confuses tester [Bug #10141
  and Bug #10146].
* Sat Aug 25 2001 kukuk@suse.de
- Update to snapshot from 24 Aug 2001
- Use included ping like all other distributions do
- Don't use included rarpd and tftpd
- Lot of new functions and minor bug fixes
* Mon Jun 18 2001 schwab@suse.de
- Fix use of cpp directives inside macro call.
* Fri Mar 30 2001 kukuk@suse.de
- Use ping6 from inet6-apps package [Bug #6354]
* Mon Mar 12 2001 schwab@suse.de
- Fix use of kernel headers.
* Fri Mar  9 2001 kukuk@suse.de
- Add ping and ping.8 manual page from OpenBSD.
* Mon Mar  5 2001 kukuk@suse.de
- fix to build with current glibc
* Wed Feb 14 2001 uli@suse.de
- fixed to build on PPC
* Sat Nov 11 2000 kukuk@suse.de
- Update to new version (20001110).
* Sat Oct 14 2000 kukuk@suse.de
- spec file fixes
* Sat Oct 14 2000 kukuk@suse.de
- Initial version