Subject: Re: admin/10957: cron ignores last line of crontab if newline is missing
To: None <eravin@panix.com>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 09/06/2000 11:48:20
[ On Tuesday, September 5, 2000 at 12:12:07 (-0700), eravin@panix.com wrote: ]
> Subject: admin/10957: cron ignores last line of crontab if newline is missing
>
> If the last line of a user's crontab does not end in newline, cron
> ignores the entry.

Cron is not unique in this respect.  This is a very common "problem"
with many unix tools.  Programmers often make this mistake, and though
emacs has helped remind many of this mistake, the historical dominance
of line editors in Unix has allowed many such mistakes to remain in
modern code.

> use emacs to edit your crontab (EDITOR=emacs crontab -e)
> go to end of last line.  type control-k several times to
> destroy the terminating newline.  save file - the last entry
> will no longer be executed by cron.
> 
> >Fix:
> 
> if cron can't be fixed to accept the newline-less line, the "crontab"
> command should warn the user about the problem (happens when you use
> emacs to edit your crontab via the "crontab -e" command).

Traditionally it has been emacs that has been programmed to provide such
warnings.  Perhaps a "crontab-mode" is in order!  ;-)

The real fix would be to change cron (and other such failing tools) to
use fgets() or fgetln() and to make sure they treat EOF as EOL too.

Cron in particular re-invents fgets() and unfortunately its version
makes the following claim:

 *              (4) returns EOF or terminating character, whichever

implying that it cannot retain any of the data between the last line
terminator and the end of the file.

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>