temporarily add vixie-cron until we migrate to something else
Hanno

Hanno commited on 2019-10-15 09:37:14
Zeige 16 geänderte Dateien mit 635 Einfügungen und 0 Löschungen.

... ...
@@ -0,0 +1,17 @@
1
+AUX crontab 488 BLAKE2B 51a7ac9bbca8e6e68d0338320535ef6e5a4cb311d6f28a7077f04f3d9f937cdc67e991a97d0ff77b482f81752f1a76b2e7f3013f409fed1191309e8403c19ec9 SHA512 adf8335c4742aea39f825e21475959e638b0926cf557f20aefa93efa1291145ef4e44ec9e4fa0f0d6358c65d2c2b6b411deb4d4ac1dcc811085851910fb8c071
2
+AUX crontab-3.0.1-r4 489 BLAKE2B 09c173a967b845b833b1f0b31705240ceb6453d53f8fd9a9a32115a08aa65df8a24ed75be26905f189b40f953d3fb82d1f51e120d9d857ffbcdd586650d7ce8d SHA512 6387680385c0f75a77a939592a9eb0f6ed30de20f262597875c64847d480a54854c4810001b7872fa769a7f9c45fa3045b2179744efad78fd80a4e8a3f4f326d
3
+AUX crontab.5.diff 772 BLAKE2B f9281e71ac8271e088bc76dbf93085a21ca1dffa04dc02bd18845af5d78838fea032a46f72e33fe440b228536f824a281f82e698d2b1618c952b4929b6e9c1b1 SHA512 2efecff5b35f06ccd65961143c55d8c4be92714c67de6c064b1d3b6975ef9d825c3f4b1b4c32c64efede2a8aa727bb4b22330ac45118f0e2b0feb6b169dfb17d
4
+AUX pamd.compatible 123 BLAKE2B 81739a6ded32d58251cfdcb6d6981aabef949b7d41be100212315f7311ca812e9790ae4b1c5a349ce23e2324cffbb8fe777260a71a55c84b10b0069436c5ce39 SHA512 ea770adf46e00c0d517333f9c072946300db88e53fa7379616f499b6e771a24b0514bd85e24272b16a9dd4599b04514c557519ecb6d51f2ad752b7326376c62b
5
+AUX vixie-cron-4.1-basename.diff 479 BLAKE2B 2b2753ee6c73a66081dce7b9d34b8b075d3a9ca85df9a4f1de9efd5242195aef1b38822b2f45602c402c552b7e0325d2087b74e831b2be01e48d08ce4a42c3ac SHA512 979942efca89b724ca4bdc865d6d5ee3a298c9a1d2af69edbc3d65b3831ff99225eb7b2b4974722d38272b8fb4651806d51f2d1bf2e15e2a65deb1c64f7a8349
6
+AUX vixie-cron-4.1-commandline.patch 387 BLAKE2B 73f6b02459037592b88483f69a28e5ecc55adc0754208eef0148970d752781670e40b7839e4397d123fc00cf4d8f69dab305964e63452e3a70e44a4c0b8ae9d7 SHA512 cfd85bb7999160559d462c246e6b87b0dd472dd859065adc0b3c98332b6da484a2be70a8ad55001f0d701e91f6f7f35972c1c0135cf79f1f7399a5371558c05b
7
+AUX vixie-cron-4.1-cron.deny 148 BLAKE2B 3da92c65667ccacd74e32443e1cd5623d8040a75d783bac5055ed2c6773b1967c516cba82fcfe8ab6a25b65af6d009ae7c4178b332681970c9b2d339bc6473bd SHA512 e2e3a72a527d7d905b8e36f3a988eb71baebab5eb83d4a744d7c4ff4e9d6030d17bd9d8dbea30397027f4f0bbcd8df82ca0c2dd89777aade530af832fa26b5c6
8
+AUX vixie-cron-4.1-crontabrace.patch 658 BLAKE2B 4958e13b14519b484b677a7fd7593f2b17adbbb7cac46d18e0cd68714841e50614d472cdb880ce7f45e456ba30b9119671c44c217edfa81679d5a231bab8be30 SHA512 7aac74563a26bc86bb99488ab0a556a389b5a3d36bed7c80c355a3504d9175d1ac8d437ebdba60831de42a1cc7188b464956f8e94876f8eaf465c9f7005b8242
9
+AUX vixie-cron-4.1-hardlink.patch 369 BLAKE2B a1e3f1106ca15411b59ebb0a162181675189ae9c459169b01893ffc33cd6ca2b256eaee043c48d841cb8ee8789414ebaf7d153f5a600190d6c8b096c2d06fbd9 SHA512 32a804929f1a005edbe58c17e5a4e57141e1b379724e1d760729ba2e5f578b9e509e5e04893e648f463dc250804a9b6303b3dfb7d91c485e57ac02e1c866600a
10
+AUX vixie-cron-4.1-pam.patch 1714 BLAKE2B 04d3b0f76b794e357b8d93f2a95a45f64f9f6baddd92901626f8cad96d9a6033802727d5d54bc3983acf3073b0e860228567f1a6894021c260222de22d99c880 SHA512 596e3888c9ba484b5e4f2b0db14aac0449760d9e4ca91105cac19555c4e45ae96c9e5e302335c5559697881286eae98d7149742e4f01102cc5042edf795d46fc
11
+AUX vixie-cron-4.1-selinux-2.patch 6566 BLAKE2B 21aec85c6ca39e6479252f34d7f8e557fbbc191d8336d056c37a41f487f8c417dea827e3f608f9c605960431583db0453db024f4bbe329a89b81661c5eba641f SHA512 b272b8a9dda7b80f6213ce7b0b38dc3beb16bf38ae202410c9062ae0c14653174dc309fe6dffa469058acf58fae903e0eb670b721213bbdcba3bf21eccfbdfd3
12
+AUX vixie-cron-4.1-setuid_check.patch 767 BLAKE2B b14d22d7a457fd984a65b32bacd30f6f4a01b6670f486d3529a28afd2f880791e0995043066035870e0221b9ae66af68f7134081ec25d18f4757249bd7119784 SHA512 4c49ac5465a142a49799ce1ab816aacd458b44287a3200d9dc35afe1b717d095b2db93eee70913c3c6ee4171afe1293d6838af3f0e6156a96e1e6431ded2af70
13
+AUX vixie-cron.rc7 239 BLAKE2B 64248f4d67ba35ae9c4cbcc9f800782a4da9c0b8780b326cf97d8800cd606cb449ab1725b68d98879d1e33db7552b090ca458fe2ba10f86d360130e65563945f SHA512 d491ae5db8e6ad00bf59380a3358577dfe45a0d137fa5100c22252b8d6d84149d379aae860a30b39c4bdbfc0274ed6cf8fe8d2dfedbea29f4260d5aaab975766
14
+AUX vixie-cron.service 178 BLAKE2B 2ef614075505ef9a48b89ae46d21c5c3544db711b430eabc04870b436437d9b194963b6da572c3bf2c758c4fc7aa37ee90500a1e72fc135ecb8a59f7582ebbba SHA512 09af14c9010c55c204db8755872df531d0e28b473d56f0b5f99c037e2183e2f9e2be9cc66895f4da2036b74efa7bc472e932331fac13722a505ae2be400a068d
15
+DIST vixie-cron-4.1-gentoo-r4.patch.bz2 4204 BLAKE2B 1e276ade20e61ae17e45c10145532e3f32dfa74e32b6cbecde22863de82afb280e97d3b380626451524cfc7fc0663934657509b228a51b3b5ad42e26e5cceb3d SHA512 eec8f89a97927a3557bd1350ed7e9baa0ec133e2c49f8f0fbf51adf62c377451dc48867ca6affcc7576833a5b6b749613c9b99641b1b658853f91d8071c3411b
16
+DIST vixie-cron-4.1.tar.bz2 54246 BLAKE2B 920bf5d95b24cd41677f4a748da02231ed75713ff280acafdf476ad0a71e73068bbad9070fc57d3b0cb39a9539da24182aa2dbc9eb9dfe241adaf9a46f9c5db2 SHA512 1db9a246243dbd4934438ce70bf022215ccffed4b899a77b076d5a7679a7b98a23ef67344e329fc7a836df90685581e10b1c95709db40601c33d2052ce561e04
17
+EBUILD vixie-cron-4.1-r15.ebuild 3467 BLAKE2B b482daee160f119cfe0095654742d3c783cb583c66ffff46999cb0fc7d98793c7584aa8973f2699fba45b7bb4fa8e4ad270d26392f8e2bb9de4d5102f758fdbe SHA512 6cf3d9773e915787233e49c7ce81cfcb1afecf68f76b3579b8a1a2ba68f56637d4a99cc7a7095674d1c0c82855d9a3ddf3cd8e8c53c67044fd9cddb2c3312192
... ...
@@ -0,0 +1,15 @@
1
+# for vixie cron
2
+#
3
+
4
+# Global variables
5
+SHELL=/bin/bash
6
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
7
+MAILTO=root
8
+HOME=/
9
+
10
+# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
11
+*/15 * * * *	root	test -x /usr/sbin/run-crons && /usr/sbin/run-crons
12
+0  *  * * *	root	rm -f /var/spool/cron/lastrun/cron.hourly
13
+0  3  * * *	root	rm -f /var/spool/cron/lastrun/cron.daily
14
+15 4  * * 6	root	rm -f /var/spool/cron/lastrun/cron.weekly
15
+30 5  1 * *	root	rm -f /var/spool/cron/lastrun/cron.monthly
... ...
@@ -0,0 +1,14 @@
1
+# for vixie cron
2
+
3
+# Global variables
4
+SHELL=/bin/bash
5
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
6
+MAILTO=root
7
+HOME=/
8
+
9
+# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
10
+59  *  * * *	root	rm -f /var/spool/cron/lastrun/cron.hourly
11
+9  3  * * *	root	rm -f /var/spool/cron/lastrun/cron.daily
12
+19 4  * * 6	root	rm -f /var/spool/cron/lastrun/cron.weekly
13
+29 5  1 * *	root	rm -f /var/spool/cron/lastrun/cron.monthly
14
+*/10  *  * * *	root	test -x /usr/sbin/run-crons && /usr/sbin/run-crons
... ...
@@ -0,0 +1,35 @@
1
+--- crontab.5.orig	2004-02-19 20:40:04.954132624 +0000
2
++++ crontab.5	2004-02-19 20:45:27.033169168 +0000
3
+@@ -153,6 +153,32 @@
4
+ ``30 4 1,15 * 5''
5
+ would cause a command to be run at 4:30 am on the 1st and 15th of each
6
+ month, plus every Friday.
7
++.PP
8
++Instead of the first five fields, one of eight special strings may
9
++appear:
10
++.IP
11
++.ta 1.5i
12
++string	   meaning
13
++.br
14
++------	   -------
15
++.br
16
++@reboot	   Run once, at startup.
17
++.br
18
++@yearly	   Run once a year, "0 0 1 1 *".
19
++.br
20
++@annually	   (same as @yearly)
21
++.br
22
++@monthly	   Run once a month, "0 0 1 * *".
23
++.br
24
++@weekly	   Run once a week, "0 0 * * 0".
25
++.br
26
++@daily	   Run once a day, "0 0 * * *".
27
++.br
28
++@midnight	   (same as @daily)
29
++.br
30
++@hourly	   Run once an hour, "0 * * * *".
31
++.br
32
++.fi
33
+ .SH EXAMPLE CRON FILE
34
+ .nf
35
+ 
... ...
@@ -0,0 +1,7 @@
1
+#%PAM-1.0
2
+
3
+account required        pam_unix.so
4
+
5
+auth    required        pam_unix.so
6
+
7
+session optional        pam_limits.so
... ...
@@ -0,0 +1,20 @@
1
+diff --exclude='*~' -urN vixie-cron-4.1.orig/cron.c vixie-cron-4.1/cron.c
2
+--- vixie-cron-4.1.orig/cron.c	2005-02-23 02:05:30.730975808 -0500
3
++++ vixie-cron-4.1/cron.c	2005-02-23 02:07:13.233393072 -0500
4
+@@ -25,6 +25,7 @@
5
+ 
6
+ #define	MAIN_PROGRAM
7
+ 
8
++#include <libgen.h>
9
+ #include "cron.h"
10
+ 
11
+ enum timejump { negative, small, medium, large };
12
+@@ -61,7 +62,7 @@
13
+ 	cron_db	database;
14
+ 	int fd;
15
+ 
16
+-	ProgramName = argv[0];
17
++	ProgramName = basename(argv[0]);
18
+ 
19
+ 	setlocale(LC_ALL, "");
20
+ 
... ...
@@ -0,0 +1,13 @@
1
+--- entry.c.orig     2004-08-27 20:09:34.000000000 +0200
2
++++ entry.c	2004-12-01 22:16:10.992268200 +0100
3
+@@ -336,7 +336,9 @@
4
+ 
5
+ 	/* If the first character of the command is '-' it is a cron option.
6
+ 	 */
7
+-	while ((ch = get_char(file)) == '-') {
8
++	ch = get_char(file);
9
++	Skip_Blanks(ch, file)
10
++	while (ch == '-') {
11
+ 		switch (ch = get_char(file)) {
12
+ 		case 'q':
13
+ 			e->flags |= DONT_LOG;
... ...
@@ -0,0 +1,4 @@
1
+# If for any reason you have users in the 'cron' group who should not
2
+# be allowed to run crontab, add them to this file (one username per
3
+# line)
4
+
... ...
@@ -0,0 +1,29 @@
1
+--- vixie-cron-4.1/crontab.c
2
++++ vixie-cron-4.1/crontab.c
3
+@@ -314,8 +314,6 @@
4
+ 		perror("fstat");
5
+ 		goto fatal;
6
+ 	}
7
+-	utimebuf.actime = statbuf.st_atime;
8
+-	utimebuf.modtime = statbuf.st_mtime;
9
+ 
10
+ 	/* Turn off signals. */
11
+ 	(void)signal(SIGHUP, SIG_IGN);
12
+@@ -374,6 +372,17 @@
13
+ 		perror(Filename);
14
+ 		exit(ERROR_EXIT);
15
+ 	}
16
++	if (swap_uids() < OK) {
17
++		perror("swapping uids");
18
++		exit(ERROR_EXIT);
19
++	}
20
++	utimebuf.actime = statbuf.st_atime;
21
++	utimebuf.modtime = statbuf.st_mtime;
22
++	utime(Filename, &utimebuf);
23
++	if (swap_uids_back() < OK) {
24
++		perror("swapping uids back");
25
++		exit(ERROR_EXIT);
26
++	}
27
+ 	utime(Filename, &utimebuf);
28
+  again:
29
+ 	rewind(NewCrontab);
... ...
@@ -0,0 +1,11 @@
1
+--- database.c.orig	2007-04-08 21:06:16.913019387 +0200
2
++++ database.c	2007-04-08 21:06:29.489736093 +0200
3
+@@ -251,7 +251,7 @@
4
+ 		log_it(fname, getpid(), "WRONG FILE OWNER", tabname);
5
+ 		goto next_crontab;
6
+ 	}
7
+-	if (statbuf->st_nlink != 1) {
8
++	if (statbuf->st_nlink != 1 && pw != NULL) {
9
+ 		log_it(fname, getpid(), "BAD LINK COUNT", tabname);
10
+ 		goto next_crontab;
11
+ 	}
... ...
@@ -0,0 +1,67 @@
1
+--- vixie-cron-3.0.1.orig/Makefile	Thu May 30 19:47:00 2002
2
++++ vixie-cron-3.0.1/Makefile	Thu May 30 20:54:46 2002
3
+@@ -55,7 +55,7 @@
4
+ INCLUDE		=	-I.
5
+ #INCLUDE	=
6
+ #<<need getopt()>>
7
+-LIBS		=
8
++LIBS		=	-lpam
9
+ #<<optimize or debug?>>
10
+ OPTIM		=	$(RPM_OPT_FLAGS)
11
+ #OPTIM		=	-g
12
+--- vixie-cron-3.0.1.orig/do_command.c	Thu May 30 19:47:00 2002
13
++++ vixie-cron-3.0.1/do_command.c	Thu May 30 20:55:50 2002
14
+@@ -25,6 +25,18 @@
15
+ 
16
+ #include "cron.h"
17
+ 
18
++#include <security/pam_appl.h>
19
++static pam_handle_t *pamh = NULL;
20
++static const struct pam_conv conv = {
21
++	NULL
22
++};
23
++#define PAM_FAIL_CHECK if (retcode != PAM_SUCCESS) { \
24
++	fprintf(stderr,"\n%s\n",pam_strerror(pamh, retcode)); \
25
++	syslog(LOG_ERR,"%s",pam_strerror(pamh, retcode)); \
26
++	pam_end(pamh, retcode); exit(1); \
27
++	}
28
++
29
++
30
+ static void		child_process(entry *, user *);
31
+ static int		safe_p(const char *, const char *);
32
+
33
+@@ -65,6 +77,7 @@
34
+ 	int stdin_pipe[2], stdout_pipe[2];
35
+ 	char *input_data, *usernm, *mailto;
36
+ 	int children = 0;
37
++	int retcode = 0;
38
+ 
39
+ 	Debug(DPROC, ("[%ld] child_process('%s')\n", (long)getpid(), e->cmd))
40
+ 
41
+@@ -134,6 +147,16 @@
42
+ 		*p = '\0';
43
+ 	}
44
+ 
45
++ 
46
++	retcode = pam_start("cron", usernm, &conv, &pamh);
47
++	PAM_FAIL_CHECK;
48
++	retcode = pam_acct_mgmt(pamh, PAM_SILENT);
49
++	PAM_FAIL_CHECK;
50
++	retcode = pam_open_session(pamh, PAM_SILENT);
51
++	PAM_FAIL_CHECK;
52
++	retcode = pam_setcred(pamh, PAM_ESTABLISH_CRED | PAM_SILENT);
53
++	PAM_FAIL_CHECK;
54
++
55
+ 	/* fork again, this time so we can exec the user's command.
56
+ 	 */
57
+ 	switch (vfork()) {
58
+@@ -507,6 +530,9 @@
59
+ 			Debug(DPROC, (", dumped core"))
60
+ 		Debug(DPROC, ("\n"))
61
+ 	}
62
++	pam_setcred(pamh, PAM_DELETE_CRED | PAM_SILENT);
63
++	retcode = pam_close_session(pamh, PAM_SILENT);
64
++	pam_end(pamh, retcode);
65
+ }
66
+ 
67
+ static int
... ...
@@ -0,0 +1,225 @@
1
+diff -ur vixie-cron-4.1/Makefile vixie-cron-4.1-selinux/Makefile
2
+--- vixie-cron-4.1/Makefile	2004-08-28 02:09:33.000000000 +0800
3
++++ vixie-cron-4.1-selinux/Makefile	2017-04-26 22:16:53.321394815 +0800
4
+@@ -68,7 +68,8 @@
5
+ #<<want to use a nonstandard CC?>>
6
+ CC		=	gcc -Wall -Wno-unused -Wno-comment
7
+ #<<manifest defines>>
8
+-DEFS		=
9
++DEFS		= -s -DWITH_SELINUX
10
++LIBS		+= 	-lselinux
11
+ #(SGI IRIX systems need this)
12
+ #DEFS		=	-D_BSD_SIGNALS -Dconst=
13
+ #<<the name of the BSD-like install program>>
14
+diff -ur vixie-cron-4.1/database.c vixie-cron-4.1-selinux/database.c
15
+--- vixie-cron-4.1/database.c	2004-08-28 02:09:34.000000000 +0800
16
++++ vixie-cron-4.1-selinux/database.c	2017-04-27 01:31:34.757942605 +0800
17
+@@ -28,6 +28,15 @@
18
+ 
19
+ #include "cron.h"
20
+ 
21
++#ifdef WITH_SELINUX
22
++#include <selinux/selinux.h>
23
++#include <selinux/context.h>
24
++#include <selinux/get_context_list.h>
25
++#define SYSUSERNAME "system_u"
26
++#else
27
++#define SYSUSERNAME "*system*"
28
++#endif
29
++
30
+ #define TMAX(a,b) ((a)>(b)?(a):(b))
31
+ 
32
+ static	void		process_crontab(const char *, const char *,
33
+@@ -183,7 +192,7 @@
34
+ 	if (fname == NULL) {
35
+ 		/* must be set to something for logging purposes.
36
+ 		 */
37
+-		fname = "*system*";
38
++		fname = SYSUSERNAME;
39
+ 	} else if ((pw = getpwnam(uname)) == NULL) {
40
+ 		/* file doesn't have a user in passwd file.
41
+ 		 */
42
+@@ -245,6 +254,117 @@
43
+ 		free_user(u);
44
+ 		log_it(fname, getpid(), "RELOAD", tabname);
45
+ 	}
46
++#ifdef WITH_SELINUX
47
++	if (is_selinux_enabled()) {
48
++		security_context_t file_context=NULL;
49
++		security_context_t user_context=NULL;
50
++		context_t current_context = NULL;
51
++		char *current_context_str = NULL;
52
++		struct av_decision avd;
53
++		int retval=0;
54
++		char *seuser=NULL;
55
++		char *level=NULL;
56
++		int sys_user = 0;
57
++
58
++		sys_user = strcmp(SYSUSERNAME, fname);
59
++
60
++		if (fgetfilecon(crontab_fd, &file_context) < OK) {
61
++			log_it(fname, getpid(), "getfilecon FAILED", tabname);
62
++			goto next_crontab;
63
++		}
64
++
65
++		if (sys_user != 0) {
66
++			if (getseuserbyname(fname, &seuser, &level) < 0) {
67
++				log_it(fname, getpid(), "NO SEUSER", tabname);
68
++				goto next_crontab;
69
++			}
70
++		} else {
71
++			if (getcon(&current_context_str) < 0) {
72
++				log_it(fname, getpid(), "getcon FAILED", tabname);
73
++				goto next_crontab;
74
++			}
75
++
76
++			current_context = context_new(current_context_str);
77
++			if (current_context == 0) {
78
++				log_it(fname, getpid(), "context new FAILED", tabname);
79
++				freecon(current_context_str);
80
++				goto next_crontab;
81
++			}
82
++
83
++			seuser = context_user_get(current_context);
84
++			level = context_range_get(current_context);
85
++		}
86
++
87
++		if (get_default_context_with_level(seuser, level, NULL, &user_context) < 0) {
88
++			log_it(fname, getpid(), "NO CONTEXT", tabname);
89
++			freecon(file_context);
90
++			if (sys_user != 0) {
91
++				free(seuser);
92
++				free(level);
93
++			}
94
++			freecon(current_context_str);
95
++			context_free(current_context);
96
++			goto next_crontab;
97
++		}
98
++
99
++		/*
100
++		 * Since crontab files are not directly executed,
101
++		 * crond must ensure that the crontab file has
102
++		 * a context that is appropriate for the context of
103
++		 * the user cron job.  It performs an entrypoint
104
++		 * permission check for this purpose.
105
++		 */
106
++		security_class_t file_class;
107
++		access_vector_t entrypoint_bit;
108
++		file_class = string_to_security_class("file");
109
++		if (file_class == 0) {
110
++			log_it(fname, getpid(), "file CLASS NOT DEFINED", tabname);
111
++			freecon(current_context_str);
112
++			context_free(current_context);
113
++			freecon(user_context);
114
++			freecon(file_context);
115
++			if (sys_user != 0) {
116
++				free(seuser);
117
++				free(level);
118
++			}
119
++			goto next_crontab;
120
++		}
121
++
122
++		entrypoint_bit = string_to_av_perm(file_class, "entrypoint");
123
++		if (entrypoint_bit == 0) {
124
++			log_it(fname, getpid(), "file:entrypoint AV NOT DEFINED", tabname);
125
++			freecon(current_context_str);
126
++			context_free(current_context);
127
++			freecon(user_context);
128
++			freecon(file_context);
129
++			if (sys_user != 0) {
130
++				free(seuser);
131
++				free(level);
132
++			}
133
++			goto next_crontab;
134
++		}
135
++
136
++		retval = security_compute_av_raw(user_context,
137
++			file_context,
138
++			file_class,
139
++			entrypoint_bit,
140
++			&avd);
141
++
142
++		freecon(user_context);
143
++		freecon(file_context);
144
++		if (sys_user != 0) {
145
++			free(seuser);
146
++			free(level);
147
++		}
148
++		context_free(current_context);
149
++		freecon(current_context_str);
150
++
151
++		if (retval || ((entrypoint_bit & avd.allowed) != entrypoint_bit)) {
152
++			log_it(fname, getpid(), "ENTRYPOINT FAILED", tabname);
153
++			goto next_crontab;
154
++		}
155
++	}
156
++#endif
157
+ 	u = load_user(crontab_fd, pw, fname);
158
+ 	if (u != NULL) {
159
+ 		u->mtime = statbuf->st_mtime;
160
+diff -ur vixie-cron-4.1/do_command.c vixie-cron-4.1-selinux/do_command.c
161
+--- vixie-cron-4.1/do_command.c	2004-08-28 02:09:34.000000000 +0800
162
++++ vixie-cron-4.1-selinux/do_command.c	2017-04-27 01:30:49.045144698 +0800
163
+@@ -25,6 +25,12 @@
164
+ 
165
+ #include "cron.h"
166
+ 
167
++#ifdef WITH_SELINUX
168
++#include <selinux/selinux.h>
169
++#include <selinux/context.h>
170
++#include <selinux/get_context_list.h>
171
++#endif
172
++
173
+ static void		child_process(entry *, user *);
174
+ static int		safe_p(const char *, const char *);
175
+ 
176
+@@ -265,6 +271,49 @@
177
+ 				_exit(OK_EXIT);
178
+ 			}
179
+ # endif /*DEBUGGING*/
180
++#ifdef WITH_SELINUX
181
++			if (is_selinux_enabled()) {
182
++				char *seuser = NULL;
183
++				char *level = NULL;
184
++				char *current_context_str = NULL;
185
++				security_context_t scontext;
186
++				context_t current_context = NULL;
187
++
188
++				if (strcmp("system_u", u->name) != 0) {
189
++					if (getseuserbyname(u->name, &seuser, &level) < 0) {
190
++						fprintf(stderr, "getseuserbyname: Could not determine seuser for user %s\n", u->name);
191
++						_exit(ERROR_EXIT);
192
++					}
193
++				} else {
194
++					if (getcon(&current_context_str) < 0) {
195
++						fprintf(stderr, "getcon FAILED\n");
196
++						_exit(ERROR_EXIT);
197
++					}
198
++
199
++					current_context = context_new(current_context_str);
200
++					if (current_context == NULL) {
201
++						fprintf(stderr, "failed to create new context: %s\n", current_context_str);
202
++						freecon(current_context_str);
203
++						_exit(ERROR_EXIT);
204
++					}
205
++
206
++					seuser = context_user_get(current_context);
207
++				}
208
++
209
++				if (get_default_context_with_level(seuser, level, NULL, &scontext) < 0) {
210
++					fprintf(stderr, "get_default_context_with_level: could not get security context for user %s, seuser %s\n", u->name, seuser);
211
++					_exit(ERROR_EXIT);
212
++				}
213
++
214
++				if (setexeccon(scontext) < 0) {
215
++					fprintf(stderr, "setexeccon: Could not set exec context to %s for user %s\n", scontext, u->name);
216
++					_exit(ERROR_EXIT);
217
++				}
218
++				free(seuser);
219
++				free(level);
220
++				freecon(scontext);
221
++			}
222
++#endif
223
+ 			execle(shell, shell, "-c", e->cmd, (char *)0, e->envp);
224
+ 			fprintf(stderr, "execl: couldn't exec `%s'\n", shell);
225
+ 			perror("execl");
... ...
@@ -0,0 +1,29 @@
1
+--- vixie-cron-4.1/do_command.c	2006-05-25 16:44:26.000000000 +0400
2
++++ vixie-cron-4.1.lk/do_command.c	2006-05-25 16:42:25.000000000 +0400
3
+@@ -240,12 +240,23 @@
4
+ 			}
5
+ 		}
6
+ #else
7
+-		setgid(e->pwd->pw_gid);
8
++		
9
+ 		initgroups(usernm, e->pwd->pw_gid);
10
+ #if (defined(BSD)) && (BSD >= 199103)
11
+ 		setlogin(usernm);
12
+ #endif /* BSD */
13
+-		setuid(e->pwd->pw_uid);	/* we aren't root after this... */
14
++		// setuid(e->pwd->pw_uid);	/* we aren't root after this... */
15
++		
16
++	if ( setgid(e->pwd->pw_gid) == -1 ) {
17
++		fprintf(stderr,"can't set gid for %s\n", e->pwd->pw_name);
18
++		_exit(1);
19
++	}
20
++		
21
++	if ( setuid(e->pwd->pw_uid) == -1 ) {
22
++		fprintf(stderr,"can't set uid for %s\n", e->pwd->pw_name);
23
++		_exit(1);
24
++	}
25
++		
26
+ 
27
+ #endif /* LOGIN_CAP */
28
+ 		chdir(env_get("HOME", e->envp));
29
+
... ...
@@ -0,0 +1,12 @@
1
+#!/sbin/openrc-run
2
+# Copyright 1999-2011 Gentoo Foundation
3
+# Distributed under the terms of the GNU General Public License v2
4
+
5
+command=/usr/sbin/cron
6
+pidfile=/var/run/cron.pid
7
+
8
+depend() {
9
+	use clock logger
10
+	need localmount
11
+	provide cron
12
+}
... ...
@@ -0,0 +1,11 @@
1
+[Unit]
2
+Description=Vixie Cron Daemon
3
+
4
+[Service]
5
+Type=forking
6
+ExecStart=/usr/sbin/cron
7
+ExecStop=/bin/kill -TERM $MAINPID
8
+IgnoreSIGPIPE=false
9
+
10
+[Install]
11
+WantedBy=multi-user.target
... ...
@@ -0,0 +1,126 @@
1
+# Copyright 1999-2019 Gentoo Authors
2
+# Distributed under the terms of the GNU General Public License v2
3
+
4
+EAPI=0
5
+
6
+inherit cron toolchain-funcs pam eutils flag-o-matic user systemd
7
+
8
+# no useful homepage, bug #65898
9
+HOMEPAGE="ftp://ftp.isc.org/isc/cron/"
10
+DESCRIPTION="Paul Vixie's cron daemon, a fully featured crond implementation"
11
+
12
+SELINUX_PATCH="${P}-selinux-2.patch"
13
+GENTOO_PATCH_REV="r4"
14
+
15
+SRC_URI="mirror://gentoo/${P}.tar.bz2
16
+	mirror://gentoo/${P}-gentoo-${GENTOO_PATCH_REV}.patch.bz2"
17
+
18
+LICENSE="ISC BSD-2 BSD"
19
+KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
20
+IUSE="selinux pam debug"
21
+
22
+DEPEND="selinux? ( sys-libs/libselinux )
23
+	pam? ( sys-libs/pam )"
24
+
25
+RDEPEND="selinux? ( sys-libs/libselinux )
26
+	 pam? ( sys-libs/pam )"
27
+
28
+#vixie-cron supports /etc/crontab
29
+CRON_SYSTEM_CRONTAB="yes"
30
+
31
+pkg_setup() {
32
+	enewgroup crontab
33
+}
34
+
35
+src_unpack() {
36
+	unpack ${A}
37
+	cd "${S}"
38
+
39
+	epatch "${WORKDIR}"/${P}-gentoo-${GENTOO_PATCH_REV}.patch
40
+	epatch "${FILESDIR}"/crontab.5.diff
41
+	epatch "${FILESDIR}"/${P}-commandline.patch
42
+	epatch "${FILESDIR}"/${P}-basename.diff
43
+	epatch "${FILESDIR}"/${P}-setuid_check.patch
44
+	epatch "${FILESDIR}"/${P}-hardlink.patch
45
+	epatch "${FILESDIR}"/${P}-crontabrace.patch
46
+	use pam && epatch "${FILESDIR}"/${P}-pam.patch
47
+	use selinux && epatch "${FILESDIR}"/${SELINUX_PATCH}
48
+}
49
+
50
+src_compile() {
51
+	use debug && append-flags -DDEBUGGING
52
+
53
+	sed -i -e "s:gcc \(-Wall.*\):$(tc-getCC) \1 ${CFLAGS}:" \
54
+		-e "s:^\(LDFLAGS[ \t]\+=\).*:\1 ${LDFLAGS}:" Makefile \
55
+		|| die "sed Makefile failed"
56
+
57
+	emake || die "emake failed"
58
+}
59
+
60
+src_install() {
61
+	docrondir -m 1730 -o root -g crontab
62
+	docron
63
+	docrontab -m 2755 -o root -g crontab
64
+
65
+	# /etc stuff
66
+	insinto /etc
67
+	newins  "${FILESDIR}"/crontab-3.0.1-r4 crontab
68
+	newins "${FILESDIR}"/${P}-cron.deny cron.deny
69
+
70
+	keepdir /etc/cron.d
71
+	newpamd "${FILESDIR}"/pamd.compatible cron
72
+	newinitd "${FILESDIR}"/vixie-cron.rc7 vixie-cron
73
+
74
+	# doc stuff
75
+	doman crontab.1 crontab.5 cron.8
76
+	dodoc "${FILESDIR}"/crontab
77
+	dodoc CHANGES CONVERSION FEATURES MAIL README THANKS
78
+
79
+	systemd_dounit "${FILESDIR}/${PN}.service"
80
+}
81
+
82
+pkg_preinst() {
83
+	has_version "<${CATEGORY}/${PN}-4.1-r10"
84
+	fix_spool_dir_perms=$?
85
+}
86
+
87
+pkg_postinst() {
88
+	if [[ -f ${ROOT}/etc/init.d/vcron ]]
89
+	then
90
+		ewarn "Please run:"
91
+		ewarn "rc-update del vcron"
92
+		ewarn "rc-update add vixie-cron default"
93
+	fi
94
+
95
+	# bug 71326
96
+	if [[ -u ${ROOT}/etc/pam.d/cron ]] ; then
97
+		echo
98
+		ewarn "Warning: previous ebuilds didn't reset permissions prior"
99
+		ewarn "to installing crontab, resulting in /etc/pam.d/cron being"
100
+		ewarn "installed with the SUID and executable bits set."
101
+		ewarn
102
+		ewarn "Run the following as root to set the proper permissions:"
103
+		ewarn "   chmod 0644 /etc/pam.d/cron"
104
+		echo
105
+	fi
106
+
107
+	# bug 164466
108
+	if [[ $fix_spool_dir_perms = 0 ]] ; then
109
+		echo
110
+		ewarn "Previous ebuilds didn't correctly set permissions on"
111
+		ewarn "the crontabs spool directory. Proper permissions are"
112
+		ewarn "now being set on ${ROOT}var/spool/cron/crontabs/"
113
+		ewarn "Look at this directory if you have a specific configuration"
114
+		ewarn "that needs special ownerships or permissions."
115
+		echo
116
+		chmod 1730 "${ROOT}/var/spool/cron/crontabs" || die "chmod failed"
117
+		chgrp -R crontab "${ROOT}/var/spool/cron/crontabs" || die "chgrp failed"
118
+		cd "${ROOT}/var/spool/cron/crontabs/"
119
+		for cronfile in * ; do
120
+			[[ ! -f $cronfile ]] || chown "$cronfile:crontab" "$cronfile" \
121
+		    || ewarn "chown failed on $cronfile, you probably have an orphan file."
122
+		done
123
+	fi
124
+
125
+	cron_pkg_postinst
126
+}
0 127