Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP1:GA
cronie
cronie-nheader_lines.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File cronie-nheader_lines.diff of Package cronie
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 enum opt_t {opt_unknown, opt_list, opt_delete, opt_edit, opt_replace, opt_hostset, opt_hostget}; @@ -381,7 +381,7 @@ static void parse_args(int argc, char *a static void list_cmd(void) { char n[MAX_FNAME]; FILE *f; - int ch; + int ch, x; log_it(RealUser, Pid, "LIST", User, 0); if (!glue_strings(n, sizeof n, SPOOL_DIR, User, '/')) { @@ -396,10 +396,25 @@ static void list_cmd(void) { exit(ERROR_EXIT); } - /* file is open. copy to stdout, close. - */ Set_LineNum(1) + /* ignore the top few comments since we probably put them there. + */ + x = 0; + while (EOF != (ch = get_char(f))) { + if ('#' != ch) { + putchar(ch); + 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 stdout. + */ + while (EOF != (ch = get_char(f))) putchar(ch); fclose(f); } @@ -475,7 +490,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; @@ -527,13 +542,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); @@ -741,6 +768,7 @@ static int replace_cmd(void) { int error = 0; entry *e; uid_t file_owner; + time_t now = time(NULL); char **envp; char *safename; @@ -770,10 +798,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);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor