2011-04-28 16:05:51 +02:00
|
|
|
Index: src/crontab.c
|
|
|
|
===================================================================
|
2010-10-23 23:48:38 +02:00
|
|
|
--- src/crontab.c.orig
|
|
|
|
+++ src/crontab.c
|
2019-03-19 17:04:35 +01:00
|
|
|
@@ -64,7 +64,7 @@
|
2013-09-25 18:49:18 +02:00
|
|
|
#include "pathnames.h"
|
|
|
|
#include "structs.h"
|
2010-09-27 17:40:15 +02:00
|
|
|
|
|
|
|
-#define NHEADER_LINES 0
|
|
|
|
+#define NHEADER_LINES 3
|
|
|
|
|
2019-11-05 15:16:20 +01:00
|
|
|
#define COMMENT_COLOR "\x1B[34m"
|
|
|
|
#define RESET_COLOR "\033[0m"
|
|
|
|
@@ -500,7 +500,7 @@ static void edit_cmd(void) {
|
2013-09-25 18:49:18 +02:00
|
|
|
char n[MAX_FNAME], q[MAX_TEMPSTR];
|
|
|
|
const char *editor;
|
2010-09-27 17:40:15 +02:00
|
|
|
FILE *f;
|
|
|
|
- int ch = '\0', t;
|
|
|
|
+ int ch = '\0', t, x;
|
|
|
|
struct stat statbuf;
|
|
|
|
struct utimbuf utimebuf;
|
|
|
|
WAIT_T waiter;
|
2019-11-05 15:16:20 +01:00
|
|
|
@@ -552,13 +552,25 @@ static void edit_cmd(void) {
|
2010-09-27 17:40:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Set_LineNum(1)
|
|
|
|
- /*
|
|
|
|
- * NHEADER_LINES processing removed for clarity
|
|
|
|
- * (NHEADER_LINES == 0 in all Red Hat crontabs)
|
|
|
|
- */
|
|
|
|
- /* copy the rest of the crontab (if any) to the temp file.
|
|
|
|
- */
|
|
|
|
- if (EOF != ch)
|
2011-04-28 16:05:51 +02:00
|
|
|
+
|
2010-09-27 17:40:15 +02:00
|
|
|
+ /* ignore the top few comments since we probably put them there.
|
|
|
|
+ */
|
|
|
|
+ x = 0;
|
|
|
|
+ while (EOF != (ch = get_char(f))) {
|
|
|
|
+ if ('#' != ch) {
|
|
|
|
+ putc(ch, NewCrontab);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ while (EOF != (ch = get_char(f)))
|
|
|
|
+ if (ch == '\n')
|
|
|
|
+ break;
|
|
|
|
+ if (++x >= NHEADER_LINES)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* copy the rest of the crontab (if any) to the temp file.
|
|
|
|
+ */
|
|
|
|
+ if (EOF != ch)
|
|
|
|
while (EOF != (ch = get_char(f)))
|
|
|
|
putc(ch, NewCrontab);
|
|
|
|
|
2019-11-05 15:16:20 +01:00
|
|
|
@@ -766,6 +778,7 @@ static int replace_cmd(void) {
|
2010-09-27 17:40:15 +02:00
|
|
|
int error = 0;
|
|
|
|
entry *e;
|
|
|
|
uid_t file_owner;
|
|
|
|
+ time_t now = time(NULL);
|
2011-04-28 16:05:51 +02:00
|
|
|
char **envp;
|
2010-10-23 23:48:38 +02:00
|
|
|
char *safename;
|
2019-03-19 17:04:35 +01:00
|
|
|
int envs = 0, entries = 0;
|
2019-11-05 15:16:20 +01:00
|
|
|
@@ -796,10 +809,10 @@ static int replace_cmd(void) {
|
2010-09-27 17:40:15 +02:00
|
|
|
*
|
|
|
|
* VERY IMPORTANT: make sure NHEADER_LINES agrees with this code.
|
|
|
|
*/
|
|
|
|
- /*fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n");
|
|
|
|
- *fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now));
|
|
|
|
- *fprintf(tmp, "# (Cron version %s)\n", CRON_VERSION);
|
|
|
|
- */
|
|
|
|
+ fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n");
|
|
|
|
+ fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now));
|
|
|
|
+ fprintf(tmp, "# (Cronie version %s)\n", CRON_VERSION);
|
2011-04-28 16:05:51 +02:00
|
|
|
+
|
2010-09-27 17:40:15 +02:00
|
|
|
#ifdef WITH_SELINUX
|
|
|
|
if (selinux_context)
|
|
|
|
fprintf(tmp, "SELINUX_ROLE_TYPE=%s\n", selinux_context);
|