diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.gitignore b/.gitignore index 4079eb0..29a96bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1 @@ -/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 -/cronie-1.5.6.tar.gz -/cronie-1.5.7.tar.gz -/cronie-1.6.0.tar.gz -/cronie-1.6.1.tar.gz -/cronie-1.7.0.tar.gz +/cronie-*.tar.gz diff --git a/0001-do-no-leak-file-descriptors.patch b/0001-do-no-leak-file-descriptors.patch new file mode 100644 index 0000000..3c81e32 --- /dev/null +++ b/0001-do-no-leak-file-descriptors.patch @@ -0,0 +1,61 @@ +From b3a54d0b3561bc2ab46c11fd5c67350cc216b171 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= +Date: Wed, 26 Jun 2024 16:08:44 +0200 +Subject: [PATCH] Do not leak file descriptors in backup_crontab + +Originally, if anything went wrong during the backup, +the early return caused the crontab_file and possibly backup_file +pointers to leak. + +Issue found by static scanner. +--- + src/crontab.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/src/crontab.c b/src/crontab.c +index f61fd46..55d2aed 100644 +--- a/src/crontab.c ++++ b/src/crontab.c +@@ -563,6 +563,7 @@ static int backup_crontab(const char *crontab_path) { + + if (swap_uids() == -1) { + perror("swapping uids"); ++ (void) fclose(crontab_file); + exit(ERROR_EXIT); + } + +@@ -590,22 +591,29 @@ static int backup_crontab(const char *crontab_path) { + + if (swap_uids_back() < OK) { + perror("swapping uids back"); ++ if (backup_file != NULL) { ++ (void) fclose(backup_file); ++ } ++ (void) fclose(crontab_file); + exit(ERROR_EXIT); + } + + if (retval != 0) +- return retval; ++ goto cleanup; + + if (EOF != ch) + while (EOF != (ch = get_char(crontab_file))) + putc(ch, backup_file); + +- (void) fclose(crontab_file); +- (void) fclose(backup_file); +- + printf("Backup of %s's previous crontab saved to %s\n", User, backup_path); + +- return 0; ++cleanup: ++ if (backup_file != NULL) { ++ (void) fclose(backup_file); ++ } ++ (void) fclose(crontab_file); ++ ++ return retval; + } + + static void check_error(const char *msg) { diff --git a/cronie-anacron-tmpfiles.conf b/cronie-anacron-tmpfiles.conf new file mode 100644 index 0000000..f8f9dd5 --- /dev/null +++ b/cronie-anacron-tmpfiles.conf @@ -0,0 +1,9 @@ +# systemd-tmpfiles configuration for cronie-anacron + +# Create the anacron spool directory +d /var/spool/anacron 0755 root root - + +# Create anacron timestamp files +f /var/spool/anacron/cron.daily 0600 root root - +f /var/spool/anacron/cron.weekly 0600 root root - +f /var/spool/anacron/cron.monthly 0600 root root - diff --git a/cronie-tmpfiles.conf b/cronie-tmpfiles.conf new file mode 100644 index 0000000..4e6eed2 --- /dev/null +++ b/cronie-tmpfiles.conf @@ -0,0 +1,4 @@ +# systemd-tmpfiles configuration for cronie + +# Create the cron spool directory +d /var/spool/cron 0700 root root - \ No newline at end of file diff --git a/cronie.spec b/cronie.spec index fc4df93..bc893a3 100644 --- a/cronie.spec +++ b/cronie.spec @@ -1,18 +1,29 @@ -%bcond_without selinux -%bcond_without pam -%bcond_without audit -%bcond_without inotify +%bcond selinux 1 +%bcond pam 1 +%bcond audit 1 +%bcond inotify 1 Summary: Cron daemon for executing programs at set times Name: cronie -Version: 1.7.0 +Version: 1.7.2 Release: %autorelease License: GPL-2.0-or-later AND BSD-3-Clause AND BSD-2-Clause AND ISC AND LGPL-2.1-or-later URL: https://github.com/cronie-crond/cronie Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}/cronie-%{version}.tar.gz +Source1: cronie-tmpfiles.conf +Source2: cronie-anacron-tmpfiles.conf -# https://github.com/cronie-crond/cronie/pull/163 -Patch: n_option_wait_on_finnishing_grandchild_process.patch +Patch: 0001-do-no-leak-file-descriptors.patch +# https://github.com/cronie-crond/cronie/issues/193 +Patch: make_error_func_prototype_complete.patch +# https://github.com/cronie-crond/cronie/pull/200 +Patch: fix_range_parsing.patch +# https://github.com/cronie-crond/cronie/pull/201 +Patch: move_parsing_code.patch +# https://github.com/cronie-crond/cronie/pull/206 +Patch: crontab-fix-backup-failure.patch +# https://github.com/cronie-crond/cronie/pull/210 +Patch: forward-XDG_SESSION_CLASS-to-PAM-for-session-classification.patch Requires: dailyjobs @@ -83,27 +94,18 @@ extra features. %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 + %{?with_pam:--with-pam} \ + %{?with_selinux:--with-selinux} \ + %{?with_audit:--with-audit} \ + %{?with_inotify:--with-inotify} \ + --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} @@ -115,26 +117,26 @@ 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 +install -m 644 -D contrib/cronie.systemd $RPM_BUILD_ROOT/usr/lib/systemd/system/crond.service + +# install tmpfiles.d configuration for bootc compatibility +install -m 644 -D %{SOURCE1} $RPM_BUILD_ROOT%{_tmpfilesdir}/cronie.conf +install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_tmpfilesdir}/cronie-anacron.conf %post # run after an installation %systemd_post crond.service +# create directories via tmpfiles.d for bootc compatibility +systemd-tmpfiles --create %{_tmpfilesdir}/cronie.conf 2>/dev/null || : %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 || : +# create directories and files via tmpfiles.d for bootc compatibility +systemd-tmpfiles --create %{_tmpfilesdir}/cronie-anacron.conf 2>/dev/null || : %preun # run before a package is removed @@ -162,7 +164,7 @@ exit 0 # The package is allowed to autostart: /bin/systemctl enable crond.service >/dev/null 2>&1 -/sbin/chkconfig --del crond >/dev/null 2>&1 || : +/bin/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 || : @@ -175,7 +177,7 @@ exit 0 %doc AUTHORS README ChangeLog %{!?_licensedir:%global license %%doc} %license COPYING -%attr(755,root,root) %{_sbindir}/crond +%attr(755,root,root) %{_bindir}/crond %attr(4755,root,root) %{_bindir}/crontab %attr(755,root,root) %{_bindir}/cronnext %{_mandir}/man8/crond.* @@ -183,7 +185,6 @@ exit 0 %{_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 @@ -191,18 +192,21 @@ exit 0 %config(noreplace) %{_sysconfdir}/sysconfig/crond %config(noreplace,missingok) %{_sysconfdir}/cron.deny %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/0hourly -%attr(0644,root,root) /lib/systemd/system/crond.service +%attr(0644,root,root) /usr/lib/systemd/system/crond.service +%{_tmpfilesdir}/cronie.conf +%ghost %dir %attr(0700,root,root) %{_localstatedir}/spool/cron %files anacron -%{_sbindir}/anacron +%{_bindir}/anacron %attr(0755,root,root) %{_sysconfdir}/cron.hourly/0anacron %config(noreplace) %{_sysconfdir}/anacrontab -%dir /var/spool/anacron +%ghost %dir %attr(0755,root,root) /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.* +%{_tmpfilesdir}/cronie-anacron.conf %files noanacron %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/dailyjobs diff --git a/crontab-fix-backup-failure.patch b/crontab-fix-backup-failure.patch new file mode 100644 index 0000000..c42554c --- /dev/null +++ b/crontab-fix-backup-failure.patch @@ -0,0 +1,38 @@ +From fd56df9b6d5fa9932edc6bd41d307e2453a6b442 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= +Date: Wed, 30 Jul 2025 12:40:17 +0200 +Subject: [PATCH] crontab: Fix backup failure when ~/.cache directory missing + +Create ~/.cache parent directory before creating ~/.cache/crontab backup +directory to prevent "mkdir: No such file or directory" errors when users +edit crontabs and their cache directory doesn't exist. +--- + src/crontab.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/src/crontab.c b/src/crontab.c +index c11dc81..14d02dd 100644 +--- a/src/crontab.c ++++ b/src/crontab.c +@@ -578,7 +578,21 @@ static int backup_crontab(const char *crontab_path) { + exit(ERROR_EXIT); + } + ++ /* Ensure the backup directory and its parent exist, creating them if necessary */ + if (stat(backup_dir, &sb) < OK && errno == ENOENT) { ++ char *last_slash = strrchr(backup_dir, '/'); ++ if (last_slash && last_slash != backup_dir) { ++ char parent_dir[MAX_FNAME]; ++ size_t parent_len = last_slash - backup_dir; ++ if (parent_len < sizeof(parent_dir)) { ++ strncpy(parent_dir, backup_dir, parent_len); ++ parent_dir[parent_len] = '\0'; ++ /* Check if parent directory exists before creating */ ++ if (stat(parent_dir, &sb) < OK && errno == ENOENT) { ++ mkdir(parent_dir, 0700); ++ } ++ } ++ } + if (OK != mkdir(backup_dir, 0755)) { + fprintf(stderr, "%s: ", backup_dir); + perror("mkdir"); diff --git a/fix_range_parsing.patch b/fix_range_parsing.patch new file mode 100644 index 0000000..81e07c5 --- /dev/null +++ b/fix_range_parsing.patch @@ -0,0 +1,26 @@ +From d037042129eacdd9d7760d74437842ee5a2d116e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= +Date: Tue, 11 Mar 2025 15:12:38 +0100 +Subject: [PATCH] get_range() fix range parsing for Sunday as 0 or 7 + +In fc8b0e5, we changed how the ranges are parsed. This created a +regression for parsing Sunday at the end of the range. This commit adds +the logic to correctly handle Sunday as the end of the range. +--- + src/entry.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/entry.c b/src/entry.c +index a2077e8..30bedb3 100644 +--- a/src/entry.c ++++ b/src/entry.c +@@ -642,6 +642,9 @@ get_range(bitstr_t * bits, int low, int high, const char *names[], + state = R_FINISH; + break; + } ++ if (low_ > high_ && high_ == 0) { ++ high_ = 7; ++ } + return (EOF); + + case R_RANDOM: diff --git a/forward-XDG_SESSION_CLASS-to-PAM-for-session-classification.patch b/forward-XDG_SESSION_CLASS-to-PAM-for-session-classification.patch new file mode 100644 index 0000000..20828d1 --- /dev/null +++ b/forward-XDG_SESSION_CLASS-to-PAM-for-session-classification.patch @@ -0,0 +1,70 @@ +From 5f9f16b5663becefdd0dd70df31c0ef5ac36f943 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= +Date: Thu, 27 Nov 2025 14:38:47 +0100 +Subject: [PATCH] Forward XDG_SESSION_CLASS to PAM for session classification + +Allow users to set the XDG_SESSION_CLASS environment variable in their +crontab to control the systemd session class for cron jobs. When set, +this value is forwarded to the PAM environment so that pam_systemd can +use it for session classification (e.g., "background-light"). + +This enables cron jobs to run in lighter-weight sessions that consume +fewer system resources. +--- + man/crontab.5 | 10 ++++++++++ + src/security.c | 21 +++++++++++++++++++++ + 2 files changed, 31 insertions(+) + +diff --git a/man/crontab.5 b/man/crontab.5 +index 68380c6..7487cc5 100644 +--- a/man/crontab.5 ++++ b/man/crontab.5 +@@ -157,6 +157,16 @@ upper limit specified by the variable. The random scaling factor is + determined during the cron daemon startup so it remains constant for + the whole run time of the daemon. + .PP ++The ++.I XDG_SESSION_CLASS ++variable specifies the session class to be used when PAM creates a systemd ++session for the cron job. If set (e.g., to "background-light"), this value ++is forwarded to the PAM environment so that ++.BR pam_systemd (8) ++can use it for session classification. This allows cron jobs to run in ++lighter-weight sessions that consume fewer system resources. This variable ++has no effect if crond was built without PAM support. ++.PP + The format of a cron command is similar to the V7 standard, with a number + of upward-compatible extensions. Each line has five time-and-date fields + followed by a +diff --git a/src/security.c b/src/security.c +index 14a514a..67b6d26 100644 +--- a/src/security.c ++++ b/src/security.c +@@ -131,6 +131,27 @@ int cron_set_job_security_context(entry *e, user *u ATTRIBUTE_UNUSED, + pam_strerror(pamh, ret), 0); + return -1; + } ++ ++ /* Forward XDG_SESSION_CLASS from crontab environment to PAM ++ * so that pam_systemd.so can use it for session classification */ ++#ifdef HAVE_PAM_PUTENV ++ if (pamh != NULL) { ++ char *xdg_session_class = env_get("XDG_SESSION_CLASS", e->envp); ++ if (xdg_session_class != NULL) { ++ char *xdg_session_class_env = NULL; ++ if (asprintf(&xdg_session_class_env, "XDG_SESSION_CLASS=%s", ++ xdg_session_class) >= 0) { ++ ret = pam_putenv(pamh, xdg_session_class_env); ++ if (ret != PAM_SUCCESS) { ++ log_it(e->pwd->pw_name, getpid(), ++ "WARNING: Failed to set XDG_SESSION_CLASS in PAM environment", ++ pam_strerror(pamh, ret), 0); ++ } ++ free(xdg_session_class_env); ++ } ++ } ++ } ++#endif + #endif + + #ifdef WITH_SELINUX diff --git a/make_error_func_prototype_complete.patch b/make_error_func_prototype_complete.patch new file mode 100644 index 0000000..1988825 --- /dev/null +++ b/make_error_func_prototype_complete.patch @@ -0,0 +1,37 @@ +From 09c630c654b2aeff06a90a412cce0a60ab4955a4 Mon Sep 17 00:00:00 2001 +From: Tomas Mraz +Date: Mon, 18 Nov 2024 21:02:30 +0100 +Subject: [PATCH] load_entry(): Make error_func prototype complete + +Fixes #193 +--- + src/entry.c | 2 +- + src/funcs.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/entry.c b/src/entry.c +index 586eb9d..a2077e8 100644 +--- a/src/entry.c ++++ b/src/entry.c +@@ -90,7 +90,7 @@ void free_entry(entry * e) { + /* return NULL if eof or syntax error occurs; + * otherwise return a pointer to a new entry. + */ +-entry *load_entry(FILE * file, void (*error_func) (), struct passwd *pw, ++entry *load_entry(FILE * file, void (*error_func) (const char *), struct passwd *pw, + char **envp) { + /* this function reads one crontab entry -- the next -- from a file. + * it skips any leading blank lines, ignores comments, and returns +diff --git a/src/funcs.h b/src/funcs.h +index 427e027..f28d634 100644 +--- a/src/funcs.h ++++ b/src/funcs.h +@@ -89,7 +89,7 @@ char *env_get(const char *, char **), + user *load_user(int, struct passwd *, const char *, const char *, const char *), + *find_user(cron_db *, const char *, const char *); + +-entry *load_entry(FILE *, void (*)(), struct passwd *, char **); ++entry *load_entry(FILE *, void (*)(const char *), struct passwd *, char **); + + FILE *cron_popen(char *, const char *, struct passwd *, char **); + diff --git a/move_parsing_code.patch b/move_parsing_code.patch new file mode 100644 index 0000000..abb83a0 --- /dev/null +++ b/move_parsing_code.patch @@ -0,0 +1,36 @@ +From e6c2853856c3103a4add4c3673b3306cc21d341e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= +Date: Wed, 7 May 2025 13:25:19 +0200 +Subject: [PATCH] get_range() move parsing code before separator check + +In the previous commit the parsing fix was added after a separator check +by accident, making it not execute properly. This commit moves it into the +right place. +--- + src/entry.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/entry.c b/src/entry.c +index 30bedb3..da1a02c 100644 +--- a/src/entry.c ++++ b/src/entry.c +@@ -638,13 +638,13 @@ get_range(bitstr_t * bits, int low, int high, const char *names[], + state = R_STEP; + break; + } ++ if (low_ > high_ && high_ == 0) { ++ high_ = 7; ++ } + if (is_separator(ch)) { + state = R_FINISH; + break; + } +- if (low_ > high_ && high_ == 0) { +- high_ = 7; +- } + return (EOF); + + case R_RANDOM: +-- +2.49.0 + diff --git a/n_option_wait_on_finnishing_grandchild_process.patch b/n_option_wait_on_finnishing_grandchild_process.patch deleted file mode 100644 index b01c6f5..0000000 --- a/n_option_wait_on_finnishing_grandchild_process.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 5cf85f8cbb816ff1df5b317d6f8559b67e1993dd Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= -Date: Wed, 25 Oct 2023 10:58:46 +0200 -Subject: [PATCH] -n option: wait on finnishing grandchild process - -With `WNOHANG` we skip sending the email when waitpid() returns 0, -which happens if the process is still running. Instead, using `0` -parameter will wait for the process to actually stop running. ---- - src/do_command.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/do_command.c b/src/do_command.c -index d7ca840..2ada913 100644 ---- a/src/do_command.c -+++ b/src/do_command.c -@@ -579,7 +579,7 @@ static int child_process(entry * e, char **jobenv) { - if (mail && e->flags & MAIL_WHEN_ERR) { - int jobstatus = -1; - if (jobpid > 0) { -- while (waitpid(jobpid, &jobstatus, WNOHANG) == -1) { -+ while (waitpid(jobpid, &jobstatus, 0) == -1) { - if (errno == EINTR) continue; - log_it("CRON", getpid(), "error", "invalid job pid", errno); - break; diff --git a/plans/default.fmf b/plans/default.fmf new file mode 100644 index 0000000..ad7db18 --- /dev/null +++ b/plans/default.fmf @@ -0,0 +1,5 @@ +summary: Default plan for cronie tests +discover: + how: fmf +execute: + how: tmt diff --git a/sources b/sources index 22b8e68..be7e26e 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (cronie-1.7.0.tar.gz) = a8e6688a164540e2cd3741c58813b6684c4c22a04806bcc8ba028a9ff72f986f165715ac3663bd34133af6566bdbd272a3e7be893f139e315aef35b2dbeb622f +SHA512 (cronie-1.7.2.tar.gz) = 5b55c677a5b812dbfa70f6ee25e41907e99cc63a4883974c6bb8115ad65155d66665704808c338d2f7be6b0a57028c319f2d1115c69bb5f3efdda1efafd144de diff --git a/tests/Can-t-remove-crontab-from-expired-accounts/main.fmf b/tests/Can-t-remove-crontab-from-expired-accounts/main.fmf new file mode 100644 index 0000000..9fd715a --- /dev/null +++ b/tests/Can-t-remove-crontab-from-expired-accounts/main.fmf @@ -0,0 +1,13 @@ +summary: Test for Can't remove crontab from expired accounts +description: '' +contact: Karel Volny +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 5m +extra-summary: + /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts +extra-task: /CoreOS/cronie/Regression/Can-t-remove-crontab-from-expired-accounts diff --git a/tests/Can-t-remove-crontab-from-expired-accounts/runtest.sh b/tests/Can-t-remove-crontab-from-expired-accounts/runtest.sh old mode 100644 new mode 100755 index 73d8914..9678675 --- a/tests/Can-t-remove-crontab-from-expired-accounts/runtest.sh +++ b/tests/Can-t-remove-crontab-from-expired-accounts/runtest.sh @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/Cron-does-uid-lookups-for-non-existent-users/main.fmf b/tests/Cron-does-uid-lookups-for-non-existent-users/main.fmf new file mode 100644 index 0000000..eb0af1f --- /dev/null +++ b/tests/Cron-does-uid-lookups-for-non-existent-users/main.fmf @@ -0,0 +1,14 @@ +summary: Test for Cron does uid lookups for non-existent users +description: "Bug summary: Cron does uid lookups for non-existent users\n" +contact: Vaclav Danek +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 5m +extra-summary: + /CoreOS/cronie/Regression/Cron-does-uid-lookups-for-non-existent-users +extra-task: + /CoreOS/cronie/Regression/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 old mode 100644 new mode 100755 index 72329da..69bb9bd --- a/tests/Cron-does-uid-lookups-for-non-existent-users/runtest.sh +++ b/tests/Cron-does-uid-lookups-for-non-existent-users/runtest.sh @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" @@ -39,8 +38,8 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest - rlRun "sleep 61 | crontab -" 0 - rlRun -s "tail /var/log/cron" 0 + rlRun "sleep 61 | crontab -" 0 "when you run crontab -, it creates a tmp file in /var/spool/cron/" + rlRun -s "tail /var/log/cron" 0,1 "crond should not do uid lookup against the name of the file" rlAssertNotGrep "ORPHAN (no passwd entry)" $rlRun_LOG rm -f $rlRun_LOG rlPhaseEnd diff --git a/tests/MAILTO-problem-with-anacron/Makefile b/tests/MAILTO-problem-with-anacron/Makefile deleted file mode 100644 index cc54f39..0000000 --- a/tests/MAILTO-problem-with-anacron/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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 deleted file mode 100644 index 0eb365c..0000000 --- a/tests/MAILTO-problem-with-anacron/PURPOSE +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index c672b71..0000000 --- a/tests/MAILTO-problem-with-anacron/anacrontab +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 9504398..0000000 --- a/tests/MAILTO-problem-with-anacron/runtest.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/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/main.fmf b/tests/Make-crontab-a-PIE/main.fmf new file mode 100644 index 0000000..cacd35f --- /dev/null +++ b/tests/Make-crontab-a-PIE/main.fmf @@ -0,0 +1,13 @@ +summary: What the test does +description: '' +contact: Jakub Prokes +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie + - elfutils +duration: 5m +extra-summary: /CoreOS/Regression/Make-crontab-a-PIE +extra-task: /CoreOS/Regression/Make-crontab-a-PIE diff --git a/tests/Make-crontab-a-PIE/runtest.sh b/tests/Make-crontab-a-PIE/runtest.sh old mode 100644 new mode 100755 index b0341a1..2b12d50 --- a/tests/Make-crontab-a-PIE/runtest.sh +++ b/tests/Make-crontab-a-PIE/runtest.sh @@ -27,7 +27,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGES="cronie vixie-cron" diff --git a/tests/anacron-segfaults-with-certain-config-data-2/main.fmf b/tests/anacron-segfaults-with-certain-config-data-2/main.fmf new file mode 100644 index 0000000..e3eb557 --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data-2/main.fmf @@ -0,0 +1,14 @@ +summary: try some invalid configs for anacron to check config parser +description: '' +contact: Jakub Prokes +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 5m +extra-summary: + /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2 +extra-task: + /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data-2 diff --git a/tests/anacron-segfaults-with-certain-config-data-2/runtest.sh b/tests/anacron-segfaults-with-certain-config-data-2/runtest.sh old mode 100644 new mode 100755 index bf78c58..e04ec72 --- a/tests/anacron-segfaults-with-certain-config-data-2/runtest.sh +++ b/tests/anacron-segfaults-with-certain-config-data-2/runtest.sh @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 assertRpms() { diff --git a/tests/anacron-segfaults-with-certain-config-data/main.fmf b/tests/anacron-segfaults-with-certain-config-data/main.fmf new file mode 100644 index 0000000..8b738de --- /dev/null +++ b/tests/anacron-segfaults-with-certain-config-data/main.fmf @@ -0,0 +1,13 @@ +summary: Test for anacron segfaults with certain config data +description: '' +contact: Robin Hack +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 20m +extra-summary: + /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data +extra-task: /CoreOS/cronie/Regression/anacron-segfaults-with-certain-config-data diff --git a/tests/anacron-segfaults-with-certain-config-data/runtest.sh b/tests/anacron-segfaults-with-certain-config-data/runtest.sh old mode 100644 new mode 100755 index a2d784d..5dca4f2 --- a/tests/anacron-segfaults-with-certain-config-data/runtest.sh +++ b/tests/anacron-segfaults-with-certain-config-data/runtest.sh @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/config-parsing-issue/runtest.sh b/tests/config-parsing-issue/runtest.sh old mode 100644 new mode 100755 index d95adab..5efb3f2 --- a/tests/config-parsing-issue/runtest.sh +++ b/tests/config-parsing-issue/runtest.sh @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie-anacron" diff --git a/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/main.fmf b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/main.fmf new file mode 100644 index 0000000..f4f142a --- /dev/null +++ b/tests/cron-daemon-fails-to-log-that-it-is-shutting-down/main.fmf @@ -0,0 +1,14 @@ +summary: Test for cron daemon fails to log that it is shutting down. +description: "Bug summary: cron daemon fails to log that it is shutting down.\n" +contact: Robin Hack +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 20m +extra-summary: + /CoreOS/cronie/Regression/cron-daemon-fails-to-log-that-it-is-shutting-down +extra-task: + /CoreOS/cronie/Regression/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 old mode 100644 new mode 100755 index 0aa147d..e7cb538 --- 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 @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/crond-is-missing-RELRO-flags/main.fmf b/tests/crond-is-missing-RELRO-flags/main.fmf new file mode 100644 index 0000000..3cfcb8f --- /dev/null +++ b/tests/crond-is-missing-RELRO-flags/main.fmf @@ -0,0 +1,13 @@ +summary: Test for crond is missing RELRO flags +description: "Bug summary: crond is missing RELRO flags\n\n" +contact: Martin Cermak +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie + - elfutils +duration: 15m +extra-summary: /CoreOS/cronie/Regression/crond-is-missing-RELRO-flags +extra-task: /CoreOS/cronie/Regression/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 old mode 100644 new mode 100755 index c6b55df..a394ca6 --- a/tests/crond-is-missing-RELRO-flags/runtest.sh +++ b/tests/crond-is-missing-RELRO-flags/runtest.sh @@ -27,7 +27,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include rhts environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/main.fmf b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/main.fmf new file mode 100644 index 0000000..f742616 --- /dev/null +++ b/tests/crond-subtask-abnormal-termination-removes-pid-file-in-error/main.fmf @@ -0,0 +1,15 @@ +summary: Test for crond subtask abnormal termination removes pid +description: "Bug summary: crond subtask abnormal termination removes pid file in + error\n" +contact: Robin Hack +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 20m +extra-summary: + /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error +extra-task: + /CoreOS/cronie/Regression/crond-subtask-abnormal-termination-removes-pid-file-in-error 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 old mode 100644 new mode 100755 index caaa895..b093ab3 --- 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 @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/cronie-jobs-environment/Makefile b/tests/cronie-jobs-environment/Makefile deleted file mode 100644 index c2a43a8..0000000 --- a/tests/cronie-jobs-environment/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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 deleted file mode 100644 index 6ef4539..0000000 --- a/tests/cronie-jobs-environment/PURPOSE +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 6a82d15..0000000 --- a/tests/cronie-jobs-environment/cron_test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/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 deleted file mode 100644 index 643879d..0000000 --- a/tests/cronie-jobs-environment/crontab.temp +++ /dev/null @@ -1,12 +0,0 @@ -# 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 deleted file mode 100644 index 9913d21..0000000 Binary files a/tests/cronie-jobs-environment/libfaketime-0.9.1.tar.gz and /dev/null differ diff --git a/tests/cronie-jobs-environment/runtest.sh b/tests/cronie-jobs-environment/runtest.sh deleted file mode 100644 index c6d83ac..0000000 --- a/tests/cronie-jobs-environment/runtest.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/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/main.fmf b/tests/crontab-can-invoke-lookup-for-nonexisted-user/main.fmf new file mode 100644 index 0000000..660a5eb --- /dev/null +++ b/tests/crontab-can-invoke-lookup-for-nonexisted-user/main.fmf @@ -0,0 +1,14 @@ +summary: Test for Cron does uid lookups for non-existent users +description: "Bug summary: Cron does uid lookups for non-existent users\n" +contact: Jakub Prokes +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 10m +extra-summary: + /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user +extra-task: + /CoreOS/cronie/Regression/crontab-can-invoke-lookup-for-nonexisted-user diff --git a/tests/crontab-can-invoke-lookup-for-nonexisted-user/runtest.sh b/tests/crontab-can-invoke-lookup-for-nonexisted-user/runtest.sh old mode 100644 new mode 100755 index 7387dd1..93f9685 --- a/tests/crontab-can-invoke-lookup-for-nonexisted-user/runtest.sh +++ b/tests/crontab-can-invoke-lookup-for-nonexisted-user/runtest.sh @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/crontab-has-wrong-permissions/main.fmf b/tests/crontab-has-wrong-permissions/main.fmf new file mode 100644 index 0000000..c004b59 --- /dev/null +++ b/tests/crontab-has-wrong-permissions/main.fmf @@ -0,0 +1,12 @@ +summary: What the test does +description: '' +contact: Jakub Prokes +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 5m +extra-summary: /CoreOS/cronie/Regression/crontab-has-wrong-permissions +extra-task: /CoreOS/cronie/Regression/crontab-has-wrong-permissions diff --git a/tests/crontab-has-wrong-permissions/runtest.sh b/tests/crontab-has-wrong-permissions/runtest.sh old mode 100644 new mode 100755 index 6a72dd2..10358b0 --- a/tests/crontab-has-wrong-permissions/runtest.sh +++ b/tests/crontab-has-wrong-permissions/runtest.sh @@ -27,7 +27,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGES="cronie vixie-cron" diff --git a/tests/echos-OK-twice-in-init-script/main.fmf b/tests/echos-OK-twice-in-init-script/main.fmf new file mode 100644 index 0000000..5779ae2 --- /dev/null +++ b/tests/echos-OK-twice-in-init-script/main.fmf @@ -0,0 +1,12 @@ +summary: Test for echos "OK" twice in init script +description: '' +contact: Martin Cermak +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 15m +extra-summary: /CoreOS/cronie/Regression/echos-OK-twice-in-init-script +extra-task: /CoreOS/cronie/Regression/echos-OK-twice-in-init-script diff --git a/tests/echos-OK-twice-in-init-script/runtest.sh b/tests/echos-OK-twice-in-init-script/runtest.sh old mode 100644 new mode 100755 index 54afa80..aa4905e --- a/tests/echos-OK-twice-in-init-script/runtest.sh +++ b/tests/echos-OK-twice-in-init-script/runtest.sh @@ -27,50 +27,45 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include rhts environment -. /usr/bin/rhts-environment.sh -. /usr/lib/beakerlib/beakerlib.sh +. /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 - 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" + rlRun "tmpDir=\$(mktemp -d)" 0 "Creating tmp directory"; + testUser="$(makeUser)"; 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 + rlRun -s "service crond restart" + rlAssertNotGrep "FAILED" $rlRun_LOG rlPhaseEnd + if ! rpm -q systemd &>/dev/null; then + rlPhaseStartTest + su -l $testUser -c "service crond restart"; + rlAssertEquals "Expected result of call initscript by unprivileged user is 4" $? 4 + rlPhaseEnd + fi + 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 + rm -f $rlRun_LOG + rm -rf $tmpDir; + userdel -rf $testUser; rlServiceRestore crond - rlRun "popd" - rlRun "rm -r $TEMPDIR" 0 "Removing tmp directory" - #avoid systemd failing to start crond due start-limit - sleep 10 rlPhaseEnd +rlJournalPrintText rlJournalEnd + diff --git a/tests/init-script-failure/main.fmf b/tests/init-script-failure/main.fmf new file mode 100644 index 0000000..3e708fc --- /dev/null +++ b/tests/init-script-failure/main.fmf @@ -0,0 +1,12 @@ +summary: Testing some init script failures +description: '' +contact: Jakub Prokes +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 5m +extra-summary: /CoreOS/cronie/Regression/init-script-failure +extra-task: /CoreOS/cronie/Regression/init-script-failure diff --git a/tests/init-script-failure/runtest.sh b/tests/init-script-failure/runtest.sh old mode 100644 new mode 100755 index c0f6d02..3fcc03e --- a/tests/init-script-failure/runtest.sh +++ b/tests/init-script-failure/runtest.sh @@ -27,7 +27,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/init-scripts-LSB/main.fmf b/tests/init-scripts-LSB/main.fmf new file mode 100644 index 0000000..01e8204 --- /dev/null +++ b/tests/init-scripts-LSB/main.fmf @@ -0,0 +1,12 @@ +summary: Init script should meet LSB specifications +description: '' +contact: Petr Sklenar +component: + - cronie +test: ./runtest.sh +framework: shell +recommend: + - cronie +duration: 5m +extra-summary: /CoreOS/cronie/Sanity/init-script-LSB +extra-task: /CoreOS/cronie/Sanity/init-script-LSB diff --git a/tests/init-scripts-LSB/runtest.sh b/tests/init-scripts-LSB/runtest.sh old mode 100644 new mode 100755 index 7b72ea7..63705fb --- a/tests/init-scripts-LSB/runtest.sh +++ b/tests/init-scripts-LSB/runtest.sh @@ -27,8 +27,7 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include rhts environment -. /usr/bin/rhts-environment.sh -. /usr/share/rhts-library/rhtslib.sh +. /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/ldap-users/Makefile b/tests/ldap-users/Makefile deleted file mode 100644 index e1967a1..0000000 --- a/tests/ldap-users/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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 deleted file mode 100644 index 786822b..0000000 --- a/tests/ldap-users/PURPOSE +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 9d8836a..0000000 --- a/tests/ldap-users/data.ldif +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 4de269b..0000000 --- a/tests/ldap-users/runtest.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/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 deleted file mode 100644 index 97b3c2d..0000000 --- a/tests/ldap-users/slapd.conf +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index 20d07a4..0000000 --- a/tests/ldap-users/user1.cron +++ /dev/null @@ -1,10 +0,0 @@ -# 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/main.fmf b/tests/only-one-running-instance-in-time/main.fmf new file mode 100644 index 0000000..0e0cdbd --- /dev/null +++ b/tests/only-one-running-instance-in-time/main.fmf @@ -0,0 +1,14 @@ +summary: 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. +description: '' +contact: Jakub Prokes +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 5m +extra-summary: /CoreOS/cronie/Regression/only-one-running-instance-in-time +extra-task: /CoreOS/cronie/Regression/only-one-running-instance-in-time diff --git a/tests/only-one-running-instance-in-time/runtest.sh b/tests/only-one-running-instance-in-time/runtest.sh old mode 100644 new mode 100755 index 7d7e8cb..8d0a5ed --- a/tests/only-one-running-instance-in-time/runtest.sh +++ b/tests/only-one-running-instance-in-time/runtest.sh @@ -27,7 +27,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/run-with-syslog-flag/main.fmf b/tests/run-with-syslog-flag/main.fmf new file mode 100644 index 0000000..2ac23bc --- /dev/null +++ b/tests/run-with-syslog-flag/main.fmf @@ -0,0 +1,13 @@ +summary: Test for cronie has a bug when run with syslog flag +description: "Bug summary: cronie has a bug when run with syslog flag\n" +contact: Jakub Prokes +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie + - rsyslog +duration: 10m +extra-summary: /CoreOS/cronie/Regression/run-with-syslog-flag +extra-task: /CoreOS/cronie/Regression/run-with-syslog-flag diff --git a/tests/run-with-syslog-flag/runtest.sh b/tests/run-with-syslog-flag/runtest.sh old mode 100644 new mode 100755 index 1770208..9f7ce5d --- a/tests/run-with-syslog-flag/runtest.sh +++ b/tests/run-with-syslog-flag/runtest.sh @@ -26,7 +26,6 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include Beaker environment -. /usr/bin/rhts-environment.sh || exit 1 . /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie" diff --git a/tests/tests.yml b/tests/tests.yml deleted file mode 100644 index a1167e8..0000000 --- a/tests/tests.yml +++ /dev/null @@ -1,82 +0,0 @@ ---- -# 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/main.fmf b/tests/usr-bin-crontab-has-wrong-permissions/main.fmf new file mode 100644 index 0000000..1c345ad --- /dev/null +++ b/tests/usr-bin-crontab-has-wrong-permissions/main.fmf @@ -0,0 +1,12 @@ +summary: Test for /usr/bin/crontab has wrong permissions +description: "Bug summary: /usr/bin/crontab has wrong permissions\n\n" +contact: Martin Cermak +component: + - cronie +test: ./runtest.sh +framework: beakerlib +recommend: + - cronie +duration: 15m +extra-summary: /CoreOS/cronie/Regression/usr-bin-crontab-has-wrong-permissions +extra-task: /CoreOS/cronie/Regression/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 old mode 100644 new mode 100755 index 5540876..606dbf0 --- a/tests/usr-bin-crontab-has-wrong-permissions/runtest.sh +++ b/tests/usr-bin-crontab-has-wrong-permissions/runtest.sh @@ -27,8 +27,7 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Include rhts environment -. /usr/bin/rhts-environment.sh -. /usr/lib/beakerlib/beakerlib.sh +. /usr/share/beakerlib/beakerlib.sh || exit 1 PACKAGE="cronie"