summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron
diff options
context:
space:
mode:
authordds <dds@FreeBSD.org>2004-09-13 18:39:04 +0000
committerdds <dds@FreeBSD.org>2004-09-13 18:39:04 +0000
commit0caca34c521c0df0ce564d2edbc446fc14c5c225 (patch)
tree10dfb0a23b84852b4fb95547e7d5c0bb9d904e1c /usr.sbin/cron
parenta4de4268bdab3fb20f0d1c0617836528eca0ef1e (diff)
downloadFreeBSD-src-0caca34c521c0df0ce564d2edbc446fc14c5c225.zip
FreeBSD-src-0caca34c521c0df0ce564d2edbc446fc14c5c225.tar.gz
Fix for the following behavior:
$ crontab -e [Add an entry with an error in the crontab file.] crontab: errors in crontab file, can't install Do you want to retry the same edit? yes [Exit the editor without any changes.] crontab: no changes made to crontab [Entry is lost.] Now crontab will loop until the error is fixed, or the user answers no.
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r--usr.sbin/cron/crontab/crontab.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c
index a347a9f..9cda6f6 100644
--- a/usr.sbin/cron/crontab/crontab.c
+++ b/usr.sbin/cron/crontab/crontab.c
@@ -309,6 +309,7 @@ edit_cmd() {
WAIT_T waiter;
PID_T pid, xpid;
mode_t um;
+ int syntax_error = 0;
log_it(RealUser, Pid, "BEGIN EDIT", User);
(void) sprintf(n, CRON_TAB(User));
@@ -446,15 +447,15 @@ edit_cmd() {
}
if (statbuf.st_dev != fsbuf.st_dev || statbuf.st_ino != fsbuf.st_ino)
errx(ERROR_EXIT, "temp file must be edited in place");
- if (mtime == statbuf.st_mtime) {
+ if (mtime == statbuf.st_mtime && !syntax_error) {
warnx("no changes made to crontab");
goto remove;
}
warnx("installing new crontab");
switch (replace_cmd()) {
- case 0:
+ case 0: /* Success */
break;
- case -1:
+ case -1: /* Syntax error */
for (;;) {
printf("Do you want to retry the same edit? ");
fflush(stdout);
@@ -462,6 +463,7 @@ edit_cmd() {
(void) fgets(q, sizeof q, stdin);
switch (islower(q[0]) ? q[0] : tolower(q[0])) {
case 'y':
+ syntax_error = 1;
goto again;
case 'n':
goto abandon;
@@ -470,7 +472,7 @@ edit_cmd() {
}
}
/*NOTREACHED*/
- case -2:
+ case -2: /* Install error */
abandon:
warnx("edits left in %s", Filename);
goto done;
OpenPOWER on IntegriCloud