diff --git a/chkcrontab_lib.py b/chkcrontab_lib.py index c1c1004ab8ce41de95bd8e7b49e971eae0a0f4ae..12778cdb7f6b8f452034c4648df8a6c77ee38b3b 100755 --- a/chkcrontab_lib.py +++ b/chkcrontab_lib.py @@ -1083,6 +1083,8 @@ def check_crontab(crontab_file, log, whitelisted_users=None): cron_line_factory = CronLineFactory() with open(crontab_file, 'r') as crontab_f: for line in crontab_f: + missing_newline = line[-1] != "\n" + line = line.strip() line_no += 1 @@ -1091,5 +1093,9 @@ def check_crontab(crontab_file, log, whitelisted_users=None): log.Emit(line_no, line) + # are we missing a trailing newline? + if missing_newline: + log.Error('Cron will not process this file - missing trailing newline') + # Summarize the log messages if there were any. return log.Summary()