- update to 1.5.5 * Avoid warning for strncat. * crontab: fsync to check for full disk * crontab: Add Y/N to retry prompt * entries: Explicitly validate upper ranges and steps * crond: report missing newline before EOF * do not log carriage return * skip directories when given as crontabs * crontab -l colors comment lines in a different color * getdtablesize() can return very high values in containers * Power supply name not detected correctly. * Revert "Avoid creating pid files when crond doesn't fork" * anacron: fix types in comparisons * mics: stop using plain integer as NULL pointer * cron: fix type in comparison and variable shadowing * cron: mark signal number arguments in signal handlers unused * Move allowed() and related function to security.c * cronnext: optionally select jobs by substring * crond: Do not abort loading crontab prematurely in case of error - refresh cronie-nheader_lines.diff - remove cronie-1.5.4-dont_abort_loading_crontab.patch and cronie-1.5.4-always_create_pid_file.patch (applied upstream) OBS-URL: https://build.opensuse.org/request/show/744805 OBS-URL: https://build.opensuse.org/package/show/Base:System/cronie?expand=0&rev=181
79 lines
2.1 KiB
Diff
79 lines
2.1 KiB
Diff
Index: src/crontab.c
|
|
===================================================================
|
|
--- src/crontab.c.orig
|
|
+++ src/crontab.c
|
|
@@ -64,7 +64,7 @@
|
|
#include "pathnames.h"
|
|
#include "structs.h"
|
|
|
|
-#define NHEADER_LINES 0
|
|
+#define NHEADER_LINES 3
|
|
|
|
#define COMMENT_COLOR "\x1B[34m"
|
|
#define RESET_COLOR "\033[0m"
|
|
@@ -500,7 +500,7 @@ static void edit_cmd(void) {
|
|
char n[MAX_FNAME], q[MAX_TEMPSTR];
|
|
const char *editor;
|
|
FILE *f;
|
|
- int ch = '\0', t;
|
|
+ int ch = '\0', t, x;
|
|
struct stat statbuf;
|
|
struct utimbuf utimebuf;
|
|
WAIT_T waiter;
|
|
@@ -552,13 +552,25 @@ static void edit_cmd(void) {
|
|
}
|
|
|
|
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)
|
|
+
|
|
+ /* 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);
|
|
|
|
@@ -766,6 +778,7 @@ static int replace_cmd(void) {
|
|
int error = 0;
|
|
entry *e;
|
|
uid_t file_owner;
|
|
+ time_t now = time(NULL);
|
|
char **envp;
|
|
char *safename;
|
|
int envs = 0, entries = 0;
|
|
@@ -796,10 +809,10 @@ static int replace_cmd(void) {
|
|
*
|
|
* 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);
|
|
+
|
|
#ifdef WITH_SELINUX
|
|
if (selinux_context)
|
|
fprintf(tmp, "SELINUX_ROLE_TYPE=%s\n", selinux_context);
|