diff --git a/.gitignore b/.gitignore index e69de29..8655656 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,6 @@ +/cronie-1.5.0.tar.gz +/cronie-1.5.1.tar.gz +/cronie-1.5.2.tar.gz +/cronie-1.5.3.tar.gz +/cronie-1.5.4.tar.gz +/cronie-1.5.5.tar.gz diff --git a/cronie.spec b/cronie.spec new file mode 100644 index 0000000..4b037b4 --- /dev/null +++ b/cronie.spec @@ -0,0 +1,543 @@ +%bcond_without selinux +%bcond_without pam +%bcond_without audit +%bcond_without inotify + +Summary: Cron daemon for executing programs at set times +Name: cronie +Version: 1.5.5 +Release: 4%{?dist} +License: MIT and BSD and ISC and GPLv2+ +URL: https://github.com/cronie-crond/cronie +Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}/cronie-%{version}.tar.gz + +Requires: dailyjobs + +%if %{with selinux} +Requires: libselinux >= 2.0.64 +Buildrequires: libselinux-devel >= 2.0.64 +%endif +%if %{with pam} +Requires: pam >= 1.0.1 +Buildrequires: pam-devel >= 1.0.1 +%endif +%if %{with audit} +Buildrequires: audit-libs-devel >= 1.4.1 +%endif + +BuildRequires: gcc +BuildRequires: systemd +Obsoletes: %{name}-sysvinit + +Requires(post): coreutils sed + +%if 0%{?fedora} && 0%{?fedora} < 28 || 0%{?rhel} && 0%{?rhel} < 8 +%{?systemd_requires} +%else +%{?systemd_ordering} # does not exist on Fedora27/RHEL7 +%endif + + +%description +Cronie contains the standard UNIX daemon crond that runs specified programs at +scheduled times and related tools. It is a fork of the original vixie-cron and +has security and configuration enhancements like the ability to use pam and +SELinux. + +%package anacron +Summary: Utility for running regular jobs +Requires: crontabs +Provides: dailyjobs +Provides: anacron = 2.4 +Obsoletes: anacron <= 2.3 +Requires(post): coreutils +Requires: %{name} = %{version}-%{release} + +%description anacron +Anacron is part of cronie that is used for running jobs with regular +periodicity which do not have exact time of day of execution. + +The default settings of anacron execute the daily, weekly, and monthly +jobs, but anacron allows setting arbitrary periodicity of jobs. + +Using anacron allows running the periodic jobs even if the system is often +powered off and it also allows randomizing the time of the job execution +for better utilization of resources shared among multiple systems. + +%package noanacron +Summary: Utility for running simple regular jobs in old cron style +Provides: dailyjobs +Requires: crontabs +Requires: %{name} = %{version}-%{release} + +%description noanacron +Old style of running {hourly,daily,weekly,monthly}.jobs without anacron. No +extra features. + +%prep +%setup -q + +%build +%configure \ +%if %{with pam} +--with-pam \ +%endif +%if %{with selinux} +--with-selinux \ +%endif +%if %{with audit} +--with-audit \ +%endif +%if %{with inotify} +--with-inotify \ +%endif +--enable-anacron \ +--enable-pie \ +--enable-relro + +%make_build V=2 + +%install +%make_install DESTMAN=$RPM_BUILD_ROOT%{_mandir} +mkdir -pm700 $RPM_BUILD_ROOT%{_localstatedir}/spool/cron +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ +mkdir -pm755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/ +%if ! %{with pam} + rm -f $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/crond +%endif +install -m 644 crond.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/crond +touch $RPM_BUILD_ROOT%{_sysconfdir}/cron.deny +install -m 644 contrib/anacrontab $RPM_BUILD_ROOT%{_sysconfdir}/anacrontab +install -c -m755 contrib/0hourly $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/0hourly +mkdir -pm 755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly +install -c -m755 contrib/0anacron $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly/0anacron +mkdir -p $RPM_BUILD_ROOT/var/spool/anacron +touch $RPM_BUILD_ROOT/var/spool/anacron/cron.daily +touch $RPM_BUILD_ROOT/var/spool/anacron/cron.weekly +touch $RPM_BUILD_ROOT/var/spool/anacron/cron.monthly + +# noanacron package +install -m 644 contrib/dailyjobs $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/dailyjobs + +# install systemd initscript +mkdir -p $RPM_BUILD_ROOT/lib/systemd/system/ +install -m 644 contrib/cronie.systemd $RPM_BUILD_ROOT/lib/systemd/system/crond.service + +%post +# run after an installation +%systemd_post crond.service + +%post anacron +[ -e /var/spool/anacron/cron.daily ] || touch /var/spool/anacron/cron.daily 2>/dev/null || : +[ -e /var/spool/anacron/cron.weekly ] || touch /var/spool/anacron/cron.weekly 2>/dev/null || : +[ -e /var/spool/anacron/cron.monthly ] || touch /var/spool/anacron/cron.monthly 2>/dev/null || : + +%preun +# run before a package is removed +%systemd_preun crond.service + +%postun +# run after a package is removed +%systemd_postun_with_restart crond.service + +%triggerun -- cronie-anacron < 1.4.1 +# empty /etc/crontab in case there are only old regular jobs +cp -a /etc/crontab /etc/crontab.rpmsave +sed -e '/^01 \* \* \* \* root run-parts \/etc\/cron\.hourly/d'\ + -e '/^02 4 \* \* \* root run-parts \/etc\/cron\.daily/d'\ + -e '/^22 4 \* \* 0 root run-parts \/etc\/cron\.weekly/d'\ + -e '/^42 4 1 \* \* root run-parts \/etc\/cron\.monthly/d' /etc/crontab.rpmsave > /etc/crontab +exit 0 + +%triggerun -- cronie < 1.4.7-2 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply crond +# to migrate them to systemd targets +/usr/bin/systemd-sysv-convert --save crond + +# The package is allowed to autostart: +/bin/systemctl enable crond.service >/dev/null 2>&1 + +/sbin/chkconfig --del crond >/dev/null 2>&1 || : +/bin/systemctl try-restart crond.service >/dev/null 2>&1 || : +/bin/systemctl daemon-reload >/dev/null 2>&1 || : + +%triggerin -- pam, glibc, libselinux +# changes in pam, glibc or libselinux can make crond crash +# when it calls pam +/bin/systemctl try-restart crond.service >/dev/null 2>&1 || : + +%files +%doc AUTHORS README ChangeLog +%{!?_licensedir:%global license %%doc} +%license COPYING +%attr(755,root,root) %{_sbindir}/crond +%attr(4755,root,root) %{_bindir}/crontab +%attr(755,root,root) %{_bindir}/cronnext +%{_mandir}/man8/crond.* +%{_mandir}/man8/cron.* +%{_mandir}/man5/crontab.* +%{_mandir}/man1/crontab.* +%{_mandir}/man1/cronnext.* +%dir %{_localstatedir}/spool/cron +%dir %{_sysconfdir}/cron.d +%if %{with pam} +%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/crond +%endif +%config(noreplace) %{_sysconfdir}/sysconfig/crond +%config(noreplace) %{_sysconfdir}/cron.deny +%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/0hourly +%attr(0644,root,root) /lib/systemd/system/crond.service + +%files anacron +%{_sbindir}/anacron +%attr(0755,root,root) %{_sysconfdir}/cron.hourly/0anacron +%config(noreplace) %{_sysconfdir}/anacrontab +%dir /var/spool/anacron +%ghost %attr(0600,root,root) %verify(not md5 size mtime) /var/spool/anacron/cron.daily +%ghost %attr(0600,root,root) %verify(not md5 size mtime) /var/spool/anacron/cron.weekly +%ghost %attr(0600,root,root) %verify(not md5 size mtime) /var/spool/anacron/cron.monthly +%{_mandir}/man5/anacrontab.* +%{_mandir}/man8/anacron.* + +%files noanacron +%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/dailyjobs + +%changelog +* Mon Jul 27 2020 Fedora Release Engineering - 1.5.5-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Mon Jul 13 2020 Tom Stellard - 1.5.5-3 +- Use make macros +- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro + +* Tue Jan 28 2020 Fedora Release Engineering - 1.5.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Oct 31 2019 Tomáš Mráz - 1.5.5-1 +- new upstream release 1.5.5 with multiple bug fixes and improvements + +* Wed Jul 24 2019 Fedora Release Engineering - 1.5.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Mon Mar 18 2019 Tomáš Mráz - 1.5.4-1 +- new upstream release 1.5.4 with regression fix + +* Fri Mar 15 2019 Tomáš Mráz - 1.5.3-1 +- new upstream release 1.5.3 fixing CVE-2019-9704 and CVE-2019-9705 + +* Thu Jan 31 2019 Fedora Release Engineering - 1.5.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Nov 30 2018 Tomáš Mráz - 1.5.2-4 +- Do not hard-require systemd as crond is used in containers without + systemd (#1654659) + +* Wed Oct 31 2018 Tomáš Mráz - 1.5.2-3 +- use role from the current context for system crontabs (#1639381) + +* Thu Jul 12 2018 Fedora Release Engineering - 1.5.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Thu May 3 2018 Tomáš Mráz - 1.5.2-1 +- new upstream release 1.5.2 + +* Wed Feb 07 2018 Fedora Release Engineering - 1.5.1-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Aug 02 2017 Fedora Release Engineering - 1.5.1-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.5.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Thu May 4 2017 Tomáš Mráz - 1.5.1-6 +- fix Y2038 problems in cron and anacron (#1445136) + +* Fri Feb 10 2017 Fedora Release Engineering - 1.5.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Tue Jan 3 2017 Tomáš Mráz - 1.5.1-4 +- make failure of creation of the ghost files in /var non-fatal + +* Mon Sep 5 2016 Tomáš Mráz - 1.5.1-3 +- on some machines the power supply is named ADP0 + +* Tue Aug 23 2016 Tomáš Mráz - 1.5.1-2 +- query power status directly from kernel + +* Thu Jun 23 2016 Tomáš Mráz - 1.5.1-1 +- new upstream release + +* Wed Feb 03 2016 Fedora Release Engineering - 1.5.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Mon Jul 13 2015 Tomáš Mráz - 1.5.0-3 +- the temp file name used by crontab needs to be ignored by crond + +* Wed Jun 17 2015 Fedora Release Engineering - 1.5.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Thu May 28 2015 Tomáš Mráz - 1.5.0-1 +- new upstream release + +* Tue Apr 21 2015 Tomáš Mráz - 1.4.12-6 +- mark the 0hourly and dailyjobs crontabs as config +- do not add already existing orphan on reload + +* Tue Feb 3 2015 Tomáš Mráz - 1.4.12-5 +- correct the permissions of the anacron timestamp files + +* Fri Jan 2 2015 Tomáš Mráz - 1.4.12-4 +- check for NULL pamh on two more places (#1176215) + +* Tue Dec 2 2014 Tomáš Mráz - 1.4.12-3 +- call PAM only for non-root user or non-system crontabs (#956157) +- bypass the PAM check in crontab for root (#1169175) + +* Tue Nov 4 2014 Tomáš Mráz - 1.4.12-2 +- refresh user entries when jobs are run + +* Wed Sep 17 2014 Marcela Mašláňová - 1.4.12-1 +- new release 1.4.12 +- remove gpl2 license, because it's part of upstream COPYING now + +* Sat Aug 16 2014 Fedora Release Engineering - 1.4.11-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Fri Jul 11 2014 Tom Callaway - 1.4.11-8 +- fix license handling + +* Sat Jun 07 2014 Fedora Release Engineering - 1.4.11-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Wed Apr 30 2014 Marcela Mašláňová - 1.4.11-6 +- unwanted fd could make trouble to SElinux 1075106 + +* Thu Jan 16 2014 Ville Skyttä - 1.4.11-5 +- Drop INSTALL from docs, fix rpmlint tabs vs spaces warning. + +* Wed Sep 25 2013 Marcela Mašláňová - 1.4.11-4 +- some jobs are not executed because not all environment variables are set 995590 +- cronie's systemd script use "KillMode=process" 919290 + +* Sat Aug 03 2013 Fedora Release Engineering - 1.4.11-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Mon Jul 22 2013 Marcela Mašláňová - 1.4.11-2 +- scriptlets are not created correctly if systemd is not in BR 986698 +- remove sub-package sysvinit, which is not needed anymore +- update license, anacron is under GPLv2+ + +* Thu Jul 18 2013 Marcela Mašláňová - 1.4.11-1 +- new release 1.4.11 (contains previous bug fixes from 1.4.10-5) + +* Tue Jun 11 2013 Tomáš Mráz - 1.4.10-5 +- add support for RANDOM_DELAY - delaying job startups +- pass some environment variables to processes (LANG, etc.) (#969761) +- do not use putenv() with string literals (#971516) + +* Wed Feb 13 2013 Fedora Release Engineering - 1.4.10-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Wed Jan 2 2013 Marcela Mašláňová - 1.4.10-3 +- change configuration files to 644 +- change 6755 to 4755 for crontab binary + +* Tue Nov 27 2012 Marcela Mašláňová - 1.4.10-1 +- New release 1.4.10 + +* Thu Nov 22 2012 Marcela Mašláňová - 1.4.9-1 +- New release 1.4.9 + +* Wed Sep 05 2012 Václav Pavlín - 1.4.8-13 +- Scriptlets replaced with new systemd macros (#850070) + +* Fri Jul 27 2012 Fedora Release Engineering - 1.4.8-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Jan 13 2012 Fedora Release Engineering - 1.4.8-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Wed Oct 26 2011 Fedora Release Engineering - 1.4.8-10 +- Rebuilt for glibc bug#747377 + +* Tue Oct 25 2011 Tomáš Mráz - 1.4.8-9 +- make crond run a little bit later in the boot process (#747759) + +* Mon Oct 17 2011 Marcela Mašláňová - 1.4.8-8 +- change triggerun to fix 735802 during upgrade + +* Wed Jul 27 2011 Karsten Hopp 1.4.8-7 +- rebuild again, ppc still had the broken rpm in the buildroots + +* Thu Jul 21 2011 Rex Dieter 1.4.8-6 +- rebuild (broken rpm in buildroot) + +* Thu Jul 21 2011 Marcela Mašláňová - 1.4.8-5 +- fix permission of init.d/crond + +* Thu Jun 30 2011 Tomáš Mráz - 1.4.8-4 +- drop the without systemd build condition +- add the chkconfig readding trigger to the sysvinit subpackage + +* Wed Jun 29 2011 Tomáš Mráz - 1.4.8-3 +- start crond after auditd + +* Wed Jun 29 2011 Tomáš Mráz - 1.4.8-2 +- fix inotify support to not leak fds (#717505) + +* Tue Jun 28 2011 Marcela Mašláňová - 1.4.8-1 +- update to 1.4.8 +- create sub-package sysvinit for initscript + +* Mon May 9 2011 Marcela Mašláňová - 1.4.7-3 +- missing requirement on systemd-sysv for scriptlets + +* Thu May 05 2011 Tomáš Mráz - 1.4.7-2 +- use only systemd units with systemd +- add trigger for restart on glibc, libselinux or pam upgrades (#699189) + +* Tue Mar 15 2011 Marcela Mašláňová - 1.4.7-1 +- new release 1.4.7 + +* Tue Feb 08 2011 Fedora Release Engineering - 1.4.6-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Jan 17 2011 Marcela Mašláňová - 1.4.6-8 +- enable crond even with systemctl + +* Thu Dec 16 2010 Marcela Mašláňová - 1.4.6-7 +- 663193 rewritten selinux support + +* Wed Dec 15 2010 Marcela Mašláňová - 1.4.6-6 +- apply selinux patch from dwalsh + +* Fri Dec 10 2010 Tomas Mraz - 1.4.6-5 +- do not lock jobs that fall out of allowed range - 661966 + +* Thu Dec 02 2010 Marcela Mašláňová - 1.4.6-4 +- fix post (thanks plautrba for review) + +* Tue Nov 30 2010 Marcela Mašláňová - 1.4.6-3 +- systemd init script 617320 + +* Tue Nov 30 2010 Marcela Mašláňová - 1.4.6-2 +- fix typos in man pages + +* Fri Oct 22 2010 Marcela Mašláňová - 1.4.6-1 +- update to 1.4.6 + +* Fri Aug 13 2010 Marcela Mašláňová - 1.4.5-4 +- 623908 fix fd leak in anacron, which caused denail of prelink + and others + +* Mon Aug 9 2010 Marcela Mašláňová - 1.4.5-2 +- remove sendmail from requirements. If it's not installed, it will + log into (r)syslog. + +* Mon Aug 2 2010 Marcela Mašláňová - 1.4.5-1 +- update to new release + +* Fri Feb 19 2010 Marcela Mašláňová - 1.4.4-1 +- update to new release + +* Mon Feb 15 2010 Marcela Mašláňová - 1.4.3-3 +- 564894 FTBFS DSOLinking + +* Thu Nov 5 2009 Marcela Mašláňová - 1.4.3-2 +- 533189 pam needs add a line and selinux needs defined one function + +* Fri Oct 30 2009 Marcela Mašláňová - 1.4.3-1 +- 531963 and 532482 creating noanacron package + +* Mon Oct 19 2009 Marcela Mašláňová - 1.4.2-2 +- 529632 service crond stop returns appropriate value + +* Mon Oct 12 2009 Marcela Mašláňová - 1.4.2-1 +- new release + +* Fri Aug 21 2009 Tomas Mraz - 1.4.1-3 +- rebuilt with new audit + +* Fri Aug 14 2009 Tomas Mraz - 1.4.1-2 +- create the anacron timestamps in correct post script + +* Fri Aug 14 2009 Marcela Mašláňová - 1.4.1-1 +- update to 1.4.1 +- create and own /var/spool/anacron/cron.{daily,weekly,monthly} to + remove false warning about non existent files +- Resolves: 517398 + +* Wed Aug 5 2009 Tomas Mraz - 1.4-4 +- 515762 move anacron provides and obsoletes to the anacron subpackage + +* Fri Jul 24 2009 Fedora Release Engineering - 1.4-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Mon Jul 20 2009 Marcela Mašláňová - 1.4-2 +- merge cronie and anacron in new release of cronie +- obsolete/provide anacron in spec + +* Thu Jun 18 2009 Marcela Mašláňová - 1.3-2 +- 506560 check return value of access + +* Mon Apr 27 2009 Marcela Mašláňová - 1.3-1 +- new release + +* Fri Apr 24 2009 Marcela Mašláňová - 1.2-8 +- 496973 close file descriptors after exec + +* Mon Mar 9 2009 Tomas Mraz - 1.2-7 +- rebuild + +* Tue Feb 24 2009 Fedora Release Engineering - 1.2-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Tue Dec 23 2008 Marcela Mašláňová - 1.2-5 +- 477100 NO_FOLLOW was removed, reload after change in symlinked + crontab is needed, man updated. + +* Fri Oct 24 2008 Marcela Mašláňová - 1.2-4 +- update init script + +* Thu Sep 25 2008 Marcela Maslanova - 1.2-3 +- add sendmail file into requirement, cause it's needed some MTA + +* Thu Sep 18 2008 Marcela Maslanova - 1.2-2 +- 462252 /etc/sysconfig/crond does not need to be executable + +* Thu Jun 26 2008 Marcela Maslanova - 1.2-1 +- update to 1.2 + +* Tue Jun 17 2008 Tomas Mraz - 1.1-3 +- fix setting keycreate context +- unify logging a bit +- cleanup some warnings and fix a typo in TZ code +- 450993 improve and fix inotify support + +* Wed Jun 4 2008 Marcela Maslanova - 1.1-2 +- 49864 upgrade/update problem. Syntax error in spec. + +* Wed May 28 2008 Marcela Maslanova - 1.1-1 +- release 1.1 + +* Tue May 20 2008 Marcela Maslanova - 1.0-6 +- 446360 check for lock didn't call chkconfig + +* Tue Feb 12 2008 Marcela Maslanova - 1.0-5 +- upgrade from less than cronie-1.0-4 didn't add chkconfig + +* Wed Feb 6 2008 Marcela Maslanova - 1.0-4 +- 431366 after reboot wasn't cron in chkconfig + +* Tue Feb 5 2008 Marcela Maslanova - 1.0-3 +- 431366 trigger part => after update from vixie-cron on cronie will + be daemon running. + +* Wed Jan 30 2008 Marcela Maslanova - 1.0-2 +- change the provides on higher version than obsoletes + +* Tue Jan 8 2008 Marcela Maslanova - 1.0-1 +- packaging cronie +- thank's for help with packaging to my reviewers diff --git a/sources b/sources new file mode 100644 index 0000000..43e3c1d --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (cronie-1.5.5.tar.gz) = 3cb53ee4db7722c0764a1d2e5dfe773cfc31c91e9d0798d579a58ec8c29a1f42238e18c27baae2eaff6df37250cd06dddbf77f0020aed68b9712fd7332efb912 diff --git a/tests/Can-t-remove-crontab-from-expired-accounts/Makefile b/tests/Can-t-remove-crontab-from-expired-accounts/Makefile new file mode 100644 index 0000000..eea8ff8 --- /dev/null +++ b/tests/Can-t-remove-crontab-from-expired-accounts/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts +# Description: Test for Can't remove crontab from expired accounts +# Author: Karel Volny +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Karel Volny " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for Can't remove crontab from expired accounts" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Can-t-remove-crontab-from-expired-accounts/PURPOSE b/tests/Can-t-remove-crontab-from-expired-accounts/PURPOSE new file mode 100644 index 0000000..addedc0 --- /dev/null +++ b/tests/Can-t-remove-crontab-from-expired-accounts/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts +Description: Test for Can't remove crontab from expired accounts +Author: Karel Volny diff --git a/tests/Can-t-remove-crontab-from-expired-accounts/runtest.sh b/tests/Can-t-remove-crontab-from-expired-accounts/runtest.sh new file mode 100644 index 0000000..73d8914 --- /dev/null +++ b/tests/Can-t-remove-crontab-from-expired-accounts/runtest.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts +# Description: Test for Can't remove crontab from expired accounts +# Author: Karel Volny +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" +TestUser="usertest" +ct_file="/var/spool/cron/$TestUser" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "useradd $TestUser" 0 "Adding the testing user" + rlPhaseEnd + + rlPhaseStartTest + rlRun "echo '1 1 1 1 1 nonsense' | crontab -u $TestUser -" 0 "Setting up crontab for the testing user" + rlRun -s "crontab -u $TestUser -l" 0 "Checking the testing crontab" + rlAssertGrep "nonsense" $rlRun_LOG + rlRun "chage -E 1 $TestUser" 0 "Expiring the testing user account" + rlRun "crontab -u $TestUser -r" 0 "Removing the testing crontab" + rlAssertNotGrep "not allowed" $rlRun_LOG + rlRun -s "crontab -u $TestUser -l" 1 "Checking the testing crontab (should not exist)" + rlAssertGrep "no crontab for $TestUser" $rlRun_LOG + rlAssertNotGrep "not allowed" $rlRun_LOG + rlAssertNotExists "$ct_file" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "userdel $TestUser" 0 "Deleting the testing user" + rlRun "popd" + rlRun "rm -rf $TmpDir $ct_file" 0 "Removing tmp directory and possible cruft" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Cron-does-uid-lookups-for-non-existent-users/Makefile b/tests/Cron-does-uid-lookups-for-non-existent-users/Makefile new file mode 100644 index 0000000..230390a --- /dev/null +++ b/tests/Cron-does-uid-lookups-for-non-existent-users/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users +# Description: Test for Cron does uid lookups for non-existent users +# Author: Vaclav Danek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Vaclav Danek " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for Cron does uid lookups for non-existent users" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Cron-does-uid-lookups-for-non-existent-users/PURPOSE b/tests/Cron-does-uid-lookups-for-non-existent-users/PURPOSE new file mode 100644 index 0000000..9d7cf13 --- /dev/null +++ b/tests/Cron-does-uid-lookups-for-non-existent-users/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users +Description: Test for Cron does uid lookups for non-existent users +Author: Vaclav Danek +Bug summary: Cron does uid lookups for non-existent users diff --git a/tests/Cron-does-uid-lookups-for-non-existent-users/runtest.sh b/tests/Cron-does-uid-lookups-for-non-existent-users/runtest.sh new file mode 100644 index 0000000..72329da --- /dev/null +++ b/tests/Cron-does-uid-lookups-for-non-existent-users/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users +# Description: Test for Cron does uid lookups for non-existent users +# Author: Vaclav Danek +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "sleep 61 | crontab -" 0 + rlRun -s "tail /var/log/cron" 0 + rlAssertNotGrep "ORPHAN (no passwd entry)" $rlRun_LOG + rm -f $rlRun_LOG + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/MAILTO-problem-with-anacron/Makefile b/tests/MAILTO-problem-with-anacron/Makefile new file mode 100644 index 0000000..cc54f39 --- /dev/null +++ b/tests/MAILTO-problem-with-anacron/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron +# Description: Test for MAILTO problem with anacron +# Author: Karel Volny +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/MAILTO-problem-with-anacron +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE anacrontab + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Karel Volny " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for MAILTO problem with anacron" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/MAILTO-problem-with-anacron/PURPOSE b/tests/MAILTO-problem-with-anacron/PURPOSE new file mode 100644 index 0000000..0eb365c --- /dev/null +++ b/tests/MAILTO-problem-with-anacron/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron +Description: Test for MAILTO problem with anacron +Author: Karel Volny +Bug summary: MAILTO problem with anacron diff --git a/tests/MAILTO-problem-with-anacron/anacrontab b/tests/MAILTO-problem-with-anacron/anacrontab new file mode 100644 index 0000000..c672b71 --- /dev/null +++ b/tests/MAILTO-problem-with-anacron/anacrontab @@ -0,0 +1,5 @@ +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=testuser1 + +1 0 test echo "Hello anacron!" diff --git a/tests/MAILTO-problem-with-anacron/runtest.sh b/tests/MAILTO-problem-with-anacron/runtest.sh new file mode 100644 index 0000000..9504398 --- /dev/null +++ b/tests/MAILTO-problem-with-anacron/runtest.sh @@ -0,0 +1,155 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron +# Description: Test for MAILTO problem with anacron +# Author: Karel Volny +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" +TestDir=$PWD + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "useradd testuser1" 0 "Adding the testing user" + rlFileBackup --clean /var/spool/mail/root /var/log/cron + # stop cron not to interfere with our logs + rlServiceStop crond + rlPhaseEnd + + # email should be sent to user specified via MAILTO (testuser1) + rlPhaseStartTest anacronmail + rlRun "truncate --size 0 /var/spool/mail/testuser1" 0 "Truncating mail queue for the user 'testuser1'" + rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log" + # DEBUG + echo "anacrontab:" + echo "***********" + cat ${TestDir}/anacrontab + rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job" + sleep 5 + # DEBUG + echo "/var/spool/mail/testuser1:" + echo "**************************" + cat /var/spool/mail/testuser1 + rlAssertGrep "anacron" "/var/spool/mail/testuser1" + rlAssertGrep "To: testuser1" "/var/spool/mail/testuser1" + # DEBUG + echo "/var/log/cron:" + echo "**************" + cat /var/log/cron + rlAssertGrep "\(produced output\)" /var/log/cron + rlAssertNotGrep "not mailing" /var/log/cron -i + rlPhaseEnd + + # email should NOT be sent with empty MAILTO + rlPhaseStartTest noanacronmail-empty + rlRun "truncate --size 0 /var/spool/mail/root" 0 "Truncating mail queue for root" + rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log" + rlRun "sed -i -e 's/MAILTO=testuser1/MAILTO=/' ${TestDir}/anacrontab" 0 "Removing mailto user from anacrontab" + # DEBUG + echo "anacrontab:" + echo "***********" + cat ${TestDir}/anacrontab + rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job" + sleep 5 + # DEBUG + echo "/var/spool/mail/root:" + echo "*********************" + cat /var/spool/mail/root + rlAssertNotGrep "anacron" "/var/spool/mail/root" + # DEBUG + echo "/var/log/cron:" + echo "**************" + cat /var/log/cron + rlAssertGrep "\(produced output\)" /var/log/cron + rlAssertGrep "not mailing" /var/log/cron -i + rlPhaseEnd + + # email should be sent to nonexisting user double-doublequotes, as the string after '=' is treated literally + rlPhaseStartTest anacronmail-quotes + rlRun "truncate --size 0 /var/spool/mail/root" 0 "Truncating mail queue for root" + rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log" + rlRun "sed -i -e 's/MAILTO=/MAILTO=\"\"/' ${TestDir}/anacrontab" 0 "Setting mailto to double quotes in anacrontab" + # DEBUG + echo "anacrontab:" + echo "***********" + cat ${TestDir}/anacrontab + rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job" + sleep 5 + # DEBUG + echo "/var/spool/mail/root:" + echo "*********************" + cat /var/spool/mail/root + rlAssertGrep "anacron" "/var/spool/mail/root" + #rlAssertGrep "To: \"\"" "/var/spool/mail/root" + # ^ this doesn't work in Beaker for some reason, check the quotes in 'Received: ... for "";' + rlAssertGrep "for \"\"" "/var/spool/mail/root" + # DEBUG + echo "/var/log/cron:" + echo "**************" + cat /var/log/cron + rlAssertGrep "\(produced output\)" /var/log/cron + rlAssertNotGrep "not mailing" /var/log/cron -i + rlPhaseEnd + + # email should be sent to the user running anacron, when MAILTO is missing + rlPhaseStartTest anacronmail-missing + rlRun "truncate --size 0 /var/spool/mail/root" 0 "Truncating mail queue for root" + rlRun "truncate --size 0 /var/log/cron" 0 "Truncating cron log" + rlRun "sed -i -e '/MAILTO/d' ${TestDir}/anacrontab" 0 "Removing mailto from anacrontab" + # DEBUG + echo "anacrontab:" + echo "***********" + cat ${TestDir}/anacrontab + rlRun "anacron -f -n -d -t ${TestDir}/anacrontab" 0 "Forcing anacron to run job" + sleep 5 + # DEBUG + echo "/var/spool/mail/root:" + echo "*********************" + cat /var/spool/mail/root + rlAssertGrep "anacron" "/var/spool/mail/root" + # DEBUG + echo "/var/log/cron:" + echo "**************" + cat /var/log/cron + rlAssertGrep "\(produced output\)" /var/log/cron + rlAssertNotGrep "not mailing" /var/log/cron -i + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "userdel testuser1" + rlServiceRestore crond + rlFileRestore + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Make-crontab-a-PIE/Makefile b/tests/Make-crontab-a-PIE/Makefile new file mode 100644 index 0000000..43e6a94 --- /dev/null +++ b/tests/Make-crontab-a-PIE/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/Regression/Regression/Make-crontab-a-PIE +# Description: What the test does +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/Regression/Make-crontab-a-PIE +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: What the test does" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie elfutils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Make-crontab-a-PIE/PURPOSE b/tests/Make-crontab-a-PIE/PURPOSE new file mode 100644 index 0000000..2d2bf11 --- /dev/null +++ b/tests/Make-crontab-a-PIE/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/Regression/Regression/Make-crontab-a-PIE +Description: What the test does +Author: Jakub Prokes diff --git a/tests/Make-crontab-a-PIE/runtest.sh b/tests/Make-crontab-a-PIE/runtest.sh new file mode 100644 index 0000000..b0341a1 --- /dev/null +++ b/tests/Make-crontab-a-PIE/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/Regression/Regression/Make-crontab-a-PIE +# Description: What the test does +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="cronie vixie-cron" + +function myAssertRpms() { + rlRun "rpm -q $*" $((${#@}-1)) "One of required packages was found"; +} + + +rlJournalStart + rlPhaseStartSetup + myAssertRpms $PACKAGES + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "eu-readelf -h /usr/bin/crontab | grep -E 'Type:[[:space:]]+DYN[[:space:]]+\(Shared object file\)'" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/anacron-segfaults-with-certain-config-data-2/Makefile b/tests/anacron-segfaults-with-certain-config-data-2/Makefile new file mode 100644 index 0000000..4323b82 --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data +# Description: try some invalid configs for anacron to check config parser +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2 +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE configs + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: try some invalid configs for anacron to check config parser" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/anacron-segfaults-with-certain-config-data-2/PURPOSE b/tests/anacron-segfaults-with-certain-config-data-2/PURPOSE new file mode 100644 index 0000000..6c8e9e2 --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2 +Description: try some invalid configs for anacron to check config parser +Author: Jakub Prokes diff --git a/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-01_1 b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-01_1 new file mode 100644 index 0000000..3f10d0b --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-01_1 @@ -0,0 +1,16 @@ +# /etc/anacrontab: configuration file for anacron + +# See anacron(8) and anacrontab(5) for details. + +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +# the maximal random delay added to the base delay of the jobs +RANDOM_DELAY=45 +# the jobs will be started during the following hours only +START_HOURS_RANGE=0 + +#period in days delay in minutes job-identifier command +1 5 cron.daily nice run-parts /etc/cron.daily +7 25 cron.weekly nice run-parts /etc/cron.weekly +@monthly 45 cron.monthly nice run-parts /etc/cron.monthly diff --git a/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-02_0 b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-02_0 new file mode 100644 index 0000000..fee29eb --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-02_0 @@ -0,0 +1,16 @@ +# /etc/anacrontab: configuration file for anacron + +# See anacron(8) and anacrontab(5) for details. + +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +# the maximal random delay added to the base delay of the jobs +RANDOM_DELAY=45 +# the jobs will be started during the following hours only +START_HOURS_RANGE=3-8 + +#period in days delay in minutes job-identifier command +1 5 cron.daily nice run-parts /etc/cron.daily +7 25 cron.weekly nice run-parts /etc/cron.weekly +@monthly 45 cron.monthly nice run-parts /etc/cron.monthly diff --git a/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-03_1 b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-03_1 new file mode 100644 index 0000000..1767210 --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-03_1 @@ -0,0 +1,18 @@ +# /etc/anacrontab: configuration file for anacron + +# See anacron(8) and anacrontab(5) for details. + +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +# the maximal random delay added to the base delay of the jobs +RANDOM_DELAY=45 +VAR=8 +# the jobs will be started during the following hours only +START_HOURS_RANGE=3-$VAR +#START_HOURS_RANGE=0 + +#period in days delay in minutes job-identifier command +1 5 cron.daily nice run-parts /etc/cron.daily +7 25 cron.weekly nice run-parts /etc/cron.weekly +@monthly 45 cron.monthly nice run-parts /etc/cron.monthly diff --git a/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-04_1 b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-04_1 new file mode 100644 index 0000000..504a7cb --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-04_1 @@ -0,0 +1,17 @@ +# /etc/anacrontab: configuration file for anacron + +# See anacron(8) and anacrontab(5) for details. + +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +# the maximal random delay added to the base delay of the jobs +RANDOM_DELAY=45 +%@$&=^^^^ +# the jobs will be started during the following hours only +START_HOURS_RANGE=%@$&=^^^^ + +#period in days delay in minutes job-identifier command +1 5 cron.daily nice run-parts /etc/cron.daily +7 25 cron.weekly nice run-parts /etc/cron.weekly +@monthly 45 cron.monthly nice run-parts /etc/cron.monthly diff --git a/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-05_1 b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-05_1 new file mode 100644 index 0000000..c2d2b58 --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/configs/scenario-05_1 @@ -0,0 +1,14 @@ +# /etc/anacrontab: configuration file for anacron + +# See anacron(8) and anacrontab(5) for details. + +SHELL=/bin/sh +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +# the maximal random delay added to the base delay of the jobs +RANDOM_DELAY=%@$&=^^^^ + +#period in days delay in minutes job-identifier command +1 5 cron.daily nice run-parts /etc/cron.daily +7 25 cron.weekly nice run-parts /etc/cron.weekly +@monthly 45 cron.monthly nice run-parts /etc/cron.monthly diff --git a/tests/anacron-segfaults-with-certain-config-data-2/runtest.sh b/tests/anacron-segfaults-with-certain-config-data-2/runtest.sh new file mode 100644 index 0000000..bf78c58 --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/runtest.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2 +# Description: try some invalid configs for anacron to check config parser +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2014 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +assertRpms() { + rlRun "rpm -q $*" 0-$((${#@}-1)) "One of required packages was found"; + RC=$?; + [[ $RC -lt ${#@} ]] && return 0; + return $RC; +} + +PACKAGES="${PACKAGES:-cronie vixie-cron}" + +rlJournalStart + rlPhaseStartSetup + assertRpms $PACKAGES + rlPhaseEnd + + rlPhaseStartTest + for scenario in ./configs/*; do + [[ ! -f $scenario ]] && rlFail "$scenario isn't regular file"; + ## File name has 'special' format: scenario-X_Y where X is scenario number and Y is expected + ## exit code. And of course there must be some issues related to RHEL 5 :-) + if rlIsRHEL 5; then + rlRun "anacron -f -u -d -t $(readlink -f $scenario)" 0 "Testing $(basename ${scenario%_[0-9]})"; + else + if rlRun "anacron -T -t $scenario;" ${scenario##*_} "Verifying $(basename ${scenario%_[0-9]})"; then + rlRun "anacron -f -u -d -t $scenario" 0 "Testing $(basename ${scenario%_[0-9]})"; + else + [[ $? -eq 139 ]] && cat $scenario; + fi + fi + done + rlPhaseEnd + + rlPhaseStartCleanup + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/anacron-segfaults-with-certain-config-data/Makefile b/tests/anacron-segfaults-with-certain-config-data/Makefile new file mode 100644 index 0000000..e4475ae --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data +# Description: Test for anacron segfaults with certain config data +# Author: Robin Hack +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE core.sh + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Robin Hack " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for anacron segfaults with certain config data" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 20m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/anacron-segfaults-with-certain-config-data/PURPOSE b/tests/anacron-segfaults-with-certain-config-data/PURPOSE new file mode 100644 index 0000000..28d8f4b --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data +Description: anacron segfaults with certain config data +Author: Robin Hack diff --git a/tests/anacron-segfaults-with-certain-config-data/core.sh b/tests/anacron-segfaults-with-certain-config-data/core.sh new file mode 100644 index 0000000..21c0cc9 --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data/core.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "$1" > /tmp/core.lock diff --git a/tests/anacron-segfaults-with-certain-config-data/runtest.sh b/tests/anacron-segfaults-with-certain-config-data/runtest.sh new file mode 100644 index 0000000..a2d784d --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data/runtest.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data +# Description: Test for anacron segfaults with certain config data +# Author: Robin Hack +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup "Set anacron" + rlAssertRpm $PACKAGE + TESTDIR="${PWD}" + + rlFileBackup "/etc/anacrontab" + + rlRun "echo 'START_HOURS_RANGE=0' > /etc/anacrontab" + + # Prepare coredump handler + rlServiceStop crond + rlRun "chmod +x ${TESTDIR}/core.sh" + + rlRun "cat /proc/sys/kernel/core_pattern > /tmp/core_pattern" + rlRun "echo \"|${TESTDIR}/core.sh %e\" > /proc/sys/kernel/core_pattern" + rlPhaseEnd + + rlPhaseStartTest + rlRun "anacron" + + rlRun "sleep 2" 0 "Wait for kernel" + + # Anacron segfaults + rlAssertNotExists "/tmp/core.lock" + if [ -s "/tmp/core.lock" ]; then + rlAssertNotGrep "anacron" "/tmp/core.lock" + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "cat /tmp/core_pattern > /proc/sys/kernel/core_pattern" + + rm -f /tmp/core.lock + rm -f /tmp/core_pattern + killall anacron + + rlFileRestore + rlServiceRestore crond + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/config-parsing-issue/Makefile b/tests/config-parsing-issue/Makefile new file mode 100644 index 0000000..894a5c3 --- /dev/null +++ b/tests/config-parsing-issue/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/config-parsing-issue +# Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/config-parsing-issue +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie-anacron" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/config-parsing-issue/PURPOSE b/tests/config-parsing-issue/PURPOSE new file mode 100644 index 0000000..fe80c7e --- /dev/null +++ b/tests/config-parsing-issue/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/config-parsing-issue +Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like +Author: Jakub Prokes +Bug summary: cronie-anacron-1.4.4-14.el6.x86_64 doesn't like its own /etc/anacrontab syntax diff --git a/tests/config-parsing-issue/runtest.sh b/tests/config-parsing-issue/runtest.sh new file mode 100644 index 0000000..d95adab --- /dev/null +++ b/tests/config-parsing-issue/runtest.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/config-parsing-issue +# Description: Test for cronie-anacron-1.4.4-14.el6.x86_64 doesn't like +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie-anacron" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "grep '^SHELL' /etc/anacrontab"; + rlRun "grep '^PATH' /etc/anacrontab"; + rlRun "grep '^MAILTO' /etc/anacrontab"; + rlPhaseEnd + + rlPhaseStartTest + rlRun "anacron -T" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/Makefile b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/Makefile new file mode 100644 index 0000000..c4d85ea --- /dev/null +++ b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down +# Description: Test for cron daemon fails to log that it is shutting down. +# Author: Robin Hack +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Robin Hack " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for cron daemon fails to log that it is shutting down." >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 20m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/PURPOSE b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/PURPOSE new file mode 100644 index 0000000..4b459e8 --- /dev/null +++ b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down +Description: Test for cron daemon fails to log that it is shutting down. +Author: Robin Hack +Bug summary: cron daemon fails to log that it is shutting down. diff --git a/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/runtest.sh b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/runtest.sh new file mode 100644 index 0000000..0aa147d --- /dev/null +++ b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/runtest.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down +# Description: Test for cron daemon fails to log that it is shutting down. +# Author: Robin Hack +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlServiceStop crond + rlPhaseEnd + + rlPhaseStartTest + start_time=$(timedatectl | grep "Local time" | awk '{print$4" "$5}') + rlServiceStart crond + sleep 20 + rlRun "journalctl --since \"$start_time\" | grep \"(CRON) INFO\"" 0 "cron startup" + rlServiceStop crond + # give dbus and cronie some time to shut down... + sleep 20 + rlRun "journalctl --since \"$start_time\" | grep \"(CRON) INFO (Shutting down)\"" 0 "cron shutdown" + # DEBUG + journalctl _COMM=cron --since="$start_time" + rlPhaseEnd + + rlPhaseStartCleanup + rlServiceRestore crond + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/crond-is-missing-RELRO-flags/Makefile b/tests/crond-is-missing-RELRO-flags/Makefile new file mode 100644 index 0000000..87a9651 --- /dev/null +++ b/tests/crond-is-missing-RELRO-flags/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/crond-is-missing-RELRO-flags +# Description: Test for crond is missing RELRO flags +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/crond-is-missing-RELRO-flags +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Martin Cermak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for crond is missing RELRO flags" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie elfutils" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/crond-is-missing-RELRO-flags/PURPOSE b/tests/crond-is-missing-RELRO-flags/PURPOSE new file mode 100644 index 0000000..1ea8ffc --- /dev/null +++ b/tests/crond-is-missing-RELRO-flags/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/cronie/Regression/crond-is-missing-RELRO-flags +Description: Test for crond is missing RELRO flags +Author: Martin Cermak +Bug summary: crond is missing RELRO flags + diff --git a/tests/crond-is-missing-RELRO-flags/runtest.sh b/tests/crond-is-missing-RELRO-flags/runtest.sh new file mode 100644 index 0000000..c6b55df --- /dev/null +++ b/tests/crond-is-missing-RELRO-flags/runtest.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/crond-is-missing-RELRO-flags +# Description: Test for crond is missing RELRO flags +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlPhaseEnd + + rlPhaseStartTest + rlRun "eu-readelf -l /usr/sbin/crond | fgrep -q 'GNU_RELRO'" 0 "Binary was compiled with RELRO." + rlPhaseEnd +rlJournalEnd diff --git a/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/Makefile b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/Makefile new file mode 100644 index 0000000..729126c --- /dev/null +++ b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error +# Description: Test for crond subtask abnormal termination removes pid +# Author: Robin Hack +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE crontab-job run-job.sh + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Robin Hack " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for crond subtask abnormal termination removes pid" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 20m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/PURPOSE b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/PURPOSE new file mode 100644 index 0000000..3bc1db0 --- /dev/null +++ b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error +Description: Test for crond subtask abnormal termination removes pid +Author: Robin Hack +Bug summary: crond subtask abnormal termination removes pid file in error diff --git a/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/crontab-job b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/crontab-job new file mode 100644 index 0000000..390ab9b --- /dev/null +++ b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/crontab-job @@ -0,0 +1 @@ +*/1 * * * * /tmp/run-job.sh diff --git a/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/run-job.sh b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/run-job.sh new file mode 100644 index 0000000..265e8db --- /dev/null +++ b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/run-job.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ -s /tmp/run-job.lock ]; then + exit 0 +fi + +echo $PPID > /tmp/run-job.lock +sleep 1234567 +exit 0 diff --git a/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/runtest.sh b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/runtest.sh new file mode 100644 index 0000000..caaa895 --- /dev/null +++ b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/runtest.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error +# Description: Test for crond subtask abnormal termination removes pid +# Author: Robin Hack +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2015 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + + rlRun "cp ./run-job.sh /tmp/" + rlRun "chmod +x /tmp/run-job.sh" + rm -f /tmp/run-job.lock + + rlServiceStop crond + rlServiceStart crond + rlRun "crontab -u root ./crontab-job" + rlRun "sleep 60" 0 "Wait for cron job to run" + rlPhaseEnd + + rlPhaseStartTest + if [ -s /var/run/crond.pid ]; then + rlPass "Crond pid file exists"; + else + rlFail "Cront pid file doesn't exists or is empty" + fi + + # /tmp/run-job.lock contains PPID of my job + rlRun "kill -SIGTERM $(cat /tmp/run-job.lock)" + + # Cut and pasta! Check file again! + # We love boiler plate code in our tests! + if [ -s /var/run/crond.pid ]; then + rlPass "Crond pid file exists"; + else + rlFail "Cront pid file doesn't exists or is empty" + fi + rlPhaseEnd + + rlPhaseStartCleanup + killall sleep + crontab -u root -r + rm -f /tmp/run-job.sh + rm -f /tmp/run-job.lock + + rlServiceStop crond + rlServiceRestore crond + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/cronie-jobs-environment/Makefile b/tests/cronie-jobs-environment/Makefile new file mode 100644 index 0000000..c2a43a8 --- /dev/null +++ b/tests/cronie-jobs-environment/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/cronie-jobs-environment +# Description: testing EUID with jobs are executed and if LANG is correctly set +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/cronie-jobs-environment +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE libfaketime-0.9.1.tar.gz crontab.temp cron_test.sh + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: testing EUID with jobs are executed and if LANG is correctly set" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 10m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/cronie-jobs-environment/PURPOSE b/tests/cronie-jobs-environment/PURPOSE new file mode 100644 index 0000000..6ef4539 --- /dev/null +++ b/tests/cronie-jobs-environment/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Regression/cronie-jobs-environment +Description: testing EUID with jobs are executed and if LANG is correctly set +Author: Jakub Prokes diff --git a/tests/cronie-jobs-environment/cron_test.sh b/tests/cronie-jobs-environment/cron_test.sh new file mode 100644 index 0000000..6a82d15 --- /dev/null +++ b/tests/cronie-jobs-environment/cron_test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +printf "LANG=$LANG\n" > /tmp/cronie-jobs-environment.log; +printf "EUID=$EUID\n" >> /tmp/cronie-jobs-environment.log; + diff --git a/tests/cronie-jobs-environment/crontab.temp b/tests/cronie-jobs-environment/crontab.temp new file mode 100644 index 0000000..643879d --- /dev/null +++ b/tests/cronie-jobs-environment/crontab.temp @@ -0,0 +1,12 @@ +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat +# | | | | | +# * * * * * command to be executed + +CRON_CORRECT_MAIL_HEADER=1 + +* * * * * %TMPDIR/cron_test.sh diff --git a/tests/cronie-jobs-environment/libfaketime-0.9.1.tar.gz b/tests/cronie-jobs-environment/libfaketime-0.9.1.tar.gz new file mode 100644 index 0000000..9913d21 Binary files /dev/null and b/tests/cronie-jobs-environment/libfaketime-0.9.1.tar.gz differ diff --git a/tests/cronie-jobs-environment/runtest.sh b/tests/cronie-jobs-environment/runtest.sh new file mode 100644 index 0000000..c6d83ac --- /dev/null +++ b/tests/cronie-jobs-environment/runtest.sh @@ -0,0 +1,124 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/cronie-jobs-environment +# Description: testing EUID with jobs are executed and if LANG is correctly set +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + + +## Is nice to know when things going wrong +trap 'errorHandler ${LINENO}' ERR; +function errorHandler() { + local code="${?}"; + local lineNO="$1"; + + case $code in + 127) + rlFail "Command not found on line $lineNO" + ;; + *) + rlFail "Unhandled error $code near line $lineNO"; + ;; + esac +} + +function makeUser() { + local userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')"; + while getent passwd $userName; do + userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')"; + done + useradd -d $tmpDir $userName; + echo $userName; +} + + +PACKAGE="cronie" +declare -r LIBFAKETTIMEPACKAGE="libfaketime-0.9.1.tar.gz"; +declare -r LIBFAKETIME="libfaketime.so.1"; + +rlJournalStart + rlPhaseStartSetup "Setup test environment" + rlAssertRpm $PACKAGE + rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory"; + testDir="$(pwd)"; + rlRun "chmod 755 $tmpDir" 0 "Setting permissions for tmp directory"; + ls -lahdZ $tmpDir; + rlRun "pushd $tmpDir" + testUser="$(makeUser)"; + rlRun "getent passwd $testUser" 0 "Test user $testUser created"; + rlServiceStop crond; + rlPhaseEnd + + rlPhaseStartSetup "Prepare libfaketime"; + rlRun "cp ${testDir}/$LIBFAKETTIMEPACKAGE ./" 0 "Get library sources"; + rlRun "tar -xvzf $LIBFAKETTIMEPACKAGE" 0 "Unpack library sources"; + pushd ${LIBFAKETTIMEPACKAGE%.tar.gz}; + rlRun "make &>/dev/null" 0 "Building library from sources"; + rlRun "cp ./src/$LIBFAKETIME ../" 0 "Coping library to working directory"; + popd; + LD_PRELOAD=./libfaketime.so.1 FAKETIME='1994-07-29 12:00:01' date +%G | { year="$(cat)"; [[ $year -eq 1994 ]]; }; + rlAssert0 "Library preloading working well" $?; + rlPhaseEnd + + rlPhaseStartSetup "Prepare tests"; + rlRun "sed 's#%TMPDIR#$tmpDir#' $testDir/crontab.temp > crontab.source" #0 "Crontab prepared from template"; + rlRun "crontab -u $testUser crontab.source" 0 "Set crontab for test user"; + crontab -lu $testUser; + rlRun "cp $testDir/cron_test.sh ./" 0 "Copyed script for cron job"; + rlRun "chmod a+x cron_test.sh" 0 "Permissions to executed set"; + rlRun "[[ -e /var/spool/mail/$testUser ]] && printf '' > /var/spool/mail/$testUser" 0 "Clean up mails" + rlLog "Execute crond with faked time"; + LD_PRELOAD=./libfaketime.so.1 FAKETIME='@1994-07-29 12:12:50' /usr/sbin/crond -n -x sch & + cronPID=$!; + pstree -Aph + rlRun "kill -0 $cronPID" 0 "crond is running"; + rlLog "Security timeout for 30 sec to ensure all configs are loaded and crontab is succesfully processed"; + sleep 30; + rlPhaseEnd + + rlPhaseStartTest "cronie drops \$LANG and never passes it on to jobs run" + rlRun "[[ $(sed -n '/^LANG/s/LANG=//p' /tmp/cronie-jobs-environment.log) = $LANG ]]" 0 "LANG is set" + rlPhaseEnd + + rlPhaseStartTest "cronie doesn't drop privileges before popen" + rlRun "[[ $(sed -n '/^EUID/s/EUID=//p' /tmp/cronie-jobs-environment.log) -eq $(id -u $testUser) ]]" 0 \ + "Crontab is executed with correct EUID"; + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "kill $cronPID" 0 "Terminating crond" + rlRun "crontab -ru $testUser" 0 "Crontab removed" + rlRun "popd" + rlRun "rm -r $tmpDir" 0 "Removing tmp directory" + rlRun "userdel -rf $testUser"; + rlServiceRestore crond; + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/crontab-can-invoke-lookup-for-nonexisted-user/Makefile b/tests/crontab-can-invoke-lookup-for-nonexisted-user/Makefile new file mode 100644 index 0000000..78b55ab --- /dev/null +++ b/tests/crontab-can-invoke-lookup-for-nonexisted-user/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user +# Description: Test for Cron does uid lookups for non-existent users +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for Cron does uid lookups for non-existent users" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 10m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/crontab-can-invoke-lookup-for-nonexisted-user/PURPOSE b/tests/crontab-can-invoke-lookup-for-nonexisted-user/PURPOSE new file mode 100644 index 0000000..056f3fb --- /dev/null +++ b/tests/crontab-can-invoke-lookup-for-nonexisted-user/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user +Description: Test for Cron does uid lookups for non-existent users +Author: Jakub Prokes +Bug summary: Cron does uid lookups for non-existent users diff --git a/tests/crontab-can-invoke-lookup-for-nonexisted-user/runtest.sh b/tests/crontab-can-invoke-lookup-for-nonexisted-user/runtest.sh new file mode 100644 index 0000000..7387dd1 --- /dev/null +++ b/tests/crontab-can-invoke-lookup-for-nonexisted-user/runtest.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k ft=beakerlib +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user +# Description: Test for Cron does uid lookups for non-existent users +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" +declare -ri EXIT_FAILURE=1; +declare -ri EXIT_SUCCESS=0; +declare -r reportAllErrors=no; + +function isTrue() { + local string="$@"; + local oldOpt="shopt -p nocasematch"; + local -i rc=1; + + shopt -s nocasematch; + [[ -z "$string" ]] && return 1; + + case $string in + yes) rc=0;; + true) rc=0;; + ano) rc=0;; + 1) rc=0;; + jo) rc=0;; + yeah) rc=0;; + y) rc=0;; + a) rc=0;; + esac; + eval $oldOpt; + return $rc; +} + +## Is nice to know when things going wrong +function errorHandler() { + local code="${?}"; + local lineNO="$1"; + + case $code in + 127) + rlFail "Command not found on line $lineNO" + ;; + *) + isTrue $reportAllErrors && rlFail "Unhandled error $code near line $lineNO"; + ;; + esac +} + + +rlJournalStart + trap 'errorHandler ${LINENO}' ERR; + rlPhaseStart FAIL "Setup" + rlAssertRpm $PACKAGE; + rlRun "rlServiceStop 'crond'" + echo > /var/log/cron + rlRun "rlServiceStart 'crond'" + rlPhaseEnd + + rlPhaseStartTest + rlRun "sleep 61 | crontab -" & + sleep 5 + fileName="$(ls /var/spool/cron/ | grep 'tmp' | head -n 1)"; + ls -lah /var/spool/cron/; + rlRun "[[ -n '$fileName' ]]" 0 "$fileName found"; + rlRun "wait"; + rlRun "grep 'ORPHAN' /var/log/cron | grep '$fileName'" 1 ; + tail -n 20 /var/log/cron; + rlPhaseEnd + + rlPhaseStart WARN "Cleanup" + rlRun "rlServiceRestore 'crond'" + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd + rlJournalPrintText + trap - ERR; +rlJournalEnd diff --git a/tests/crontab-has-wrong-permissions/Makefile b/tests/crontab-has-wrong-permissions/Makefile new file mode 100644 index 0000000..fd02095 --- /dev/null +++ b/tests/crontab-has-wrong-permissions/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/crontab-has-wrong-permissions +# Description: What the test does +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/crontab-has-wrong-permissions +export TESTVERSION=1.1 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: What the test does" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/crontab-has-wrong-permissions/PURPOSE b/tests/crontab-has-wrong-permissions/PURPOSE new file mode 100644 index 0000000..61f54cb --- /dev/null +++ b/tests/crontab-has-wrong-permissions/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Regression/crontab-has-wrong-permissions +Description: What the test does +Author: Jakub Prokes diff --git a/tests/crontab-has-wrong-permissions/runtest.sh b/tests/crontab-has-wrong-permissions/runtest.sh new file mode 100644 index 0000000..6a72dd2 --- /dev/null +++ b/tests/crontab-has-wrong-permissions/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/crontab-has-wrong-permissions +# Description: What the test does +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="cronie vixie-cron" + +function myAssertRpms() { + rlRun "rpm -q $*" $((${#@}-1)) "One of required packages was found"; +} + + +rlJournalStart + rlPhaseStartSetup + myAssertRpms $PACKAGES + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "[[ $(stat /usr/bin/crontab -c \"%a\") -eq 4755 ]]" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/echos-OK-twice-in-init-script/Makefile b/tests/echos-OK-twice-in-init-script/Makefile new file mode 100644 index 0000000..dec6383 --- /dev/null +++ b/tests/echos-OK-twice-in-init-script/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/echos-OK-twice-in-init-script +# Description: Test for echos "OK" twice in init script +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/echos-OK-twice-in-init-script +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Martin Cermak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for echos \"OK\" twice in init script" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/echos-OK-twice-in-init-script/PURPOSE b/tests/echos-OK-twice-in-init-script/PURPOSE new file mode 100644 index 0000000..9a334d7 --- /dev/null +++ b/tests/echos-OK-twice-in-init-script/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/echos-OK-twice-in-init-script +Description: Test for echos "OK" twice in init script +Author: Martin Cermak + diff --git a/tests/echos-OK-twice-in-init-script/runtest.sh b/tests/echos-OK-twice-in-init-script/runtest.sh new file mode 100644 index 0000000..54afa80 --- /dev/null +++ b/tests/echos-OK-twice-in-init-script/runtest.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/echos-OK-twice-in-init-script +# Description: Test for echos "OK" twice in init script +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/bin/rhts-environment.sh +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TEMPDIR=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "pushd $TEMPDIR" + + rlFileBackup "/etc/rc.d/init.d/crond" + rlServiceStop crond + +cat > /etc/rc.d/init.d/functions2 <> $TEMPDIR/log.txt +} +EOF1 + rlRun "cat /etc/rc.d/init.d/functions2" + + sed -i "s/^\..*$/\0\n\. \/etc\/rc\.d\/init\.d\/functions2/" /etc/rc.d/init.d/crond + rlRun "grep ^\\\. /etc/rc.d/init.d/crond" + rlPhaseEnd + + rlPhaseStartTest + rlAssertNotExists log.txt + rlServiceStart crond + rlAssertExists log.txt + + rlRun "TIMES_PRINTED_OK=`grep OK log.txt | wc -l`" + rlRun "test $TIMES_PRINTED_OK -eq 1" + + rlServiceStop crond + rlPhaseEnd + + rlPhaseStartCleanup + rlBundleLogs TESTLOGS /etc/rc.d/init.d/functions2 /etc/rc.d/init.d/crond + rlRun "rm -f /etc/rc.d/init.d/functions2" + rlFileRestore + rlServiceRestore crond + rlRun "popd" + rlRun "rm -r $TEMPDIR" 0 "Removing tmp directory" + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalEnd diff --git a/tests/init-script-failure/Makefile b/tests/init-script-failure/Makefile new file mode 100644 index 0000000..49b556c --- /dev/null +++ b/tests/init-script-failure/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/init-script-failure +# Description: Testing some init script failures +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/init-script-failure +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Testing some init script failures" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/init-script-failure/PURPOSE b/tests/init-script-failure/PURPOSE new file mode 100644 index 0000000..81de15d --- /dev/null +++ b/tests/init-script-failure/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Regression/init-script-failure +Description: Testing some init script failures +Author: Jakub Prokes diff --git a/tests/init-script-failure/runtest.sh b/tests/init-script-failure/runtest.sh new file mode 100644 index 0000000..c0f6d02 --- /dev/null +++ b/tests/init-script-failure/runtest.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/init-script-failure +# Description: Testing some init script failures +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +function makeUser() { + local userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')"; + while getent passwd $userName; do + userName="$(tr -dc "[:lower:]" < /dev/urandom | head -c 5 | sed 's/^/qa_/')"; + done + useradd -d $tmpDir $userName; + echo $userName; +} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlServiceStop crond + rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory"; + testUser="$(makeUser)"; + rlPhaseEnd + + rlPhaseStartTest "Service restart needlessly reports failure" + rlRun -s "service crond restart" + rlAssertNotGrep "FAILED" $rlRun_LOG + rlPhaseEnd + + if ! rpm -q systemd &>/dev/null; then + rlPhaseStartTest "Check service restart exit code" + su -l $testUser -c "service crond restart"; + rlAssertEquals "Expected result of call initscript by unprivileged user is 4" $? 4 + rlPhaseEnd + fi + + rlPhaseStartCleanup + rm -f $rlRun_LOG + rm -rf $tmpDir; + userdel -rf $testUser; + rlServiceRestore crond + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/init-scripts-LSB/Makefile b/tests/init-scripts-LSB/Makefile new file mode 100644 index 0000000..712f909 --- /dev/null +++ b/tests/init-scripts-LSB/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Sanity/init-script-LSB +# Description: Init script should meet LSB specifications +# Author: Yulia Kopkova +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Sanity/init-script-LSB +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Petr Sklenar " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Init script should meet LSB specifications" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + rhts-lint $(METADATA) diff --git a/tests/init-scripts-LSB/PURPOSE b/tests/init-scripts-LSB/PURPOSE new file mode 100644 index 0000000..26efe1c --- /dev/null +++ b/tests/init-scripts-LSB/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Sanity/init-script-LSB +Description: Init script should meet LSB specifications +Author: Yulia Kopkova diff --git a/tests/init-scripts-LSB/runtest.sh b/tests/init-scripts-LSB/runtest.sh new file mode 100644 index 0000000..7b72ea7 --- /dev/null +++ b/tests/init-scripts-LSB/runtest.sh @@ -0,0 +1,186 @@ +#!/bin/bash +# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Sanity/init-script-LSB +# Description: Init script should meet LSB specifications +# Author: Jan Scotka , Yulia Kopkova +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/bin/rhts-environment.sh +. /usr/share/rhts-library/rhtslib.sh + +PACKAGE="cronie" + +SERVICE="crond"; +reportAllErrors=no; + +function isTrue() { + local string="$@"; + local oldOpt="shopt -p nocasematch"; + local -i rc=1; + + shopt -s nocasematch; + [[ -z "$string" ]] && return 1; + + case $string in + yes) rc=0;; + true) rc=0;; + ano) rc=0;; + 1) rc=0;; + jo) rc=0;; + yeah) rc=0;; + y) rc=0;; + a) rc=0;; + esac; + eval $oldOpt; + return $rc; +} + +isTrue no && echo Yes || echo No; + +## Is nice to know when things going wrong +function errorHandler() { + local code="${?}"; + local lineNO="$1"; + + case $code in + 127) + rlFail "Command not found on line $lineNO" + ;; + *) + isTrue $reportAllErrors && rlFail "Unhandled error $code near line $lineNO"; + ;; + esac +} + +function getUserName() { + local userName="qa_$(tr -dc "[:lower:]" < /dev/urandom | head -c 5)"; + echo "$userName" >&2;⏎ + if getent passwd $userName &>/dev/null; then + getUserName; + return $? + fi + if [[ -n "$userName" ]]; then + echo "$userName"; + return $EXIT_SUCCESS; + else + return $EXIT_FAILURE; + fi +} + + +rlJournalStart +trap 'errorHandler ${LINENO}' ERR; + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory"; + testUser="$(getUserName || rlDie "Cannot get username")" + rlLog "${testUser}" + rlRun "useradd -d $tmpDir $testUser"; + pushd $tmpDir; + rlServiceStop $SERVICE + rlPhaseEnd + + rlPhaseStartTest "starts the service" + rlRun "service $SERVICE start" 0 " Service must start without problem" + rlRun "service $SERVICE status" 0 " Then Status command " + rlRun "service $SERVICE start" 0 " Already started service " + rlRun "service $SERVICE status" 0 " Again status command " + rlPhaseEnd + + rlPhaseStartTest "restart the service" + firstPid=$(ps h -C $SERVICE -o pid); + rlRun "service $SERVICE restart" 0 " Restarting of service" + rlRun "service $SERVICE status" 0 " Status command " + secondPid=$(ps h -C $SERVICE -o pid); + rlRun "[[ -n $firstPid ]] && [[ -n $secondPid ]] && [[ $firstPid -ne $secondPid ]]" 0 \ + "Pids are different after restart"; + rlPhaseEnd + + rlPhaseStartTest "stop the service" + rlRun "service $SERVICE stop" 0 " Stopping service " + rlRun "service $SERVICE status" 3 " Status of stopped service " || true + rlRun "service $SERVICE stop" 0 " Stopping service again " + rlRun "service $SERVICE status" 3 " Status of stopped service " || true + rlPhaseEnd + + if ! rlIsRHEL ">=7"; then + rlPhaseStartTest "pid file" + rlServiceStart $SERVICE + rlAssertExists "/var/run/$SERVICE.pid" "Pid file /var/run/$SERVICE.pid must exist" + sleep 1 + rlRun "kill -9 `pidof crond`" 0 "Kill $SERVICE" + sleep 10 + rlRun "service $SERVICE status" 1 " Existing pid file, but service not started " || true; + sleep 1 + rlRun "rm -fv /var/run/$SERVICE.pid" 0 "Remove .pid file" + rlPhaseEnd + + rlPhaseStartTest "lock file" + rlAssertExists "/var/lock/subsys/$SERVICE" "Lock file /var/lock/subsys/$SERVICE must exist" + rlRun "service $SERVICE status" 2 " Existing lock file, but service not started " || true; + rlServiceStop $SERVICE + rlPhaseEnd + fi + + rlPhaseStartTest "insufficient rights" + rlRun "service $SERVICE start " 0 " Starting service for restarting under nonpriv user " + rlRun "su $testUser -c 'service $SERVICE restart'" \ + $(rpm -q systemd &>/dev/null && echo 1 || echo 4) \ + "Insufficient rights, restarting service under nonprivileged user must fail"; + rlPhaseEnd + + rlPhaseStartTest "operations" + rlRun "service $SERVICE start" 0 " Service have to implement start function " + rlRun "service $SERVICE restart" 0 " Service have to implement restart function " + rlRun "service $SERVICE status" 0 " Service have to implement status function " + rlRun "service $SERVICE reload" 0 " Service have to implement reload function " + rlRun "service $SERVICE force-reload" 0 " Service have to implement force-reload function " + rlRun "service $SERVICE condrestart" 0 " Service have to implement condrestart function " + if ! rlIsRHEL ">=7"; then + rlRun "service $SERVICE try-restart" 0 " Service have to implement try-restart function " + fi + rlPhaseEnd + + rlPhaseStartTest "nonexisting operations" + rlRun "service $SERVICE noexistop" 2 " Testing proper return code when nonexisting function"; + rlRun "service $SERVICE stopex" 2 " Testing proper return code when nonexisting function"; + rlRun "service $SERVICE foo" 2 " Testing proper return code when nonexisting function" || true + rlPhaseEnd + + rlPhaseEnd + + rlPhaseStartCleanup + rlServiceRestore $SERVICE + rlRun "getent passwd $testUser"; + popd tmpDir; + rlRun "userdel -fr $testUser" 0 "Remove test user"; +# rlRun "rm -rf $testDir"; + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd + +rlJournalPrintText +trap - ERR; +rlJournalEnd diff --git a/tests/ldap-users/Makefile b/tests/ldap-users/Makefile new file mode 100644 index 0000000..e1967a1 --- /dev/null +++ b/tests/ldap-users/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/ldap-users +# Description: Test for cronie not creating jobs for ldap users if ldap +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/ldap-users +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE data.ldif slapd.conf user1.cron + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for cronie not creating jobs for ldap users if ldap" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 10m" >> $(METADATA) + @echo "RunFor: cronie openldap" >> $(METADATA) + @echo "Requires: cronie authconfig openldap openldap-servers openldap-clients sssd sssd-ldap" >> $(METADATA) + @echo "RhtsRequires: library(authconfig/basic)" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/ldap-users/PURPOSE b/tests/ldap-users/PURPOSE new file mode 100644 index 0000000..786822b --- /dev/null +++ b/tests/ldap-users/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/cronie/Regression/ldap-users +Description: Test for cronie not creating jobs for ldap users if ldap +Author: Jakub Prokes +Bug summary: cronie not creating jobs for ldap users if ldap server is temporarily down. + diff --git a/tests/ldap-users/data.ldif b/tests/ldap-users/data.ldif new file mode 100644 index 0000000..9d8836a --- /dev/null +++ b/tests/ldap-users/data.ldif @@ -0,0 +1,26 @@ +dn: dc=foo,dc=bar,dc=com +dc: foo +objectClass: top +objectClass: domain + +dn: ou=people,dc=foo,dc=bar,dc=com +ou: people +objectClass: top +objectClass: organizationalUnit + +dn: uid=user1,ou=people,dc=foo,dc=bar,dc=com +uid: user1 +cn: user1 +objectClass: account +objectClass: posixAccount +objectClass: top +objectClass: shadowAccount +userPassword: {CRYPT}hebc0ErNA0uXY +shadowLastChange: 14460 +shadowMax: 99999 +shadowWarning: 7 +loginShell: /bin/bash +uidNumber: 1001 +gidNumber: 1000 +homeDirectory: /home/ldap/user1 +gecos: user1 diff --git a/tests/ldap-users/runtest.sh b/tests/ldap-users/runtest.sh new file mode 100644 index 0000000..4de269b --- /dev/null +++ b/tests/ldap-users/runtest.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/ldap-users +# Description: Test for cronie not creating jobs for ldap users if ldap +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStart FAIL "General Setup" + rlAssertRpm $PACKAGE + rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "testDir=\"$(pwd)\"" + rlRun "pushd $tmpDir" + rlRun "rlImport --all" + rlServiceStart "crond" + rlFileBackup /var/log/cron + echo > /var/log/cron + /bin/kill -HUP $(cat /var/run/syslogd.pid) + rlRun "getent passwd user1" 2 + rlPhaseEnd + + rlPhaseStart FAIL "LDAP Server Setup" + rlServiceStop "slapd" + rlFileBackup --clean "/etc/openldap" + rlFileBackup --clean "/var/run/openldap" + rlFileBackup --clean "/var/lib/ldap" + rlRun "rm -rf /etc/openldap/slapd.d/* /var/lib/ldap/* /var/run/openldap/*" 0 "Cleaning LDAP directories" + rlRun "slapadd -l ${testDir}/data.ldif -f ${testDir}/slapd.conf" 0 "Importing testing user into LDAP" + rlRun "chown ldap:ldap /var/run/openldap/*" 0 "Fixing permissions on '/var/run/openldap/*'" + rlRun "restorecon -Rv /etc/" 0 "Fixing SELinux contexts" + rlRun "slaptest -f ${testDir}/slapd.conf -F /etc/openldap/slapd.d" 0 "Importing LDAP configuration" + rlRun "chown -R ldap:ldap /etc/openldap/slapd.d" 0 "Fixing permissions on '/etc/openldap/slapd.d'" + rlServiceStart "slapd" + rlPhaseEnd + + rlPhaseStart FAIL "LDAP auth setup" + rlServiceStop "sssd" + rlRun "authconfig_setup" + rlRun "authconfig --savebackup=CoreOS_cronie_Regression_ldap-users" + rlRun "authconfig --enableldap --enableldapauth --ldapserver=ldap://127.0.0.1/ \ + --ldapbasedn=dc=foo,dc=bar,dc=com --update" + rlRun "getent passwd user1" + rlRun "mkdir -p /home/ldap/user1" + rlRun "chown user1 /home/ldap/user1" + rlPhaseEnd + + rlPhaseStartTest + rlRun "su user1 -c 'crontab ${testDir}/user1.cron'" 0 "Creating user cronjob" && \ + cat ${testDir}/user1.cron; + rlFileBackup /etc/crontab + rlRun "rlServiceStop slapd" + rlRun "service sssd stop" + rlRun "rm -rf /var/lib/sss/db/*" + rlRun "service sssd start" + rlRun "getent passwd user1" 2 + rlRun "echo \"* * * * * user1 /bin/echo foo > /tmp/cron.out\" > /etc/crontab" 0 \ + "Create record in system crontab" + cat /etc/crontab + rlRun "service crond restart" + rlRun "rlServiceStart slapd" + rlRun "service sssd stop" + rlRun "rm -rf /var/lib/sss/db/*" + rlRun "service sssd start" + waitCounter=60; + echo "Waiting for LDAP" + while ! getent passwd user1; do + sleep 1; + echo -n . + [[ waitCounter -le 0 ]] && break; + waitCounter=$((waitCounter-1)); + done + echo; + rlRun "getent passwd user1" + rm -f /home/ldap/user1/cron.out + echo "Waiting for cronjob execution" + sleep 65; + if rlRun "[[ -f /home/ldap/user1/cron.out ]]" 0 "User cronjob executed successfully"; then + rlAssertGrep "foo" /home/ldap/user1/cron.out; + fi + if rlRun "[[ -f /tmp/cron.out ]]" 0 "Crontab cronjob executed successfully"; then + rlAssertGrep "foo" /tmp/cron.out; + fi + rlRun "service crond stop" + cat /var/log/cron + rlPhaseEnd + + rlPhaseStart WARN "Cleanup" + rlRun "service crond restart" + rlRun "crontab -r -u user1" + rlRun "rlServiceStop slapd" + rlRun "authconfig --disableldap --disableldapauth --update" + rlRun "authconfig --restorebackup=CoreOS_cronie_Regression_ldap-users" + rlRun "authconfig_cleanup" + rlRun "popd" + rlRun "rm -r $tmpDir" 0 "Removing tmp directory" + rlRun "rm -r /home/ldap/user1" + rlRun "rm -r /home/ldap" + rlFileRestore + rlServiceRestore slapd + rlServiceRestore sssd + /bin/kill -HUP $(cat /var/run/syslogd.pid) + rlServiceRestore crond + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/ldap-users/slapd.conf b/tests/ldap-users/slapd.conf new file mode 100644 index 0000000..97b3c2d --- /dev/null +++ b/tests/ldap-users/slapd.conf @@ -0,0 +1,32 @@ +include /etc/openldap/schema/core.schema +include /etc/openldap/schema/cosine.schema +include /etc/openldap/schema/inetorgperson.schema +include /etc/openldap/schema/nis.schema + +allow bind_v2 + +pidfile /var/run/openldap/slapd.pid +argsfile /var/run/openldap/slapd.args + +database bdb +suffix "dc=foo,dc=bar,dc=com" +rootdn "cn=admin,dc=foo,dc=bar,dc=com" + +# Password is 'x'. +rootpw {SSHA}GPhzu7pTYP4I+nGeujpBkODiPxX0v8n8 + +directory /var/run/openldap/ + +index objectClass eq,pres +index ou,cn,mail,surname,givenname eq,pres,sub +index uidNumber,gidNumber,loginShell eq,pres +index uid,memberUid eq,pres,sub +index nisMapName,nisMapEntry eq,pres,sub +index entryCSN,entryUUID eq + +access to attrs=shadowLastChange,userPassword + by self write + by * auth + +access to * + by * read diff --git a/tests/ldap-users/user1.cron b/tests/ldap-users/user1.cron new file mode 100644 index 0000000..20d07a4 --- /dev/null +++ b/tests/ldap-users/user1.cron @@ -0,0 +1,10 @@ +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat +# | | | | | +# * * * * * command to be executed + + * * * * * /bin/echo foo > $HOME/cron.out diff --git a/tests/only-one-running-instance-in-time/Makefile b/tests/only-one-running-instance-in-time/Makefile new file mode 100644 index 0000000..25272de --- /dev/null +++ b/tests/only-one-running-instance-in-time/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/only-one-running-instance-in-time +# Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time. +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/only-one-running-instance-in-time +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time." >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/only-one-running-instance-in-time/PURPOSE b/tests/only-one-running-instance-in-time/PURPOSE new file mode 100644 index 0000000..7928fc9 --- /dev/null +++ b/tests/only-one-running-instance-in-time/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/cronie/Regression/only-one-running-instance-in-time +Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time. +Author: Jakub Prokes diff --git a/tests/only-one-running-instance-in-time/runtest.sh b/tests/only-one-running-instance-in-time/runtest.sh new file mode 100644 index 0000000..7d7e8cb --- /dev/null +++ b/tests/only-one-running-instance-in-time/runtest.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/only-one-running-instance-in-time +# Description: When crond is running in multiple instance, then cron jobs are executed multiple times. Is neccesary to prevent multiple instances of crond running in time. +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup + rlServiceStart crond + rlPhaseEnd + + rlPhaseStartTest + rlRun "kill -0 $(cat /var/run/crond.pid)" 0 "Service crond is running"; + rlRun "/usr/sbin/crond" 1 "Executing another instance fail"; + rlAssertEquals "There is stil one instance of crond" $(ps h -C crond -o pid | wc -l) 1; + rlPhaseEnd + + rlPhaseStartCleanup + rlServiceRestore crond + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/run-with-syslog-flag/Makefile b/tests/run-with-syslog-flag/Makefile new file mode 100644 index 0000000..bc16c08 --- /dev/null +++ b/tests/run-with-syslog-flag/Makefile @@ -0,0 +1,62 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/run-with-syslog-flag +# Description: Test for cronie has a bug when run with syslog flag +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/run-with-syslog-flag +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jakub Prokes " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for cronie has a bug when run with syslog flag" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 10m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie rsyslog" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/run-with-syslog-flag/PURPOSE b/tests/run-with-syslog-flag/PURPOSE new file mode 100644 index 0000000..bd80d4b --- /dev/null +++ b/tests/run-with-syslog-flag/PURPOSE @@ -0,0 +1,4 @@ +PURPOSE of /CoreOS/cronie/Regression/run-with-syslog-flag +Description: Test for cronie has a bug when run with syslog flag +Author: Jakub Prokes +Bug summary: cronie has a bug when run with syslog flag diff --git a/tests/run-with-syslog-flag/runtest.sh b/tests/run-with-syslog-flag/runtest.sh new file mode 100644 index 0000000..1770208 --- /dev/null +++ b/tests/run-with-syslog-flag/runtest.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/run-with-syslog-flag +# Description: Test for cronie has a bug when run with syslog flag +# Author: Jakub Prokes +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="cronie" +declare -r sysConfig="/etc/sysconfig/crond"; +declare -r cronJobFile=/etc/cron.d/testjob + +rlJournalStart + rlPhaseStart FAIL "Setup" + ## nasty hack for journalctl + export PAGER="" + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlServiceStart rsyslog + rlPhaseEnd + + rlPhaseStartTest + rlFileBackup ${sysConfig}; + crondOpts="$(sed -n '/^\s*CRONDARGS/s/^\s*CRONDARGS\s*=//p' ${sysConfig})"; + rlLog "Old CRONDARGS=\"${crondOpts}\""; + if echo "$crondOpts" | grep '"'; then + ## strip trailing quotes + crondOpts="$(echo "$crondOpts" | sed 's/\(^"\)\|\("$\)//g')"; + fi + crondOpts="$crondOpts -s -m off"; + rlLog "New CRONDARGS=\"${crondOpts}\""; + echo "CRONDARGS=\"${crondOpts}\"" > ${sysConfig}; + phrase="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32)"; + echo "* * * * * root /bin/echo $phrase" > ${cronJobFile}; + cp /var/log/cron ./oldLog; + [[ -f ./oldLog ]] || touch ./oldLog; + rlServiceStop crond; + sleep 1 + rlServiceStart crond; + sleep 65; + rlRun "diff ./oldLog /var/log/cron |grep -v '/bin/echo' \ + | grep '$phrase'" 0 "Output is logged correctly." \ + || rlLog "$(tail -n 5 /var/log/cron)" + rlPhaseEnd + + rlPhaseStart WARN "Cleanup" + rlRun "rm ${cronJobFile}"; + rlFileRestore; + rlRun "rlServiceRestore crond"; + rlServiceRestore rsyslog + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + #avoid systemd failing to start crond due start-limit + sleep 10 + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..a1167e8 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,82 @@ +--- +# Tests to run in a classic environment +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + tests: + - anacron-segfaults-with-certain-config-data + - anacron-segfaults-with-certain-config-data-2 + - Can-t-remove-crontab-from-expired-accounts + - Cron-does-uid-lookups-for-non-existent-users + - cron-daemon-fails-to-log-that-it-is-shutting-down + - crond-is-missing-RELRO-flags + - crond-subtask-abnormal-termination-removes-pid-file-in-error + - config-parsing-issue + - cronie-jobs-environment + - crontab-can-invoke-lookup-for-nonexisted-user + - crontab-has-wrong-permissions +# - echos-OK-twice-in-init-script Does not work on Fedora-26 + - init-script-failure +# - init-scripts-LSB Does not work on Fedora-26 +# - ldap-users Does not work on Fedora-26 +# - MAILTO-problem-with-anacron Does not work on Fedora-26 + - Make-crontab-a-PIE + - only-one-running-instance-in-time + - run-with-syslog-flag + - usr-bin-crontab-has-wrong-permissions + required_packages: + - authconfig # ldap-users needs this package + - findutils # beakerlib needs find command + - elfutils # crond-is-missing-RELRO-flags needs eu-readelf tool + - gcc # cronie-jobs-environment needs gcc command + - openldap # ldap-users needs this package + - openldap-servers # ldap-users needs this package + - openldap-clients # ldap-users needs this package + - procps-ng # multiple tests need ps and pidof commands + - psmisc # multiple tests need killall command + - rsyslog # run-with-syslog-flag requires this package + - sendmail # MAILTO-problem-with-anacron needs sendmail command + - sssd # ldap-users needs this package + - sssd-ldap # ldap-users needs this package + +# Tests to run in a container environment +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - container + tests: + - Can-t-remove-crontab-from-expired-accounts + - Make-crontab-a-PIE + - config-parsing-issue + - crond-is-missing-RELRO-flags + - crontab-has-wrong-permissions + - usr-bin-crontab-has-wrong-permissions + required_packages: + - cronie # everything needs cronie package + - findutils # beakerlib needs find command + - procps-ng # multiple tests need ps and pidof commands + - psmisc # multiple tests need killall command + - elfutils # multiple tests need eu-readelf tool + +# Tests to run in an Atomic Host VM +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - atomic + tests: + - Can-t-remove-crontab-from-expired-accounts + - Make-crontab-a-PIE + - config-parsing-issue + - crond-is-missing-RELRO-flags + - crontab-has-wrong-permissions + - usr-bin-crontab-has-wrong-permissions + required_packages: + - cronie # everything needs cronie package + - findutils # beakerlib needs find command + - procps-ng # multiple tests need ps and pidof commands + - psmisc # multiple tests need killall command + - elfutils # multiple tests need eu-readelf tool diff --git a/tests/usr-bin-crontab-has-wrong-permissions/Makefile b/tests/usr-bin-crontab-has-wrong-permissions/Makefile new file mode 100644 index 0000000..f76a672 --- /dev/null +++ b/tests/usr-bin-crontab-has-wrong-permissions/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions +# Description: Test for /usr/bin/crontab has wrong permissions +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Martin Cermak " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for /usr/bin/crontab has wrong permissions" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: cronie" >> $(METADATA) + @echo "Requires: cronie" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/usr-bin-crontab-has-wrong-permissions/PURPOSE b/tests/usr-bin-crontab-has-wrong-permissions/PURPOSE new file mode 100644 index 0000000..fb2bd73 --- /dev/null +++ b/tests/usr-bin-crontab-has-wrong-permissions/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions +Description: Test for /usr/bin/crontab has wrong permissions +Author: Martin Cermak +Bug summary: /usr/bin/crontab has wrong permissions + diff --git a/tests/usr-bin-crontab-has-wrong-permissions/runtest.sh b/tests/usr-bin-crontab-has-wrong-permissions/runtest.sh new file mode 100644 index 0000000..5540876 --- /dev/null +++ b/tests/usr-bin-crontab-has-wrong-permissions/runtest.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions +# Description: Test for /usr/bin/crontab has wrong permissions +# Author: Martin Cermak +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include rhts environment +. /usr/bin/rhts-environment.sh +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGE="cronie" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlPhaseEnd + + rlPhaseStartTest + rlRun "test `stat -c %a /usr/bin/crontab` -eq 4755" + rlPhaseEnd +rlJournalEnd +rlJournalPrintText