74b14c
#global prever rcX
74b14c
%global _hardened_build 1
74b14c
74b14c
Summary: DNSSEC key and zone management software
74b14c
Name: opendnssec
74b14c
Version: 2.1.6
74b14c
Release: 1%{?prever}%{?dist}
74b14c
License: BSD
74b14c
Url: http://www.opendnssec.org/
74b14c
Source0: http://www.opendnssec.org/files/source/%{?prever:testing/}%{name}-%{version}%{?prever}.tar.gz
74b14c
Source1: ods-enforcerd.service
74b14c
Source2: ods-signerd.service
74b14c
Source3: ods.sysconfig
74b14c
Source4: conf.xml
74b14c
Source5: tmpfiles-opendnssec.conf
74b14c
Source6: opendnssec.cron
74b14c
Source7: opendnssec-2.1.sqlite_convert.sql
74b14c
Source8: opendnssec-2.1.sqlite_rpmversion.sql
74b14c
74b14c
Patch1: opendnssec-2.1.6-gcc10-fixups.patch
74b14c
Patch2: opendnssec-2.1.6-sqlite.patch
74b14c
74b14c
Requires: opencryptoki, softhsm >= 2.5.0 , systemd-units
74b14c
Requires: libxml2, libxslt sqlite
74b14c
BuildRequires:  gcc
74b14c
BuildRequires: ldns-devel >= 1.6.12, sqlite-devel >= 3.0.0, openssl-devel
74b14c
BuildRequires: libxml2-devel CUnit-devel, doxygen
74b14c
# It tests for pkill/killall and would use /bin/false if not found
74b14c
BuildRequires: procps-ng
74b14c
BuildRequires: perl-interpreter
74b14c
BuildRequires: libmicrohttpd-devel jansson-devel libyaml-devel
74b14c
74b14c
BuildRequires: systemd-units
74b14c
Requires(pre): shadow-utils
74b14c
Requires(post): systemd-units
74b14c
Requires(preun): systemd-units
74b14c
Requires(postun): systemd-units
74b14c
%if 0%{?prever:1}
74b14c
# For building development snapshots
74b14c
Buildrequires: autoconf, automake, libtool, java
74b14c
%endif
74b14c
74b14c
%description
74b14c
OpenDNSSEC was created as an open-source turn-key solution for DNSSEC.
74b14c
It secures zone data just before it is published in an authoritative
74b14c
name server. It requires a PKCS#11 crypto module library, such as softhsm
74b14c
74b14c
%prep
74b14c
%setup -q -n %{name}-%{version}%{?prever}
74b14c
# bump default policy ZSK keysize to 2048
74b14c
sed -i "s/1024/2048/" conf/kasp.xml.in
74b14c
%patch1 -p1
74b14c
%patch2 -p1
74b14c
74b14c
%build
74b14c
#export LDFLAGS="-Wl,-z,relro,-z,now -pie -specs=/usr/lib/rpm/redhat/redhat-hardened-ld"
74b14c
#export CFLAGS="$RPM_OPT_FLAGS -fPIE -pie -Wextra -Wformat -Wformat-nonliteral -Wformat-security"
74b14c
#export CXXFLAGS="$RPM_OPT_FLAGS -fPIE -pie -Wformat-nonliteral -Wformat-security"
74b14c
%if 0%{?prever:1}
74b14c
# for development snapshots
74b14c
sh ./autogen.sh
74b14c
%endif
74b14c
%configure --with-ldns=%{_libdir}
74b14c
make %{?_smp_mflags}
74b14c
74b14c
%check
74b14c
# Requires sample db not shipped with upstream
74b14c
# make check
74b14c
74b14c
%install
74b14c
rm -rf %{buildroot}
74b14c
make DESTDIR=%{buildroot} install
74b14c
mkdir -p %{buildroot}%{_localstatedir}/opendnssec/{tmp,signed,signconf,enforcer}
74b14c
install -d -m 0755 %{buildroot}%{_initrddir} %{buildroot}%{_sysconfdir}/cron.d/
74b14c
install -m 0644 %{SOURCE6} %{buildroot}/%{_sysconfdir}/cron.d/opendnssec
74b14c
rm -f %{buildroot}/%{_sysconfdir}/opendnssec/*.sample
74b14c
install -d -m 0755 %{buildroot}/%{_sysconfdir}/sysconfig
74b14c
install -d -m 0755 %{buildroot}%{_unitdir}
74b14c
install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/
74b14c
install -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/
74b14c
install -m 0644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/sysconfig/ods
74b14c
install -m 0644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/opendnssec/
74b14c
mkdir -p %{buildroot}%{_tmpfilesdir}/
74b14c
install -m 0644 %{SOURCE5} %{buildroot}%{_tmpfilesdir}/opendnssec.conf
74b14c
mkdir -p %{buildroot}%{_localstatedir}/run/opendnssec
74b14c
mkdir -p %{buildroot}%{_datadir}/opendnssec/
74b14c
cp -a enforcer/utils %{buildroot}%{_datadir}/opendnssec/migration
74b14c
cp -a enforcer/src/db/schema.* %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/
74b14c
# fixup path for mysql/sqlite. Use our replacement sqlite_convert.sql to detect previous migration
74b14c
cp -a %{SOURCE7} %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/sqlite_convert.sql
74b14c
cp -a %{SOURCE8} %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/rpmversion.sql
74b14c
sed -i "s:^SCHEMA=.*schema:SCHEMA=%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/schema:" %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/convert_sqlite
74b14c
sed -i "s:find_problematic_zones.sql:%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/find_problematic_zones.sql:g" %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/convert_sqlite
74b14c
sed -i "s:^SCHEMA=.*schema:SCHEMA=%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/schema:" %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/convert_mysql
74b14c
sed -i "s:find_problematic_zones.sql:%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/find_problematic_zones.sql:g" %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/convert_mysql
74b14c
sed -i "s:sqlite_convert.sql:%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/sqlite_convert.sql:g" %{buildroot}%{_datadir}/opendnssec/migration/1.4-2.0_db_convert/convert_sqlite
74b14c
74b14c
74b14c
%files
74b14c
%{_unitdir}/ods-enforcerd.service
74b14c
%{_unitdir}/ods-signerd.service
74b14c
%config(noreplace) %{_tmpfilesdir}/opendnssec.conf
74b14c
%attr(0770,root,ods) %dir %{_sysconfdir}/opendnssec
74b14c
%attr(0770,root,ods) %dir %{_localstatedir}/opendnssec
74b14c
%attr(0770,root,ods) %dir %{_localstatedir}/opendnssec/tmp
74b14c
%attr(0775,root,ods) %dir %{_localstatedir}/opendnssec/signed
74b14c
%attr(0770,root,ods) %dir %{_localstatedir}/opendnssec/signconf
74b14c
%attr(0770,root,ods) %dir %{_localstatedir}/opendnssec/enforcer
74b14c
%attr(0660,root,ods) %config(noreplace) %{_sysconfdir}/opendnssec/*.xml
74b14c
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/ods
74b14c
%attr(0770,root,ods) %dir %{_localstatedir}/run/opendnssec
74b14c
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/opendnssec
74b14c
%doc NEWS README.md
74b14c
%license LICENSE
74b14c
%{_mandir}/*/*
74b14c
%{_sbindir}/*
74b14c
%{_bindir}/*
74b14c
%attr(0755,root,root) %dir %{_datadir}/opendnssec
74b14c
%{_datadir}/opendnssec/*
74b14c
74b14c
%pre
74b14c
getent group ods >/dev/null || groupadd -r ods
74b14c
getent passwd ods >/dev/null || \
74b14c
useradd -r -g ods -d /etc/opendnssec -s /sbin/nologin \
74b14c
-c "opendnssec daemon account" ods
74b14c
exit 0
74b14c
74b14c
%post
74b14c
# Initialise a slot on the softhsm on first install
74b14c
if [ "$1" -eq 1 ]; then
74b14c
   %{_sbindir}/runuser -u ods -- %{_bindir}/softhsm2-util --init-token \
74b14c
                --free --label "OpenDNSSEC" --pin 1234 --so-pin 1234
74b14c
   if [ ! -s %{_localstatedir}/opendnssec/kasp.db ]; then
74b14c
      echo y | %{_sbindir}/ods-enforcer-db-setup
74b14c
      %{_bindir}/sqlite3 -batch %{_localstatedir}/opendnssec/kasp.db < %{_datadir}/opendnssec/migration/1.4-2.0_db_convert/rpmversion.sql
74b14c
   fi
74b14c
74b14c
elif [ -z "$(%{_bindir}/sqlite3 %{_localstatedir}/opendnssec/kasp.db 'select * from rpm_migration;')" ]; then
74b14c
   # Migrate version 1.4 db to version 2.1 db
74b14c
   if [ -e %{_localstatedir}/opendnssec/rpm-migration-in-progress ]; then
74b14c
      echo "previous (partial?) migration found - human intervention is needed"
74b14c
   else
74b14c
      echo "opendnssec 1.4 database found, migrating to 2.x"
74b14c
      touch %{_localstatedir}/opendnssec/rpm-migration-in-progress
74b14c
      mv -n %{_localstatedir}/opendnssec/kasp.db %{_localstatedir}/opendnssec/kasp.db-1.4
74b14c
      echo "migrating conf.xml from 1.4 to 2.1 schema"
74b14c
      cp -n %{_sysconfdir}/opendnssec/conf.xml %{_sysconfdir}/opendnssec/conf.xml-1.4
74b14c
      # fixup incompatibilities inflicted upon us by upstream :(
74b14c
      sed -i "/<Interval>.*Interval>/d" %{_sysconfdir}/opendnssec/conf.xml
74b14c
      echo "Converting kasp.db"
74b14c
      ERR=""
74b14c
      %{_datadir}/opendnssec/migration/1.4-2.0_db_convert/convert_sqlite -i %{_localstatedir}/opendnssec/kasp.db-1.4 -o %{_localstatedir}/opendnssec/kasp.db || ERR="convert_sqlite error"
74b14c
      chown ods.ods %{_localstatedir}/opendnssec/kasp.db
74b14c
      cp -n %{_sysconfdir}/opendnssec/zonelist.xml %{_localstatedir}/opendnssec/enforcer/zones.xml
74b14c
      if [ -z "$ERR" ]; then
74b14c
         echo "calling ods-migrate"
74b14c
         ods-migrate || ERR="ods-migrate failed"
74b14c
         if [ -z "$ERR" ]; then
74b14c
            echo "opendnssec 1.4 to 2.x migration completed"
74b14c
            rm %{_localstatedir}/opendnssec/rpm-migration-in-progress
74b14c
         else
74b14c
            echo "ods-migrate process failed - human intervention is needed"
74b14c
         fi
74b14c
      else
74b14c
         echo "%{_localstatedir}/opendnssec/kasp.db conversion failed - not calling ods-migrate to complete migration. human intervention is needed"
74b14c
      fi
74b14c
   fi
74b14c
fi
74b14c
74b14c
# in case we update any xml conf file
74b14c
ods-enforcer update all >/dev/null 2>/dev/null ||:
74b14c
74b14c
%systemd_post ods-enforcerd.service
74b14c
%systemd_post ods-signerd.service
74b14c
74b14c
%preun
74b14c
%systemd_preun ods-enforcerd.service
74b14c
%systemd_preun ods-signerd.service
74b14c
74b14c
%postun
74b14c
%systemd_postun_with_restart ods-enforcerd.service
74b14c
%systemd_postun_with_restart ods-signerd.service
74b14c
74b14c
%changelog
74b14c
* Wed Apr 15 2020 Paul Wouters <pwouters@redhat.com> - 2.1.6-1
74b14c
- Resolves: rhbz#1759888 Rebase OpenDNSSEC to 2.1
74b14c
74b14c
* Tue Dec 12 2017 Paul Wouters <pwouters@redhat.com> - 1.4.14-1
74b14c
- Update to 1.4.14 as first steop to migrating to 2.x
74b14c
- Resolves: rhbz#1413254 Move tmpfiles.d config to %%{_tmpfilesdir}, install LICENSE as %%license
74b14c
74b14c
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.9-7
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
74b14c
74b14c
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.9-6
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
74b14c
74b14c
* Wed Mar 08 2017 Tomas Hozza <thozza@redhat.com> - 1.4.9-5
74b14c
- Fix FTBFS (#1424019) in order to rebuild against new ldns
74b14c
74b14c
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.9-4
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
74b14c
74b14c
* Thu Feb 18 2016 Paul Wouters <pwouters@redhat.com> - 1.4.9-3
74b14c
- Resolves: rbz#1303965 upgrade to opendnssec-1.4.9-1.fc23 breaks old installations
74b14c
- On initial install, after token init, also run ods-ksmutil setup
74b14c
74b14c
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.9-2
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
74b14c
74b14c
* Mon Feb 01 2016 Paul Wouters <pwouters@redhat.com> - 1.4.9-1
74b14c
- Updated to 1.4.9
74b14c
- Removed merged in patch
74b14c
74b14c
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.7-3
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
74b14c
74b14c
* Tue Jun 09 2015 Paul Wouters <pwouters@redhat.com> - 1.4.7-2
74b14c
- Resolves rhbz#1219746 ods-signerd.service misplaced After= in section Service
74b14c
- Resolves rhbz#1220443 OpenDNSSEC fails to initialise a slot in softhsm on first install
74b14c
74b14c
* Tue Dec 09 2014 Paul Wouters <pwouters@redhat.com> - 1.4.7-1
74b14c
- Updated to 1.4.7 (fix zone update can get stuck, crash on retransfer cmd)
74b14c
74b14c
* Wed Oct 15 2014 Paul Wouters <pwouters@redhat.com> - 1.4.6-4
74b14c
- Change /etc/opendnssec to be ods group writable
74b14c
74b14c
* Wed Oct 08 2014 Paul Wouters <pwouters@redhat.com> - 1.4.6-3
74b14c
- Added Petr Spacek's patch that adds the config option <AllowExtraction/> (rhbz#1123354)
74b14c
74b14c
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.6-2
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
74b14c
74b14c
* Mon Jul 28 2014 Paul Wouters <pwouters@redhat.com> - 1.4.6-1
74b14c
- Updated to 1.4.6
74b14c
- Removed incorporated patch upstream
74b14c
- Remove Wants= from ods-signerd.service (rhbz#1098205)
74b14c
74b14c
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.5-3
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
74b14c
74b14c
* Fri Apr 18 2014 Paul Wouters <pwouters@redhat.com> - 1.4.5-2
74b14c
- Updated to 1.4.5
74b14c
- Added patch for serial 0 bug in XFR adapter
74b14c
74b14c
* Tue Apr 01 2014 Paul Wouters <pwouters@redhat.com> - 1.4.4-3
74b14c
- Add buildrequires for ods-kasp2html (rhbz#1073313)
74b14c
74b14c
* Sat Mar 29 2014 Paul Wouters <pwouters@redhat.com> - 1.4.4-2
74b14c
- Add requires for ods-kasp2html (rhbz#1073313)
74b14c
74b14c
* Thu Mar 27 2014 Paul Wouters <pwouters@redhat.com> - 1.4.4-1
74b14c
- Updated to 1.4.4 (compatibility with non RFC 5155 errata 3441)
74b14c
- Change the default ZSK policy from 1024 to 2048 bit RSA keys
74b14c
- Fix post to be quiet when upgrading opendnssec
74b14c
74b14c
* Thu Jan 09 2014 Paul Wouters <pwouters@redhat.com> - 1.4.3-1
74b14c
- Updated to 1.4.3 (rhel#1048449) - minor bugfixes, minor feature enhancements
74b14c
- rhel#1025985 OpenDNSSEC signer cannot be started due to a typo in service file
74b14c
74b14c
* Wed Sep 11 2013 Paul Wouters <pwouters@redhat.com> - 1.4.2-1
74b14c
- Updated to 1.4.2, bugfix release
74b14c
74b14c
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.1-2
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
74b14c
74b14c
* Fri Jun 28 2013 Paul Wouters <pwouters@redhat.com> - 1.4.1-1
74b14c
- Updated to 1.4.1. NSEC3 handling and serial number handling fixes
74b14c
- Add BuildRequire for systemd-units
74b14c
74b14c
* Sat May 11 2013 Paul Wouters <pwouters@redhat.com> - 1.4.0-1
74b14c
- Updated to 1.4.0
74b14c
74b14c
* Fri Apr 12 2013 Paul Wouters <pwouters@redhat.com> - 1.4.20-0.8.rc3
74b14c
- Updated to 1.4.0rc3
74b14c
- Enabled hardened compile, full relzo/pie
74b14c
74b14c
* Fri Jan 25 2013 Patrick Uiterwijk <puiterwijk@gmail.com> - 1.4.0-0.7.rc2
74b14c
- Updated to 1.4.0rc2, which includes svn r6952
74b14c
74b14c
* Fri Jan 18 2013 Patrick Uiterwijk <puiterwijk@gmail.com> - 1.4.0-0.6.rc1
74b14c
- Updated to 1.4.0rc1
74b14c
- Applied opendnssec-ksk-premature-retirement.patch (svn r6952)
74b14c
74b14c
* Tue Dec 18 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.5.b2
74b14c
- Updated to 1.4.0b2
74b14c
- All patches have been merged upstream
74b14c
- cron job should be marked as config file
74b14c
74b14c
* Tue Oct 30 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.4.b1
74b14c
- Added BuildRequires: procps-ng for bug OPENDNSSEC-345
74b14c
- Change RRSIG inception offset to -2h to avoid possible
74b14c
  daylight saving issues on resolvers
74b14c
- Patch to prevent removal of occluded data
74b14c
74b14c
* Wed Sep 26 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.3.b1
74b14c
- Just an EVR fix to the proper standard
74b14c
- Cleanup of spec file
74b14c
- Introduce new systemd-rpm macros (rhbz#850242)
74b14c
74b14c
* Wed Sep 12 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.b1.1
74b14c
- Updated to 1.4.0b1
74b14c
- Patch for NSEC3PARAM TTL
74b14c
- Cron job to assist narrowing ods-enforcerd timing differences
74b14c
74b14c
* Wed Aug 29 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.a3.1
74b14c
- Updated to 1.4.0a3
74b14c
- Patch to more aggressively try to resign
74b14c
- Patch to fix locking issue eating up cpu
74b14c
74b14c
* Fri Jul 20 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.0-0.a2.2
74b14c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
74b14c
74b14c
* Tue Jun 12 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.a2.1
74b14c
- Updated to 1.4.0a2
74b14c
- ksm-utils patch for ods-ksmutil to die sooner when it can't lock
74b14c
  the HSM.
74b14c
74b14c
* Wed May 16 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.a1.3
74b14c
- Patch for crasher with deleted RRsets and NSEC3/OPTOUT chains
74b14c
74b14c
* Mon Mar 26 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.a1.2
74b14c
- Added opendnssec LICENSE file from trunk (Thanks Jakob!)
74b14c
74b14c
* Mon Mar 26 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.a1.1
74b14c
- Fix macros in comment
74b14c
- Added missing -m to install target
74b14c
74b14c
* Sun Mar 25 2012 Paul Wouters <pwouters@redhat.com> - 1.4.0-0.a1
74b14c
- The 1.4.x branch no longer needs ruby, as the auditor has been removed
74b14c
- Added missing openssl-devel BuildRequire
74b14c
- Comment out <SkipPublicKey/> so keys generated by ods can be used by bind
74b14c
74b14c
* Fri Feb 24 2012 Paul Wouters <pwouters@redhat.com> - 1.3.6-3
74b14c
- Requires rubygem-soap4r when using ruby-1.9
74b14c
- Don't ghost /var/run/opendnssec
74b14c
- Converted initd to systemd
74b14c
74b14c
* Thu Nov 24 2011 root - 1.3.2-6
74b14c
- Added rubygem-dnsruby requires as rpm does not pick it up automatically
74b14c
74b14c
* Tue Nov 22 2011 root - 1.3.2-5
74b14c
- Added /var/opendnssec/signconf/ /as this temp dir is needed
74b14c
74b14c
* Mon Nov 21 2011 Paul Wouters <paul@xelerance.com> - 1.3.2-4
74b14c
- Added /var/opendnssec/signed/ as this is the default output dir
74b14c
74b14c
* Sun Nov 20 2011 Paul Wouters <paul@xelerance.com> - 1.3.2-3
74b14c
- Add ods user for opendnssec tasks
74b14c
- Added initscripts and services for ods-signerd and ods-enforcerd
74b14c
- Initialise OpenDNSSEC softhsm token on first install
74b14c
74b14c
* Wed Oct 05 2011 Paul Wouters <paul@xelerance.com> - 1.3.2-1
74b14c
- Updated to 1.3.2
74b14c
- Added dependancies on opencryptoki and softhsm
74b14c
- Don't install duplicate unreadable .sample files
74b14c
- Fix upstream conf.xml to point to actually used library paths
74b14c
74b14c
* Thu Mar  3 2011 Paul Wouters <paul@xelerance.com> - 1.2.0-1
74b14c
- Initial package for Fedora