I created a patch which fixes the problem. With this patch, a last
newline is no longer needed, which is the most user-friendly IMO.

Regards, Thue
Only in thue3: b-cron
Only in thue3: b-cron-se
diff -u cron-3.0pl1/cron.h thue3/cron.h
--- cron-3.0pl1/cron.h  2007-02-04 23:41:32.000000000 +0100
+++ thue3/cron.h        2007-02-04 22:29:58.000000000 +0100
@@ -226,7 +226,7 @@
                get_string __P((char *, int, FILE *, char *)),
                swap_uids __P((void)),
                swap_uids_back __P((void)),
-               load_env __P((char *, FILE *)),
+               load_env __P((char *, FILE *, int *)),
                cron_pclose __P((FILE *)),
                strcmp_until __P((char *, char *, int)),
                allowed __P((char *)),
diff -u cron-3.0pl1/crontab.c thue3/crontab.c
--- cron-3.0pl1/crontab.c       2007-02-04 23:41:32.000000000 +0100
+++ thue3/crontab.c     2007-02-04 22:29:58.000000000 +0100
@@ -808,7 +808,7 @@
        Set_LineNum(1 - NHEADER_LINES)
        CheckErrorCount = 0;  eof = FALSE;
        while (!CheckErrorCount && !eof) {
-               switch (load_env(envstr, tmp)) {
+               switch (load_env(envstr, tmp, &eof)) {
                case ERR:
                        eof = TRUE;
                        break;
Common subdirectories: cron-3.0pl1/debian and thue3/debian
diff -u cron-3.0pl1/entry.c thue3/entry.c
--- cron-3.0pl1/entry.c 2007-02-04 23:41:32.000000000 +0100
+++ thue3/entry.c       2007-02-04 22:29:58.000000000 +0100
@@ -319,13 +319,9 @@
         */ 
        ch = get_string(cmd, MAX_COMMAND, file, "\n");
 
-       /* a file without a \n before the EOF is rude, so we'll complain...
+       /* Allow EOF at the end of the line
+        * if (ch == EOF) { ... }
         */
-       if (ch == EOF) {
-               ecode = e_cmd;
-                log_it("CRON",getpid(),"DEBUG","detected early eof");
-               goto eof;
-       }
 
        /* got the command in the 'cmd' string; save it in *e.
         */
diff -u cron-3.0pl1/env.c thue3/env.c
--- cron-3.0pl1/env.c   2007-02-04 23:41:32.000000000 +0100
+++ thue3/env.c 2007-02-04 22:59:53.000000000 +0100
@@ -134,9 +134,10 @@
  *             TRUE = was an env setting
  */
 int
-load_env(envstr, f)
+load_env(envstr, f, eof)
        char    *envstr;
        FILE    *f;
+       int     *eof;
 {
        long    filepos;
        int     fileline;
@@ -146,8 +147,7 @@
        filepos = ftell(f);
        fileline = LineNumber;
        skip_comments(f);
-       if (EOF == get_string(envstr, MAX_ENVSTR - 1, f, "\n"))
-               return (ERR);
+       *eof = EOF == get_string(envstr, MAX_ENVSTR - 1, f, "\n");
 
     envstr[MAX_ENVSTR - 1] = '\0';
 
diff -u cron-3.0pl1/user.c thue3/user.c
--- cron-3.0pl1/user.c  2007-02-04 23:41:32.000000000 +0100
+++ thue3/user.c        2007-02-04 23:42:54.000000000 +0100
@@ -153,7 +153,7 @@
        FILE    *file;
        user    *u;
        entry   *e;
-       int     status;
+       int     status, eof;
        char    **envp = NULL, **tenvp;
 
        if (!(file = fdopen(crontab_fd, "r"))) {
@@ -206,7 +206,8 @@
        /*
         * load the crontab
         */
-       while ((status = load_env(envstr, file)) >= OK) {
+       eof = FALSE;
+       while (!eof && (status = load_env(envstr, file, &eof)) >= OK) {
                switch (status) {
                case ERR:
                        free_user(u);
@@ -223,6 +224,8 @@
                        if (e) {
                                e->next = u->crontab;
                                u->crontab = e;
+                       } else if (eof) {
+                         goto done;
                        } else {
                                /* stop processing on EOF/syntax error */
                                free_user(u);
Only in thue3: user.c~

Reply via email to