#
# spec file for package iputils
#
# Copyright (c) 2013 SUSE LINUX Products 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:  libopenssl-devel
#BuildRequires:  opensp
#BuildRequires:  perl-SGMLS
#%if 0%{?suse_version} > 1130
#BuildRequires:  sysfsutils-devel
#%else
#BuildRequires:  sysfsutils
#%endif
#BuildRequires:  libcap-devel
Summary:        IPv4 and IPv6 Networking Utilities
License:        BSD-3-Clause and GPL-2.0+
Group:          Productivity/Networking/Other
Version:        s20101006
Release:        22.3
Url:            http://www.skbuff.net/iputils
Source:         http://www.skbuff.net/iputils/iputils-%{version}.tar.bz2
# XXX: from linux/Documentation/networking/ifenslave.c
Source1:        ifenslave.c
Patch1:         iputils-pingnamelookuponce.diff
Patch2:         iputils-traceroute6-stdint.diff
Patch3:         iputils-ifenslave.diff
Patch6:         iputils-s20101006-capabilities.diff
Patch7:         iputils-pingtypo.diff
Patch8:         iputils-s20101006-sec-ping-unblock.diff
Patch9:         iputils-s20101006-ping-interrupt.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
#PreReq:         permissions
BuildArch:	i486

%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 . 
%patch1
%patch2
%patch3
#patch4
#patch5
%patch6 -p1
%patch7
%patch8
%patch9
mkdir linux
touch linux/autoconf.h

%build
make %{?_smp_mflags} KERNEL_INCLUDE=$PWD \
	CCOPT='%optflags -fno-strict-aliasing -fpie -D_GNU_SOURCE' \
	LDLIBS='-Wl,-z,relro,-z,now -pie -lcap -lresolv' \
	CAPABILITIES=1
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 ping		$RPM_BUILD_ROOT/%{_bindir}
install ping6		$RPM_BUILD_ROOT/%{_bindir}
install ipg			$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/arping.8		$RPM_BUILD_ROOT%_mandir/man8/
install  -m 644 doc/clockdiff.8		$RPM_BUILD_ROOT%_mandir/man8/
install  -m 644 doc/tracepath.8		$RPM_BUILD_ROOT%_mandir/man8/
install  -m 644 doc/ping.8		$RPM_BUILD_ROOT%_mandir/man8/
install  -m 644 doc/ping.8		$RPM_BUILD_ROOT%_mandir/man8/ping6.8
install  -m 644 doc/pg3.8		$RPM_BUILD_ROOT%_mandir/man8/
install  -m 644 doc/rdisc.8		$RPM_BUILD_ROOT%_mandir/man8/

%clean
rm -rf $RPM_BUILD_ROOT

%post
%set_permissions /bin/ping /bin/ping6

%verifyscript
%verify_permissions /bin/ping /bin/ping6

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

%changelog
* 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