Name:           nessus-core
Version:        2.2.11
Release:        4%{?_dist_release}
Summary:        Network vulnerability scanner
Summary(ja):    ネットワーク脆弱性スキャナ

Group:          Applications/System
License:        GPLv2
URL:            http://www.nessus.org
#http://www.nessus.org/download/index.php
Source0:        nessus-core-2.2.11.tar.gz
Source1:        nessusd.init
Source2:        nessusd.log
Source3:        nessus.desktop
# force nessus into fedora dir structure
# and use system gd
# Thanks to Dawid Gajownik for providing these patches =)
Patch0:         nessus-core-Makefile.patch
Patch1:         nessus-core-2.2.4.config.h.in.patch
Patch2:         nessus-core-2.2.4.configure.in.patch
Patch3:         nessus-core-2.2.4.configure.patch
Patch4:         nessus-core-2.2.4.gd.patch
Patch5:         nessus-core-2.2.4.nessus-adduser.in.patch
Patch6:         nessus-core-2.2.4.nessus-mkcert.patch
Patch7:         nessus-core-2.2.4.nessus-rmuser.in.patch
Patch8:         nessus-core-2.2.4.nessus.tmpl.in.patch
Patch9:         nessus-core-2.2.4.pid.patch
Patch10:        nessus-core-2.2.11.pki.patch
# fixes #399211 glibc open check
Patch11:        nessus-core-open.patch

# Patch for Vine
Patch100:       nessus-core-2.2.11.pcap.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-root
BuildRequires:  nessus-libraries-devel
BuildRequires:  libnasl-devel
BuildRequires:  gtk2-devel
BuildRequires:  glib2-devel
BuildRequires:  libICE-devel
BuildRequires:  gd-devel
BuildRequires:  tcp_wrappers
BuildRequires:  desktop-file-utils

%define pkidir %{_sysconfdir}/pki/nessus

%description
Nessus is the world's most popular vulnerability scanner used in over 75,000
organizations world-wide. Many of the world's largest organizations are
realizing significant cost savings by using Nessus to audit business-critical
enterprise devices and applications.

The "Nessus" Project was started by Renaud Deraison in 1998 to provide to the
internet community a free, powerful, up-to-date and easy to use remote
security scanner. Nessus is currently rated among the top products of its type
throughout the security industry and is endorsed by professional information
security organizations such as the SANS Institute.

%package devel
Summary: Header files for plugin development
Summary(ja): Nessus プラグイン開発に必要なヘッダファイル
Group: Development/Libraries

%description devel
%{summary}

%package -n nessus-server
Summary: nessusd is the server part of the nessus client-server model
Summary(ja): nessusd - Nessus クライアントサーバモデルのサーバ
Group: System Environment/Daemons
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires: nessus-core = %{version}-%{release}

%description -n nessus-server
%{summary}

%package -n nessus-client
Summary: Text client interface for nessusd
Summary(ja): nessusd のテキスト版クライアント
Group: Applications/Internet
Requires: nessus-core = %{version}-%{release}

%description -n nessus-client
%{summary}

%package -n nessus-gui
Summary: GTK client interface for nessusd
Summary(ja): Nessusd の GTK+ 版クライアント
Group: Applications/Internet
Requires: nessus-core = %{version}-%{release}

%description -n nessus-gui
%{summary}

%prep
%setup -q -n %{name}

%patch0  -p1
%patch1  -p1
%patch2  -p1
# You cannot compile against system gd, because nessus-text client
# will require X.org X11
%patch3  -p1
%patch4  -p1
%patch5  -p1
%patch6  -p1
%patch7  -p1
%patch8  -p1
%patch9  -p1
%patch10 -p1
%patch11 -p1

%patch100 -p0

%build
# libdir is used by plugins
# smpflags will break builds sometime...
%configure \
	--libdir=%{_localstatedir}/lib \
	--disable-gtk \
	--enable-syslog \
	--enable-tcpwrappers \
	--without-x
make -C nessus 

mv -f nessus/nessus nessus-text
make distclean

%configure \
	--libdir=%{_localstatedir}/lib \
	--enable-gtk \
	--enable-syslog \
	--enable-tcpwrappers \
	--with-x
make 

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

install -p -m 0755 nessus-text $RPM_BUILD_ROOT/%{_bindir}

install -D -p -m 755 %{SOURCE1} $RPM_BUILD_ROOT/%{_initrddir}/nessusd

install -D -p -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/nessusd
install -D -p -m 644 nessus/xpm/nessus.xpm \
	$RPM_BUILD_ROOT/%{_datadir}/pixmaps/nessus.xpm

desktop-file-install --vendor vine \
	--dir $RPM_BUILD_ROOT/%{_datadir}/applications\
	%{SOURCE3}

