Compare commits

..

No commits in common. "c8s" and "c10s" have entirely different histories.
c8s ... c10s

96 changed files with 3728 additions and 1237 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

11
.gitignore vendored
View File

@ -1,2 +1,11 @@
SOURCES/cronie-1.5.2.tar.gz
/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

View File

@ -1,369 +0,0 @@
From 0f1704a0f8c5fd2a4da6f530694bdd93a7ca3226 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?=
<35430604+opohorel@users.noreply.github.com>
Date: Mon, 8 Nov 2021 16:20:09 +0100
Subject: [PATCH] Add random within range '~' operator
With the operator one can specify for a job a random time or date within
a specified range for a field.
The random value is generated when the crontab where the job is
specified, is loaded.
---
man/crontab.5 | 9 ++
src/entry.c | 262 ++++++++++++++++++++++++++++++++------------------
2 files changed, 176 insertions(+), 95 deletions(-)
diff --git a/man/crontab.5 b/man/crontab.5
index a011c89..ba8f0c3 100644
--- a/man/crontab.5
+++ b/man/crontab.5
@@ -199,6 +199,15 @@ hyphen. The specified range is inclusive. For example, 8-11 for
an 'hours' entry specifies execution at hours 8, 9, 10, and 11. The first
number must be less than or equal to the second one.
.PP
+Randomization of the execution time within a range can be used.
+A random number within a range specified as two numbers separated with
+a tilde is picked. The specified range is inclusive.
+For example, 6~15 for a 'minutes' entry picks a random minute
+within 6 to 15 range. The random number is picked when crontab file is parsed.
+The first number must be less than or equal to the second one. You might omit
+one or both of the numbers specifying the range. For example, ~ for a 'minutes'
+entry picks a random minute within 0 to 59 range.
+.PP
Lists are allowed. A list is a set of numbers (or ranges) separated by
commas. Examples: "1,2,5,9", "0-4,8-12".
.PP
diff --git a/src/entry.c b/src/entry.c
index 92b55f5..9276f47 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -62,9 +62,22 @@ static const char *ecodes[] = {
"out of memory"
};
+typedef enum {
+ R_START,
+ R_AST,
+ R_STEP,
+ R_TERMS,
+ R_NUM1,
+ R_RANGE,
+ R_RANGE_NUM2,
+ R_RANDOM,
+ R_RANDOM_NUM2,
+ R_FINISH,
+} range_state_t;
+
static int get_list(bitstr_t *, int, int, const char *[], int, FILE *),
-get_range(bitstr_t *, int, int, const char *[], int, FILE *),
-get_number(int *, int, const char *[], int, FILE *, const char *),
+get_range(bitstr_t *, int, int, const char *[], FILE *),
+get_number(int *, int, const char *[], FILE *),
set_element(bitstr_t *, int, int, int);
void free_entry(entry * e) {
@@ -449,11 +462,14 @@ get_list(bitstr_t * bits, int low, int high, const char *names[],
/* process all ranges
*/
done = FALSE;
+ /* unget ch to allow get_range() to process it properly
+ */
+ unget_char(ch, file);
while (!done) {
- if (EOF == (ch = get_range(bits, low, high, names, ch, file)))
+ if (EOF == (ch = get_range(bits, low, high, names, file)))
return (EOF);
if (ch == ',')
- ch = get_char(file);
+ continue;
else
done = TRUE;
}
@@ -468,137 +484,193 @@ get_list(bitstr_t * bits, int low, int high, const char *names[],
return (ch);
}
+inline static int is_separator(int ch) {
+ switch (ch) {
+ case '\t':
+ case '\n':
+ case ' ':
+ case ',':
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
static int
get_range(bitstr_t * bits, int low, int high, const char *names[],
- int ch, FILE * file) {
+ FILE * file) {
/* range = number | number "-" number [ "/" number ]
+ * | [number] "~" [number]
*/
+
+ int ch, i, num1, num2, num3;
- int i, num1, num2, num3;
+ /* default value for step
+ */
+ num3 = 1;
+ range_state_t state = R_START;
+
+ while (state != R_FINISH && ((ch = get_char(file)) != EOF)) {
+ switch (state) {
+ case R_START:
+ if (ch == '*') {
+ num1 = low;
+ num2 = high;
+ state = R_AST;
+ break;
+ }
+ if (ch == '~') {
+ num1 = low;
+ state = R_RANDOM;
+ break;
+ }
+ unget_char(ch, file);
+ if (get_number(&num1, low, names, file) != EOF) {
+ state = R_NUM1;
+ break;
+ }
+ return (EOF);
- Debug(DPARS | DEXT, ("get_range()...entering, exit won't show\n"));
+ case R_AST:
+ if (ch == '/') {
+ state = R_STEP;
+ break;
+ }
+ if (is_separator(ch)) {
+ state = R_FINISH;
+ break;
+ }
+ return (EOF);
- if (ch == '*') {
- /* '*' means "first-last" but can still be modified by /step
- */
- num1 = low;
- num2 = high;
- ch = get_char(file);
- if (ch == EOF)
- return (EOF);
- }
- else {
- ch = get_number(&num1, low, names, ch, file, ",- \t\n");
- if (ch == EOF)
- return (EOF);
+ case R_STEP:
+ if (get_number(&num3, 0, PPC_NULL, file) != EOF) {
+ state = R_TERMS;
+ break;
+ }
+ return (EOF);
- if (ch != '-') {
- /* not a range, it's a single number.
- */
- if (EOF == set_element(bits, low, high, num1)) {
- unget_char(ch, file);
+ case R_TERMS:
+ if (is_separator(ch)) {
+ state = R_FINISH;
+ break;
+ }
return (EOF);
- }
- return (ch);
- }
- else {
- /* eat the dash
- */
- ch = get_char(file);
- if (ch == EOF)
+
+ case R_NUM1:
+ if (ch == '-') {
+ state = R_RANGE;
+ break;
+ }
+ if (ch == '~') {
+ state = R_RANDOM;
+ break;
+ }
+ if (is_separator(ch)) {
+ num2 = num1;
+ state = R_FINISH;
+ break;
+ }
return (EOF);
- /* get the number following the dash
- */
- ch = get_number(&num2, low, names, ch, file, "/, \t\n");
- if (ch == EOF || num1 > num2)
+ case R_RANGE:
+ if (get_number(&num2, low, names, file) != EOF) {
+ state = R_RANGE_NUM2;
+ break;
+ }
return (EOF);
- }
- }
- /* check for step size
- */
- if (ch == '/') {
- /* eat the slash
- */
- ch = get_char(file);
- if (ch == EOF)
- return (EOF);
+ case R_RANGE_NUM2:
+ if (ch == '/') {
+ state = R_STEP;
+ break;
+ }
+ if (is_separator(ch)) {
+ state = R_FINISH;
+ break;
+ }
+ return (EOF);
- /* get the step size -- note: we don't pass the
- * names here, because the number is not an
- * element id, it's a step size. 'low' is
- * sent as a 0 since there is no offset either.
- */
- ch = get_number(&num3, 0, PPC_NULL, ch, file, ", \t\n");
- if (ch == EOF || num3 == 0)
- return (EOF);
- }
- else {
- /* no step. default==1.
- */
- num3 = 1;
+ case R_RANDOM:
+ if (is_separator(ch)) {
+ num2 = high;
+ state = R_FINISH;
+ }
+ else if (unget_char(ch, file),
+ get_number(&num2, low, names, file) != EOF) {
+ state = R_TERMS;
+ }
+ /* fail if couldn't find match on previous term
+ */
+ else
+ return (EOF);
+
+ /* if invalid random range was selected */
+ if (num1 > num2)
+ return (EOF);
+
+ /* select random number in range <num1, num2>
+ */
+ num1 = num2 = random() % (num2 - num1 + 1) + num1;
+ break;
+
+
+ default:
+ /* We should never get here
+ */
+ return (EOF);
+ }
}
+ if (state != R_FINISH || ch == EOF)
+ return (EOF);
- /* range. set all elements from num1 to num2, stepping
- * by num3. (the step is a downward-compatible extension
- * proposed conceptually by bob@acornrc, syntactically
- * designed then implemented by paul vixie).
- */
for (i = num1; i <= num2; i += num3)
if (EOF == set_element(bits, low, high, i)) {
unget_char(ch, file);
return (EOF);
}
-
- return (ch);
+ return ch;
}
static int
-get_number(int *numptr, int low, const char *names[], int ch, FILE * file,
- const char *terms) {
+get_number(int *numptr, int low, const char *names[], FILE * file) {
char temp[MAX_TEMPSTR], *pc;
- int len, i;
+ int len, i, ch;
+ char *endptr;
pc = temp;
len = 0;
- /* first look for a number */
- while (isdigit((unsigned char) ch)) {
+ /* get all alnum characters available */
+ while (isalnum((ch = get_char(file)))) {
if (++len >= MAX_TEMPSTR)
goto bad;
*pc++ = (char)ch;
- ch = get_char(file);
}
- *pc = '\0';
- if (len != 0) {
- /* got a number, check for valid terminator */
- if (!strchr(terms, ch))
- goto bad;
- *numptr = atoi(temp);
- return (ch);
+ if (len == 0)
+ goto bad;
+
+ unget_char(ch, file);
+
+ /* try to get number */
+ *numptr = (int) strtol(temp, &endptr, 10);
+ if (*endptr == '\0' && temp != endptr) {
+ /* We have a number */
+ return 0;
}
/* no numbers, look for a string if we have any */
if (names) {
- while (isalpha((unsigned char) ch)) {
- if (++len >= MAX_TEMPSTR)
- goto bad;
- *pc++ = (char)ch;
- ch = get_char(file);
- }
- *pc = '\0';
- if (len != 0 && strchr(terms, ch)) {
- for (i = 0; names[i] != NULL; i++) {
- Debug(DPARS | DEXT,
- ("get_num, compare(%s,%s)\n", names[i], temp));
- if (!strcasecmp(names[i], temp)) {
- *numptr = i + low;
- return (ch);
- }
+ for (i = 0; names[i] != NULL; i++) {
+ Debug(DPARS | DEXT, ("get_num, compare(%s,%s)\n", names[i], temp));
+ if (strcasecmp(names[i], temp) == 0) {
+ *numptr = i + low;
+ return 0;
}
}
+ } else {
+ goto bad;
}
bad:
--
2.35.1

View File

@ -0,0 +1,64 @@
From dd6426f80011aa83a6b43f3ea592a1052690bc09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= <jstanek@redhat.com>
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 5318e71..ec624c7 100644
--- a/src/crontab.c
+++ b/src/crontab.c
@@ -562,6 +562,7 @@ static int backup_crontab(const char *crontab_path) {
if (swap_uids() == -1) {
perror("swapping uids");
+ (void) fclose(crontab_file);
exit(ERROR_EXIT);
}
@@ -584,22 +585,29 @@ static int backup_crontab(const char *crontab_path) {
swapback:
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) {
--
2.47.0

View File

@ -1,25 +0,0 @@
From 07bf4b9037de19b580cfa24f5ad023b56725b285 Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Wed, 5 Jan 2022 19:17:18 +0100
Subject: [PATCH 2/4] get_number: Add missing NUL termination for the scanned
string
---
src/entry.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/entry.c b/src/entry.c
index f2bb717..15ce9b5 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -666,6 +666,7 @@ get_number(int *numptr, int low, const char *names[], FILE * file) {
goto bad;
*pc++ = (char)ch;
}
+ *pc = '\0';
if (len == 0)
goto bad;
--
2.35.1

View File

@ -1,28 +0,0 @@
From 299ef06ea4371afa97301cec64dc8f21c4f7b11b Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Tue, 22 Mar 2022 14:35:48 +0100
Subject: [PATCH 3/4] Fix regression in handling */x crontab entries
Fixes #102
---
src/entry.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/entry.c b/src/entry.c
index 15ce9b5..e9e258b 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -563,7 +563,9 @@ get_range(bitstr_t * bits, int low, int high, const char *names[],
return (EOF);
case R_STEP:
- if (get_number(&num3, 0, PPC_NULL, file) != EOF) {
+ unget_char(ch, file);
+ if (get_number(&num3, 0, PPC_NULL, file) != EOF
+ && num3 != 0) {
state = R_TERMS;
break;
}
--
2.35.1

View File

@ -1,24 +0,0 @@
From 62e53f1cdb9c1e12a01ee7814c92cd937d50328d Mon Sep 17 00:00:00 2001
From: w30023233 <wangyuhang27@huawei.com>
Date: Wed, 23 Mar 2022 15:40:01 +0800
Subject: [PATCH 4/4] Fix regression in handling 1-5 crontab entries
---
src/entry.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/entry.c b/src/entry.c
index e9e258b..bb7cb62 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -595,6 +595,7 @@ get_range(bitstr_t * bits, int low, int high, const char *names[],
return (EOF);
case R_RANGE:
+ unget_char(ch, file);
if (get_number(&num2, low, names, file) != EOF) {
state = R_RANGE_NUM2;
break;
--
2.35.1

376
changelog Normal file
View File

@ -0,0 +1,376 @@
* Mon Sep 11 2023 Jan Staněk <jstanek@redhat.com> - 1.6.1-6
- Migrated to SPDX license
* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Tue Jun 28 2022 Jan Staněk <jstanek@redhat.com> - 1.6.1-2
- Set 'missingok' for /etc/cron.deny to not recreate it on update
* Mon May 02 2022 Ondřej Pohořelský <opohorel@redhat.com> - 1.6.1-1
- New upstream release 1.6.1
* Tue Mar 22 2022 Ondřej Pohořelský <opohorel@redhat.com> - 1.6.0-1
- New upstream release 1.6.0
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Apr 30 2021 Jan Staněk <jstanek@redhat.com> - 1.5.7-2
- Address issues found by static scanners
* Mon Mar 29 2021 Tomáš Mráz <tmraz@fedoraproject.org> - 1.5.7-1
- new upstream release 1.5.7 with bug fixes and enhancements
* Wed Mar 17 2021 Tomáš Mráz <tmraz@fedoraproject.org> - 1.5.6-1
- new upstream release 1.5.6 with bug fixes and enhancements
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.5-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Jul 13 2020 Tom Stellard <tstellar@redhat.com> - 1.5.5-3
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Oct 31 2019 Tomáš Mráz <tmraz@redhat.com> - 1.5.5-1
- new upstream release 1.5.5 with multiple bug fixes and improvements
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Mon Mar 18 2019 Tomáš Mráz <tmraz@redhat.com> - 1.5.4-1
- new upstream release 1.5.4 with regression fix
* Fri Mar 15 2019 Tomáš Mráz <tmraz@redhat.com> - 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 <releng@fedoraproject.org> - 1.5.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Nov 30 2018 Tomáš Mráz <tmraz@redhat.com> - 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 <tmraz@redhat.com> - 1.5.2-3
- use role from the current context for system crontabs (#1639381)
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu May 3 2018 Tomáš Mráz <tmraz@redhat.com> - 1.5.2-1
- new upstream release 1.5.2
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Thu May 4 2017 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-6
- fix Y2038 problems in cron and anacron (#1445136)
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Tue Jan 3 2017 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-4
- make failure of creation of the ghost files in /var non-fatal
* Mon Sep 5 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-3
- on some machines the power supply is named ADP0
* Tue Aug 23 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-2
- query power status directly from kernel
* Thu Jun 23 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-1
- new upstream release
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Mon Jul 13 2015 Tomáš Mráz <tmraz@redhat.com> - 1.5.0-3
- the temp file name used by crontab needs to be ignored by crond
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.5.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Thu May 28 2015 Tomáš Mráz <tmraz@redhat.com> - 1.5.0-1
- new upstream release
* Tue Apr 21 2015 Tomáš Mráz <tmraz@redhat.com> - 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 <tmraz@redhat.com> - 1.4.12-5
- correct the permissions of the anacron timestamp files
* Fri Jan 2 2015 Tomáš Mráz <tmraz@redhat.com> - 1.4.12-4
- check for NULL pamh on two more places (#1176215)
* Tue Dec 2 2014 Tomáš Mráz <tmraz@redhat.com> - 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 <tmraz@redhat.com> - 1.4.12-2
- refresh user entries when jobs are run
* Wed Sep 17 2014 Marcela Mašláňová <mmaslano@redhat.com> - 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 <rel-eng@lists.fedoraproject.org> - 1.4.11-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Fri Jul 11 2014 Tom Callaway <spot@fedoraproject.org> - 1.4.11-8
- fix license handling
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.11-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Wed Apr 30 2014 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.11-6
- unwanted fd could make trouble to SElinux 1075106
* Thu Jan 16 2014 Ville Skyttä <ville.skytta@iki.fi> - 1.4.11-5
- Drop INSTALL from docs, fix rpmlint tabs vs spaces warning.
* Wed Sep 25 2013 Marcela Mašláňová <mmaslano@redhat.com> - 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 <rel-eng@lists.fedoraproject.org> - 1.4.11-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Mon Jul 22 2013 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 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 <tmraz@redhat.com> - 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 <rel-eng@lists.fedoraproject.org> - 1.4.10-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Wed Jan 2 2013 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.10-3
- change configuration files to 644
- change 6755 to 4755 for crontab binary
* Tue Nov 27 2012 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.10-1
- New release 1.4.10
* Thu Nov 22 2012 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.9-1
- New release 1.4.9
* Wed Sep 05 2012 Václav Pavlín <vpavlin@redhat.com> - 1.4.8-13
- Scriptlets replaced with new systemd macros (#850070)
* Fri Jul 27 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.8-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.8-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Wed Oct 26 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.8-10
- Rebuilt for glibc bug#747377
* Tue Oct 25 2011 Tomáš Mráz <tmraz@redhat.com> - 1.4.8-9
- make crond run a little bit later in the boot process (#747759)
* Mon Oct 17 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.8-8
- change triggerun to fix 735802 during upgrade
* Wed Jul 27 2011 Karsten Hopp <karsten@redhat.com> 1.4.8-7
- rebuild again, ppc still had the broken rpm in the buildroots
* Thu Jul 21 2011 Rex Dieter <rdieter@fedoraproject.org> 1.4.8-6
- rebuild (broken rpm in buildroot)
* Thu Jul 21 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.8-5
- fix permission of init.d/crond
* Thu Jun 30 2011 Tomáš Mráz <tmraz@redhat.com> - 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 <tmraz@redhat.com> - 1.4.8-3
- start crond after auditd
* Wed Jun 29 2011 Tomáš Mráz <tmraz@redhat.com> - 1.4.8-2
- fix inotify support to not leak fds (#717505)
* Tue Jun 28 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.8-1
- update to 1.4.8
- create sub-package sysvinit for initscript
* Mon May 9 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.7-3
- missing requirement on systemd-sysv for scriptlets
* Thu May 05 2011 Tomáš Mráz <tmraz@redhat.com> - 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á <mmaslano@redhat.com> - 1.4.7-1
- new release 1.4.7
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.6-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Mon Jan 17 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-8
- enable crond even with systemctl
* Thu Dec 16 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-7
- 663193 rewritten selinux support
* Wed Dec 15 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-6
- apply selinux patch from dwalsh
* Fri Dec 10 2010 Tomas Mraz <tmraz@redhat.com> - 1.4.6-5
- do not lock jobs that fall out of allowed range - 661966
* Thu Dec 02 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-4
- fix post (thanks plautrba for review)
* Tue Nov 30 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-3
- systemd init script 617320
* Tue Nov 30 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-2
- fix typos in man pages
* Fri Oct 22 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-1
- update to 1.4.6
* Fri Aug 13 2010 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 1.4.5-1
- update to new release
* Fri Feb 19 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.4-1
- update to new release
* Mon Feb 15 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.3-3
- 564894 FTBFS DSOLinking
* Thu Nov 5 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.3-2
- 533189 pam needs add a line and selinux needs defined one function
* Fri Oct 30 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.3-1
- 531963 and 532482 creating noanacron package
* Mon Oct 19 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.2-2
- 529632 service crond stop returns appropriate value
* Mon Oct 12 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.2-1
- new release
* Fri Aug 21 2009 Tomas Mraz <tmraz@redhat.com> - 1.4.1-3
- rebuilt with new audit
* Fri Aug 14 2009 Tomas Mraz <tmraz@redhat.com> - 1.4.1-2
- create the anacron timestamps in correct post script
* Fri Aug 14 2009 Marcela Mašláňová <mmaslano@redhat.com> - 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 <tmraz@redhat.com> - 1.4-4
- 515762 move anacron provides and obsoletes to the anacron subpackage
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Mon Jul 20 2009 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 1.3-2
- 506560 check return value of access
* Mon Apr 27 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.3-1
- new release
* Fri Apr 24 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.2-8
- 496973 close file descriptors after exec
* Mon Mar 9 2009 Tomas Mraz <tmraz@redhat.com> - 1.2-7
- rebuild
* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
* Tue Dec 23 2008 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 1.2-4
- update init script
* Thu Sep 25 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.2-3
- add sendmail file into requirement, cause it's needed some MTA
* Thu Sep 18 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.2-2
- 462252 /etc/sysconfig/crond does not need to be executable
* Thu Jun 26 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.2-1
- update to 1.2
* Tue Jun 17 2008 Tomas Mraz <tmraz@redhat.com> - 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 <mmaslano@redhat.com> - 1.1-2
- 49864 upgrade/update problem. Syntax error in spec.
* Wed May 28 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.1-1
- release 1.1
* Tue May 20 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-6
- 446360 check for lock didn't call chkconfig
* Tue Feb 12 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-5
- upgrade from less than cronie-1.0-4 didn't add chkconfig
* Wed Feb 6 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-4
- 431366 after reboot wasn't cron in chkconfig
* Tue Feb 5 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-3
- 431366 trigger part => after update from vixie-cron on cronie will
be daemon running.
* Wed Jan 30 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-2
- change the provides on higher version than obsoletes
* Tue Jan 8 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-1
- packaging cronie
- thank's for help with packaging to my reviewers

View File

@ -1,41 +0,0 @@
From 1f866530f5b3c49012c61b299f3c4e1dceff2a71 Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Thu, 18 Oct 2018 14:25:58 +0200
Subject: [PATCH] Use the role from the crond context for system job contexts.
New SELinux policy added multiple roles for the system_u user on crond_t.
The default context returned from get_default_context_with_level() is now
unconfined_t instead of system_cronjob_t which is incorrect for system cron
jobs.
We use the role to limit the default context to system_cronjob_t.
---
src/security.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/security.c b/src/security.c
index d1bdc7f..5213cf3 100644
--- a/src/security.c
+++ b/src/security.c
@@ -505,6 +505,7 @@ get_security_context(const char *name, int crontab_fd,
retval = get_default_context_with_level(seuser, level, NULL, &scontext);
}
else {
+ const char *current_user, *current_role;
if (getcon(&current_context_str) < 0) {
log_it(name, getpid(), "getcon FAILED", "", 0);
return (security_getenforce() > 0);
@@ -517,8 +518,9 @@ get_security_context(const char *name, int crontab_fd,
return (security_getenforce() > 0);
}
- const char *current_user = context_user_get(current_context);
- retval = get_default_context_with_level(current_user, level, NULL, &scontext);
+ current_user = context_user_get(current_context);
+ current_role = context_role_get(current_context);
+ retval = get_default_context_with_rolelevel(current_user, current_role, level, NULL, &scontext);
freecon(current_context_str);
context_free(current_context);
--
2.14.5

View File

@ -1,26 +0,0 @@
From 0570c2cd979bc9ce1da6a873089e89dbca900a1f Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Tue, 7 May 2019 14:45:53 +0200
Subject: [PATCH] Revert "Avoid creating pid files when crond doesn't fork"
This reverts commit 5b285b46b88dc63689c6a56542cb2ba81f861b66.
The PID file is useful to avoid running multiple crond instances
at once.
---
src/misc.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/misc.c b/src/misc.c
index 42153b8..faf6ffb 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -315,9 +315,6 @@ void acquire_daemonlock(int closeflag) {
return;
}
- if (NoFork == 1)
- return; //move along, nothing to do here...
-
if (fd == -1) {
pidfile = _PATH_CRON_PID;
/* Initial mode is 0600 to prevent flock() race/DoS. */

View File

@ -1,13 +0,0 @@
diff -ru cronie-1.5.2/contrib/cronie.systemd cronie-1.5.2_patched/contrib/cronie.systemd
--- cronie-1.5.2/contrib/cronie.systemd 2018-11-27 15:26:46.797288342 +0100
+++ cronie-1.5.2_patched/contrib/cronie.systemd 2018-11-27 15:26:19.479159225 +0100
@@ -7,6 +7,8 @@
ExecStart=/usr/sbin/crond -n $CRONDARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
+Restart=on-failure
+RestartSec=30s
[Install]
WantedBy=multi-user.target

View File

@ -1,26 +0,0 @@
From 978a00ea7ac92852c153ebb3b2152886730ca51c Mon Sep 17 00:00:00 2001
From: Marcel Plch <mplch@redhat.com>
Date: Fri, 7 Dec 2018 15:01:19 +0100
Subject: [PATCH] Use system-auth instead of password-auth for PAM
authentication (#25)
---
pam/crond | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pam/crond b/pam/crond
index 91964aa..560529d 100644
--- a/pam/crond
+++ b/pam/crond
@@ -4,8 +4,8 @@
#
# Although no PAM authentication is called, auth modules
# are used for credential setting
-auth include password-auth
+auth include system-auth
account required pam_access.so
-account include password-auth
+account include system-auth
session required pam_loginuid.so
-session include password-auth
+session include system-auth

View File

@ -5,13 +5,18 @@
Summary: Cron daemon for executing programs at set times
Name: cronie
Version: 1.5.2
Release: 10%{?dist}
License: MIT and BSD and ISC and GPLv2+
Group: System Environment/Base
Version: 1.7.0
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
# https://github.com/cronie-crond/cronie/pull/163
Patch: n_option_wait_on_finnishing_grandchild_process.patch
# https://github.com/cronie-crond/cronie/pull/184
Patch: 0001-Do-not-leak-file-descriptors-in-backup_crontab.patch
Requires: dailyjobs
%if %{with selinux}
@ -28,34 +33,17 @@ Buildrequires: audit-libs-devel >= 1.4.1
BuildRequires: gcc
BuildRequires: systemd
BuildRequires: make
Obsoletes: %{name}-sysvinit
Requires(post): coreutils sed
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Requires(post): systemd
# Some parts of code could result in a memory leak.
Patch0: fix-memory-leaks.patch
# Some parts of code could result in undefined behavior.
Patch1: fix-unsafe-code.patch
# Use correct selinux role
Patch2: cronie-1.5.2-context-role.patch
# Make systemd restart crond when it fails.
Patch3: cronie-1.5.2-restart-on-failure.patch
# Revert "Avoid creating pid files when crond doesn't fork"
Patch4: cronie-1.5.2-create-pid-files.patch
# Use system-auth in PAM (rhbz#2005526)
Patch5: cronie-1.5.2-use-pam-system-auth.patch
# Add support for "~" ("random within range") + regression fixing patches (rhbz#1832510)
Patch6: 0001-Add-random-within-range-operator.patch
Patch7: 0002-get_number-Add-missing-NUL-termination-for-the-scann.patch
Patch8: 0003-Fix-regression-in-handling-x-crontab-entries.patch
Patch9: 0004-Fix-regression-in-handling-1-5-crontab-entries.patch
# Optimization to close fds from /proc/self/fd in case of high nofile limit after fork
# https://github.com/cronie-crond/cronie/commit/e3682c7135b9176b60d226c60ee4e78cf1ab711b
Patch10: optimization_to_close_fds.patch
%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
@ -66,7 +54,6 @@ SELinux.
%package anacron
Summary: Utility for running regular jobs
Requires: crontabs
Group: System Environment/Base
Provides: dailyjobs
Provides: anacron = 2.4
Obsoletes: anacron <= 2.3
@ -86,7 +73,6 @@ for better utilization of resources shared among multiple systems.
%package noanacron
Summary: Utility for running simple regular jobs in old cron style
Group: System Environment/Base
Provides: dailyjobs
Requires: crontabs
Requires: %{name} = %{version}-%{release}
@ -96,19 +82,7 @@ Old style of running {hourly,daily,weekly,monthly}.jobs without anacron. No
extra features.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%autosetup -p1
%build
%configure \
@ -128,10 +102,10 @@ extra features.
--enable-pie \
--enable-relro
make %{?_smp_mflags} V=2
%make_build V=2
%install
make install DESTDIR=$RPM_BUILD_ROOT DESTMAN=$RPM_BUILD_ROOT%{_mandir}
%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/
@ -237,342 +211,4 @@ exit 0
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/dailyjobs
%changelog
* Thu Nov 30 2023 Ondřej Pohořelský <opohorel@redhat.com> - 1.5.2-10
- Bump release because of CI issues
- Related: RHEL-2609
* Thu Nov 30 2023 Ondřej Pohořelský <opohorel@redhat.com> - 1.5.2-9
- Add `optimization_to_close_fds.patch`
- Resolves: RHEL-2609
* Mon Jul 11 2022 Jan Staněk <jstanek@redhat.com> - 1.5.2-8
- Set 'missingok' for /etc/cron.deny to not recreate it on update
* Mon May 02 2022 Ondřej Pohořelský <opohorel@redhat.com> - 1.5.2-7
- Add support for "~" ("random within range")
Resolves: rhbz#1832510
* Mon Sep 20 2021 Jan Staněk <jstanek@redhat.com> - 1.5.2-6
- Use system-auth for PAM authentication
Resolves: rhbz#2005526
* Fri Sep 03 2021 Jan Staněk <jstanek@redhat.com> - 1.5.2-5
- Create PID files even when crond does not fork
Resolves: rhbz#1926300
* Wed Jun 12 2019 Marcel Plch <mplch@redhat.com> - 1.5.2-4
- Make crond restart on failure
- Resolves: rhbz#1715137
* Mon May 20 2019 Marcel Plch <mplch@redhat.com> - 1.5.2-3
- use role from the current context for system crontabs
- Resolves: rhbz#1708557
* Fri Sep 07 2018 Marcel Plch <mplch@redhat.com> - 1.5.2-2
- Covscan issues review
- Fix potential memory leaks
- Fix unsafe code
- Resolves: rhbz#1602467
* Thu May 3 2018 Tomáš Mráz <tmraz@redhat.com> - 1.5.2-1
- new upstream release 1.5.2
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Thu May 4 2017 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-6
- fix Y2038 problems in cron and anacron (#1445136)
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Tue Jan 3 2017 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-4
- make failure of creation of the ghost files in /var non-fatal
* Mon Sep 5 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-3
- on some machines the power supply is named ADP0
* Tue Aug 23 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-2
- query power status directly from kernel
* Thu Jun 23 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-1
- new upstream release
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Mon Jul 13 2015 Tomáš Mráz <tmraz@redhat.com> - 1.5.0-3
- the temp file name used by crontab needs to be ignored by crond
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.5.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Thu May 28 2015 Tomáš Mráz <tmraz@redhat.com> - 1.5.0-1
- new upstream release
* Tue Apr 21 2015 Tomáš Mráz <tmraz@redhat.com> - 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 <tmraz@redhat.com> - 1.4.12-5
- correct the permissions of the anacron timestamp files
* Fri Jan 2 2015 Tomáš Mráz <tmraz@redhat.com> - 1.4.12-4
- check for NULL pamh on two more places (#1176215)
* Tue Dec 2 2014 Tomáš Mráz <tmraz@redhat.com> - 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 <tmraz@redhat.com> - 1.4.12-2
- refresh user entries when jobs are run
* Wed Sep 17 2014 Marcela Mašláňová <mmaslano@redhat.com> - 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 <rel-eng@lists.fedoraproject.org> - 1.4.11-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Fri Jul 11 2014 Tom Callaway <spot@fedoraproject.org> - 1.4.11-8
- fix license handling
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.11-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Wed Apr 30 2014 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.11-6
- unwanted fd could make trouble to SElinux 1075106
* Thu Jan 16 2014 Ville Skyttä <ville.skytta@iki.fi> - 1.4.11-5
- Drop INSTALL from docs, fix rpmlint tabs vs spaces warning.
* Wed Sep 25 2013 Marcela Mašláňová <mmaslano@redhat.com> - 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 <rel-eng@lists.fedoraproject.org> - 1.4.11-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Mon Jul 22 2013 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 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 <tmraz@redhat.com> - 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 <rel-eng@lists.fedoraproject.org> - 1.4.10-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Wed Jan 2 2013 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.10-3
- change configuration files to 644
- change 6755 to 4755 for crontab binary
* Tue Nov 27 2012 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.10-1
- New release 1.4.10
* Thu Nov 22 2012 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.9-1
- New release 1.4.9
* Wed Sep 05 2012 Václav Pavlín <vpavlin@redhat.com> - 1.4.8-13
- Scriptlets replaced with new systemd macros (#850070)
* Fri Jul 27 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.8-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.8-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Wed Oct 26 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.8-10
- Rebuilt for glibc bug#747377
* Tue Oct 25 2011 Tomáš Mráz <tmraz@redhat.com> - 1.4.8-9
- make crond run a little bit later in the boot process (#747759)
* Mon Oct 17 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.8-8
- change triggerun to fix 735802 during upgrade
* Wed Jul 27 2011 Karsten Hopp <karsten@redhat.com> 1.4.8-7
- rebuild again, ppc still had the broken rpm in the buildroots
* Thu Jul 21 2011 Rex Dieter <rdieter@fedoraproject.org> 1.4.8-6
- rebuild (broken rpm in buildroot)
* Thu Jul 21 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.8-5
- fix permission of init.d/crond
* Thu Jun 30 2011 Tomáš Mráz <tmraz@redhat.com> - 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 <tmraz@redhat.com> - 1.4.8-3
- start crond after auditd
* Wed Jun 29 2011 Tomáš Mráz <tmraz@redhat.com> - 1.4.8-2
- fix inotify support to not leak fds (#717505)
* Tue Jun 28 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.8-1
- update to 1.4.8
- create sub-package sysvinit for initscript
* Mon May 9 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.7-3
- missing requirement on systemd-sysv for scriptlets
* Thu May 05 2011 Tomáš Mráz <tmraz@redhat.com> - 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á <mmaslano@redhat.com> - 1.4.7-1
- new release 1.4.7
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.6-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Mon Jan 17 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-8
- enable crond even with systemctl
* Thu Dec 16 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-7
- 663193 rewritten selinux support
* Wed Dec 15 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-6
- apply selinux patch from dwalsh
* Fri Dec 10 2010 Tomas Mraz <tmraz@redhat.com> - 1.4.6-5
- do not lock jobs that fall out of allowed range - 661966
* Thu Dec 02 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-4
- fix post (thanks plautrba for review)
* Tue Nov 30 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-3
- systemd init script 617320
* Tue Nov 30 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-2
- fix typos in man pages
* Fri Oct 22 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.6-1
- update to 1.4.6
* Fri Aug 13 2010 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 1.4.5-1
- update to new release
* Fri Feb 19 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.4-1
- update to new release
* Mon Feb 15 2010 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.3-3
- 564894 FTBFS DSOLinking
* Thu Nov 5 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.3-2
- 533189 pam needs add a line and selinux needs defined one function
* Fri Oct 30 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.3-1
- 531963 and 532482 creating noanacron package
* Mon Oct 19 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.2-2
- 529632 service crond stop returns appropriate value
* Mon Oct 12 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.4.2-1
- new release
* Fri Aug 21 2009 Tomas Mraz <tmraz@redhat.com> - 1.4.1-3
- rebuilt with new audit
* Fri Aug 14 2009 Tomas Mraz <tmraz@redhat.com> - 1.4.1-2
- create the anacron timestamps in correct post script
* Fri Aug 14 2009 Marcela Mašláňová <mmaslano@redhat.com> - 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 <tmraz@redhat.com> - 1.4-4
- 515762 move anacron provides and obsoletes to the anacron subpackage
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Mon Jul 20 2009 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 1.3-2
- 506560 check return value of access
* Mon Apr 27 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.3-1
- new release
* Fri Apr 24 2009 Marcela Mašláňová <mmaslano@redhat.com> - 1.2-8
- 496973 close file descriptors after exec
* Mon Mar 9 2009 Tomas Mraz <tmraz@redhat.com> - 1.2-7
- rebuild
* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
* Tue Dec 23 2008 Marcela Mašláňová <mmaslano@redhat.com> - 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á <mmaslano@redhat.com> - 1.2-4
- update init script
* Thu Sep 25 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.2-3
- add sendmail file into requirement, cause it's needed some MTA
* Thu Sep 18 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.2-2
- 462252 /etc/sysconfig/crond does not need to be executable
* Thu Jun 26 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.2-1
- update to 1.2
* Tue Jun 17 2008 Tomas Mraz <tmraz@redhat.com> - 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 <mmaslano@redhat.com> - 1.1-2
- 49864 upgrade/update problem. Syntax error in spec.
* Wed May 28 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.1-1
- release 1.1
* Tue May 20 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-6
- 446360 check for lock didn't call chkconfig
* Tue Feb 12 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-5
- upgrade from less than cronie-1.0-4 didn't add chkconfig
* Wed Feb 6 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-4
- 431366 after reboot wasn't cron in chkconfig
* Tue Feb 5 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-3
- 431366 trigger part => after update from vixie-cron on cronie will
be daemon running.
* Wed Jan 30 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-2
- change the provides on higher version than obsoletes
* Tue Jan 8 2008 Marcela Maslanova <mmaslano@redhat.com> - 1.0-1
- packaging cronie
- thank's for help with packaging to my reviewers
%autochangelog

View File

@ -1,140 +0,0 @@
diff -ru cronie-1.5.2/anacron/readtab.c cronie-1.5.2_patched/anacron/readtab.c
--- cronie-1.5.2/anacron/readtab.c 2017-09-14 13:53:21.000000000 +0200
+++ cronie-1.5.2_patched/anacron/readtab.c 2018-09-07 15:13:17.752498050 +0200
@@ -134,8 +134,19 @@
var_len = (int)strlen(env_var);
val_len = (int)strlen(value);
+ if (!var_len) {
+ return;
+ }
+
er = obstack_alloc(&tab_o, sizeof(env_rec));
+ if (er == NULL) {
+ die_e("Cannot allocate memory.");
+ }
+
er->assign = obstack_alloc(&tab_o, var_len + 1 + val_len + 1);
+ if (er->assign == NULL) {
+ die_e("Cannot allocate memory.");
+ }
strcpy(er->assign, env_var);
er->assign[var_len] = '=';
strcpy(er->assign + var_len + 1, value);
@@ -167,15 +178,24 @@
return;
}
jr = obstack_alloc(&tab_o, sizeof(job_rec));
+ if (jr == NULL) {
+ die_e("Cannot allocate memory.");
+ }
jr->period = period;
jr->named_period = 0;
delay += random_number;
jr->delay = delay;
jr->tab_line = line_num;
jr->ident = obstack_alloc(&tab_o, ident_len + 1);
+ if (jr->ident == NULL) {
+ die_e("Cannot allocate memory.");
+ }
strcpy(jr->ident, ident);
jr->arg_num = job_arg_num(ident);
jr->command = obstack_alloc(&tab_o, command_len + 1);
+ if (jr->command == NULL) {
+ die_e("Cannot allocate memory.");
+ }
strcpy(jr->command, command);
jr->job_pid = jr->mailer_pid = 0;
if (last_job_rec != NULL) last_job_rec->next = jr;
@@ -208,6 +228,9 @@
}
jr = obstack_alloc(&tab_o, sizeof(job_rec));
+ if (jr == NULL) {
+ die_e("Cannot allocate memory.");
+ }
if (!strncmp ("@monthly", periods, 8)) {
jr->named_period = 1;
} else if (!strncmp("@yearly", periods, 7) || !strncmp("@annually", periods, 9) || !strncmp(/* backwards compat misspelling */"@annualy", periods, 8)) {
@@ -225,9 +248,15 @@
jr->delay = delay;
jr->tab_line = line_num;
jr->ident = obstack_alloc(&tab_o, ident_len + 1);
+ if (jr->ident == NULL) {
+ die_e("Cannot allocate memory.");
+ }
strcpy(jr->ident, ident);
jr->arg_num = job_arg_num(ident);
jr->command = obstack_alloc(&tab_o, command_len + 1);
+ if (jr->command == NULL) {
+ die_e("Cannot allocate memory.");
+ }
strcpy(jr->command, command);
jr->job_pid = jr->mailer_pid = 0;
if (last_job_rec != NULL) last_job_rec->next = jr;
diff -ru cronie-1.5.2/anacron/runjob.c cronie-1.5.2_patched/anacron/runjob.c
--- cronie-1.5.2/anacron/runjob.c 2018-01-24 17:02:33.000000000 +0100
+++ cronie-1.5.2_patched/anacron/runjob.c 2018-09-07 15:13:17.752498050 +0200
@@ -104,9 +104,44 @@
static void
xputenv(const char *s)
{
- char *copy = strdup (s);
- if (!copy) die_e("Not enough memory to set the environment");
- if (putenv(copy)) die_e("Can't set the environment");
+ char *name = NULL, *val = NULL;
+ char *eq_ptr;
+ const char *errmsg;
+ size_t eq_index;
+
+ if (s == NULL) {
+ die_e("Invalid environment string");
+ }
+
+ eq_ptr = strchr(s, '=');
+ if (eq_ptr == NULL) {
+ die_e("Invalid environment string");
+ }
+
+ eq_index = (size_t) (eq_ptr - s);
+
+ name = malloc((eq_index + 1) * sizeof(char));
+ if (name == NULL) {
+ die_e("Not enough memory to set the environment");
+ }
+
+ val = malloc((strlen(s) - eq_index) * sizeof(char));
+ if (val == NULL) {
+ die_e("Not enough memory to set the environment");
+ }
+
+ strncpy(name, s, eq_index);
+ name[eq_index] = '\0';
+ strcpy(val, s + eq_index + 1);
+
+ if (setenv(name, val, 1)) {
+ die_e("Can't set the environment");
+ }
+
+ free(name);
+ free(val);
+ return;
+
}
static void
diff -ru cronie-1.5.2/src/entry.c cronie-1.5.2_patched/src/entry.c
--- cronie-1.5.2/src/entry.c 2017-09-14 13:53:21.000000000 +0200
+++ cronie-1.5.2_patched/src/entry.c 2018-09-07 15:13:17.752498050 +0200
@@ -131,8 +131,10 @@
goto eof;
}
ch = get_char(file);
- if (ch == EOF)
+ if (ch == EOF) {
+ free(e);
return NULL;
+ }
}
if (ch == '@') {

View File

@ -1,117 +0,0 @@
diff -ru cronie-1.5.2/src/cronnext.c cronie-1.5.2_patched/src/cronnext.c
--- cronie-1.5.2/src/cronnext.c 2018-05-03 18:41:12.000000000 +0200
+++ cronie-1.5.2_patched/src/cronnext.c 2018-09-07 15:17:54.555924440 +0200
@@ -71,13 +71,13 @@
/*
* print entry flags
*/
-char *flagname[]= {
- [MIN_STAR] = "MIN_STAR",
- [HR_STAR] = "HR_STAR",
- [DOM_STAR] = "DOM_STAR",
- [DOW_STAR] = "DOW_STAR",
- [WHEN_REBOOT] = "WHEN_REBOOT",
- [DONT_LOG] = "DONT_LOG"
+const char *flagname[]= {
+ "MIN_STAR",
+ "HR_STAR",
+ "DOM_STAR",
+ "DOW_STAR",
+ "WHEN_REBOOT",
+ "DONT_LOG"
};
void printflags(char *indent, int flags) {
@@ -85,8 +85,8 @@
int first = 1;
printf("%s flagnames:", indent);
- for (f = 1; f < sizeof(flagname); f = f << 1)
- if (flags & f) {
+ for (f = 0; f < sizeof(flagname)/sizeof(char *); f++)
+ if (flags & (int)1 << f) {
printf("%s%s", first ? " " : "|", flagname[f]);
first = 0;
}
diff -ru cronie-1.5.2/src/do_command.c cronie-1.5.2_patched/src/do_command.c
--- cronie-1.5.2/src/do_command.c 2017-09-14 13:53:21.000000000 +0200
+++ cronie-1.5.2_patched/src/do_command.c 2018-09-07 15:17:54.555924440 +0200
@@ -418,7 +418,7 @@
if (mailto && safe_p(usernm, mailto)
&& strncmp(MailCmd,"off",3) && !SyslogOutput) {
char **env;
- char mailcmd[MAX_COMMAND];
+ char mailcmd[MAX_COMMAND+1]; /* +1 for terminator */
char hostname[MAXHOSTNAMELEN];
char *content_type = env_get("CONTENT_TYPE", jobenv),
*content_transfer_encoding =
@@ -434,7 +434,7 @@
}
}
else {
- strncpy(mailcmd, MailCmd, MAX_COMMAND);
+ strncpy(mailcmd, MailCmd, MAX_COMMAND+1);
}
if (!(mail = cron_popen(mailcmd, "w", e->pwd, jobenv))) {
perror(mailcmd);
diff -ru cronie-1.5.2/src/env.c cronie-1.5.2_patched/src/env.c
--- cronie-1.5.2/src/env.c 2017-09-14 13:53:21.000000000 +0200
+++ cronie-1.5.2_patched/src/env.c 2018-09-07 15:17:54.554924435 +0200
@@ -63,7 +63,7 @@
for (i = 0; i < count; i++)
if ((p[i] = strdup(envp[i])) == NULL) {
save_errno = errno;
- while (--i >= 0)
+ while (i-- > 0)
free(p[i]);
free(p);
errno = save_errno;
@@ -263,7 +263,9 @@
}
if (state != FINI && state != EQ2 && !(state == VALUE && !quotechar)) {
Debug(DPARS, ("load_env, not an env var, state = %d\n", state));
- fseek(f, filepos, 0);
+ if (fseek(f, filepos, 0)) {
+ return ERR;
+ }
Set_LineNum(fileline);
return (FALSE);
}
diff -ru cronie-1.5.2/src/globals.h cronie-1.5.2_patched/src/globals.h
--- cronie-1.5.2/src/globals.h 2017-01-17 16:53:50.000000000 +0100
+++ cronie-1.5.2_patched/src/globals.h 2018-09-07 15:17:54.555924440 +0200
@@ -77,7 +77,7 @@
XTRN time_t StartTime;
XTRN int NoFork;
XTRN int PermitAnyCrontab;
-XTRN char MailCmd[MAX_COMMAND];
+XTRN char MailCmd[MAX_COMMAND+1]; /* +1 for terminator */
XTRN char cron_default_mail_charset[MAX_ENVSTR];
XTRN int EnableClustering;
XTRN int ChangePath;
diff -ru cronie-1.5.2/src/security.c cronie-1.5.2_patched/src/security.c
--- cronie-1.5.2/src/security.c 2017-09-14 13:29:47.000000000 +0200
+++ cronie-1.5.2_patched/src/security.c 2018-09-07 15:17:54.554924435 +0200
@@ -417,7 +417,7 @@
}
}
- if (strcmp(u->scontext, ucontext)) {
+ if (!ucontext || strcmp(u->scontext, ucontext)) {
if (!cron_authorize_range(u->scontext, ucontext)) {
if (security_getenforce() > 0) {
# ifdef WITH_AUDIT
diff -ru cronie-1.5.2/src/user.c cronie-1.5.2_patched/src/user.c
--- cronie-1.5.2/src/user.c 2017-01-17 16:53:50.000000000 +0100
+++ cronie-1.5.2_patched/src/user.c 2018-09-07 15:17:54.555924440 +0200
@@ -44,6 +44,10 @@
free_user (user * u) {
entry *e, *ne;
+ if (!u) {
+ return;
+ }
+
free(u->name);
free(u->tabname);
for (e = u->crontab; e != NULL; e = ne) {

View File

@ -1,6 +1,6 @@
--- !Policy
product_versions:
- rhel-8
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier1.functional}
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -0,0 +1,25 @@
From 5cf85f8cbb816ff1df5b317d6f8559b67e1993dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= <opohorel@redhat.com>
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;

View File

@ -1,40 +0,0 @@
--- ./src/do_command.c 2023-09-07 09:40:32.016272074 +0200
+++ ./src/do_command.c 2023-09-07 09:43:04.938995232 +0200
@@ -30,6 +30,7 @@
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <dirent.h>
#include "externs.h"
#include "funcs.h"
@@ -239,10 +240,26 @@
{
char *shell = env_get("SHELL", jobenv);
int fd, fdmax = getdtablesize();
+ DIR *dir;
+ struct dirent *dent;
- /* close all unwanted open file descriptors */
- for(fd = STDERR + 1; fd < fdmax; fd++) {
- close(fd);
+ /*
+ * if /proc is mounted, we can optimize what fd can be closed,
+ * but if it isn't available, fall back to the previous behavior.
+ */
+ if ((dir = opendir("/proc/self/fd")) != NULL) {
+ while ((dent = readdir(dir)) != NULL) {
+ if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
+ continue;
+ fd = atoi(dent->d_name);
+ if (fd > STDERR_FILENO)
+ close(fd);
+ }
+ } else {
+ /* close all unwanted open file descriptors */
+ for(fd = STDERR + 1; fd < fdmax; fd++) {
+ close(fd);
+ }
}
#if DEBUGGING

10
plans/tier1-internal.fmf Normal file
View File

@ -0,0 +1,10 @@
summary: Internal Tier1 tests plan
discover:
how: fmf
filter: 'tier: 1'
url: https://pkgs.devel.redhat.com/git/tests/cronie
execute:
how: tmt
adjust:
enabled: false
when: distro == centos-stream or distro == fedora

View File

@ -1 +1 @@
SHA512 (cronie-1.5.2.tar.gz) = e306b4b8388bff0181ca4b3f15b81c0881d727b0f502c28204e8325359c49baeb1b1a4a5751ffc11eb5ebdeefe42704b77f6727f029c60c99c70b9885f6b4d18
SHA512 (cronie-1.7.0.tar.gz) = a8e6688a164540e2cd3741c58813b6684c4c22a04806bcc8ba028a9ff72f986f165715ac3663bd34133af6566bdbd272a3e7be893f139e315aef35b2dbeb622f

View File

@ -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 <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <kvolny@redhat.com>" > $(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)

View File

@ -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 <kvolny@redhat.com>

View File

@ -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 <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <vdanek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <vdanek@redhat.com>" > $(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)

View File

@ -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 <vdanek@redhat.com>
Bug summary: Cron does uid lookups for non-existent users

View File

@ -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 <vdanek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron
# Description: Test for MAILTO problem with anacron
# Author: Karel Volny <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <kvolny@redhat.com>" > $(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)

View File

@ -0,0 +1,4 @@
PURPOSE of /CoreOS/cronie/Regression/MAILTO-problem-with-anacron
Description: Test for MAILTO problem with anacron
Author: Karel Volny <kvolny@redhat.com>
Bug summary: MAILTO problem with anacron

View File

@ -0,0 +1,5 @@
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=testuser1
1 0 test echo "Hello anacron!"

View File

@ -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 <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/Regression/Regression/Make-crontab-a-PIE
# Description: What the test does
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/Regression/Regression/Make-crontab-a-PIE
Description: What the test does
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -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 <jprokes@redhat.com>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <rhack@redhat.com>" > $(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)

View File

@ -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 <rhack@redhat.com>

View File

@ -0,0 +1,3 @@
#!/bin/bash
echo "$1" > /tmp/core.lock

View File

@ -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 <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -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 <jprokes@redhat.com>
Bug summary: cronie-anacron-1.4.4-14.el6.x86_64 doesn't like its own /etc/anacrontab syntax

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <rhack@redhat.com>" > $(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)

View File

@ -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 <rhack@redhat.com>
Bug summary: cron daemon fails to log that it is shutting down.

View File

@ -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 <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <mcermak@redhat.com>" > $(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)

View File

@ -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 <mcermak@redhat.com>
Bug summary: crond is missing RELRO flags

View File

@ -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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <rhack@redhat.com>" > $(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)

View File

@ -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 <rhack@redhat.com>
Bug summary: crond subtask abnormal termination removes pid file in error

View File

@ -0,0 +1 @@
*/1 * * * * /tmp/run-job.sh

View File

@ -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

View File

@ -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 <rhack@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -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 <jprokes@redhat.com>

View File

@ -0,0 +1,5 @@
#!/bin/bash
printf "LANG=$LANG\n" > /tmp/cronie-jobs-environment.log;
printf "EUID=$EUID\n" >> /tmp/cronie-jobs-environment.log;

View File

@ -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

Binary file not shown.

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -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 <jprokes@redhat.com>
Bug summary: Cron does uid lookups for non-existent users

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/crontab-has-wrong-permissions
# Description: What the test does
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/crontab-has-wrong-permissions
Description: What the test does
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <mcermak@redhat.com>" > $(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)

View File

@ -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 <mcermak@redhat.com>

View File

@ -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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <<EOF1
success() {
echo OK >> $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

View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Regression/init-script-failure
# Description: Testing some init script failures
# Author: Jakub Prokes <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Regression/init-script-failure
Description: Testing some init script failures
Author: Jakub Prokes <jprokes@redhat.com>

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -0,0 +1,62 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/cronie/Sanity/init-script-LSB
# Description: Init script should meet LSB specifications
# Author: Yulia Kopkova <ykopkova@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <psklenar@redhat.com>" > $(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)

View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/cronie/Sanity/init-script-LSB
Description: Init script should meet LSB specifications
Author: Yulia Kopkova <ykopkova@redhat.com>

View File

@ -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 <jscotka@redhat.com>, Yulia Kopkova <ykopkova@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

63
tests/ldap-users/Makefile Normal file
View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

5
tests/ldap-users/PURPOSE Normal file
View File

@ -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 <jprokes@redhat.com>
Bug summary: cronie not creating jobs for ldap users if ldap server is temporarily down.

View File

@ -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

133
tests/ldap-users/runtest.sh Normal file
View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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

View File

@ -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

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -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 <jprokes@redhat.com>

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jprokes@redhat.com>" > $(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)

View File

@ -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 <jprokes@redhat.com>
Bug summary: cronie has a bug when run with syslog flag

View File

@ -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 <jprokes@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

82
tests/tests.yml Normal file
View File

@ -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

View File

@ -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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <mcermak@redhat.com>" > $(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)

View File

@ -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 <mcermak@redhat.com>
Bug summary: /usr/bin/crontab has wrong permissions

View File

@ -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 <mcermak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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