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
|
|
|
|
@@ -38,7 +38,7 @@
|
2010-09-27 17:40:15 +02:00
|
|
|
# include <selinux/av_permissions.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
-#define NHEADER_LINES 0
|
|
|
|
+#define NHEADER_LINES 3
|
|
|
|
|
2010-10-23 23:48:38 +02:00
|
|
|
enum opt_t {opt_unknown, opt_list, opt_delete, opt_edit, opt_replace, opt_hostset, opt_hostget};
|
2010-09-27 17:40:15 +02:00
|
|
|
|
2011-04-28 16:05:51 +02:00
|
|
|
@@ -429,7 +429,7 @@ static char *host_specific_filename(char
|
2010-09-27 17:40:15 +02:00
|
|
|
static void edit_cmd(void) {
|
|
|
|
char n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
|
|
|
|
FILE *f;
|
|
|
|
- int ch = '\0', t;
|
|
|
|
+ int ch = '\0', t, x;
|
|
|
|
struct stat statbuf;
|
|
|
|
struct utimbuf utimebuf;
|
|
|
|
WAIT_T waiter;
|
2011-04-28 16:05:51 +02:00
|
|
|
@@ -481,13 +481,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);
|
|
|
|
|
2011-04-28 16:05:51 +02:00
|
|
|
@@ -695,6 +707,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;
|
2010-09-27 17:40:15 +02:00
|
|
|
|
2011-04-28 16:05:51 +02:00
|
|
|
@@ -724,10 +737,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);
|