# generate ghost .pem files
mkdir -m 0755 -p $RPM_BUILD_ROOT/%{pkidir}/{private,}/CA
chmod 700 $RPM_BUILD_ROOT/%{pkidir}/private/CA
touch $RPM_BUILD_ROOT/%{pkidir}/private/CA/{cakey,serverkey}.pem
chmod 600 $RPM_BUILD_ROOT/%{pkidir}/private/CA/{cakey,serverkey}.pem
touch $RPM_BUILD_ROOT/%{pkidir}/CA/{cacert,servercert}.pem
chmod 644 $RPM_BUILD_ROOT/%{pkidir}/CA/{cacert,servercert}.pem

# install services file
install -D -p -m 644 nessus-services $RPM_BUILD_ROOT/%{_localstatedir}/lib/nessus/nessus-services

# plugin folder
mkdir -m 0755 -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/nessus/plugins

# generate ghost config files
touch $RPM_BUILD_ROOT/%{_sysconfdir}/nessus/nessusd.{conf,rules}
chmod 600 $RPM_BUILD_ROOT/%{_sysconfdir}/nessus/nessusd.conf

# fix multilib conflict for config.h (#342661)
touch -r CHANGES $RPM_BUILD_ROOT%{_includedir}/nessus/config.h

%clean
rm -rf $RPM_BUILD_ROOT

%post -n nessus-server
# This adds the proper /etc/rc*.d links for the script
if [ $1 = 1 ]; then
/sbin/chkconfig --add nessusd
fi

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

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

%files
%defattr(-,root,root,-)
%doc TODO CHANGES README_SSL doc/*txt doc/WARNING.* nessus/COPYING
%{_bindir}/nessus-mkrand
%{_bindir}/nessus-mkcert-client
%{_mandir}/man1/nessus.1*
%{_mandir}/man1/nessus-mkcert-client.1*
%{_mandir}/man1/nessus-mkrand.1*

%files devel
%defattr(-,root,root,-)
%doc doc/ntp/*
%dir %{_includedir}/nessus
%{_includedir}/nessus/*
%exclude %{_includedir}/nessus/includes.h

%files -n nessus-client
%defattr(-,root,root,-)
%{_bindir}/nessus-text

%files -n nessus-gui
%defattr(-,root,root,-)
%{_bindir}/nessus
%{_datadir}/pixmaps/nessus.xpm
%{_datadir}/applications/*

%files -n nessus-server
%defattr(-,root,root,-)
%{_bindir}/nessus-fetch
%{_sbindir}/nessusd
%{_sbindir}/nessus-mkcert
%{_sbindir}/nessus-adduser
%{_sbindir}/nessus-rmuser
%{_sbindir}/nessus-check-signature
%{_mandir}/man1/nessus-fetch.1*
%{_mandir}/man8/*
%{_initrddir}/nessusd
%{_localstatedir}/lib/nessus/nessus-services
%dir %{_localstatedir}/log/nessus
%dir %{_localstatedir}/lib/nessus/
%dir %{_localstatedir}/lib/nessus/plugins
%dir %{_sysconfdir}/nessus
%dir %{_sysconfdir}/pki/nessus
%config(noreplace) %{_sysconfdir}/logrotate.d/nessusd
%ghost %config(missingok,noreplace) %verify(not md5 size mtime) %{pkidir}/CA/*
%ghost %config(missingok,noreplace) %verify(not md5 size mtime) %{pkidir}/private/CA/*
%ghost %config(missingok,noreplace) %verify(not md5 size mtime) %{_sysconfdir}/nessus/*

%changelog
* Sat Apr 25 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 2.2.11-4
- updated nessus based on Fedora Development
- added Patch100 for building on Vine

* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.11-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Sat Jan 17 2009 Tomas Mraz <tmraz@redhat.com> - 2.2.11-2
- rebuild with new openssl

* Sun Nov 23 2008 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
- 2.2.11-1
- fix #465113 FTBFS

* Mon Feb 18 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 2.2.10-4
- Autorebuild for GCC 4.3

* Sat Dec 08 2007 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
- 2.2.10-3
- fix build #399211 (patch from Oliver Falk)
- fix multilib issues #342661
- fix init scripts #246992

* Thu Dec 06 2007 Release Engineering <rel-eng at fedoraproject dot org> - 2.2.10-2
- Rebuild for deps

* Wed Aug 22 2007 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
- 2.2.10-1
- version upgrade
- new license tag

* Wed Apr 25 2007 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
2.2.9-2
- fix #233888

* Tue Dec 19 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
2.2.9-1
- version upgrade (#199399)

* Sun Jun 18 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
2.2.8-1
- version upgrade

* Wed May 17 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
2.2.7-1
- version upgrade

* Mon Apr 03 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
2.2.6-3
- fix description
- create and own log dir
- include copying

* Sun Feb 26 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
2.2.6-2
- fix buildroot
- add source0 url

* Fri Feb 24 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
2.2.6-1
- initial version
