diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c index 8ee2ccbc146b..deea864692d5 100644 --- a/usr.sbin/cron/crontab/crontab.c +++ b/usr.sbin/cron/crontab/crontab.c @@ -226,7 +226,7 @@ static void list_cmd() { char n[MAX_FNAME]; FILE *f; - int ch; + int ch, x; log_it(RealUser, Pid, "LIST", User); (void) sprintf(n, CRON_TAB(User)); @@ -240,6 +240,24 @@ list_cmd() { /* file is open. copy to stdout, close. */ Set_LineNum(1) + + /* ignore the top few comments since we probably put them there. + */ + for (x = 0; x < NHEADER_LINES; x++) { + ch = get_char(f); + if (EOF == ch) + break; + if ('#' != ch) { + putc(ch, NewCrontab); + break; + } + while (EOF != (ch = get_char(f))) + if (ch == '\n') + break; + if (EOF == ch) + break; + } + while (EOF != (ch = get_char(f))) putchar(ch); fclose(f);