From a56073651509de2445913cddabbc2049c1f6a94f Mon Sep 17 00:00:00 2001 From: amd <amd@gurge.com> Date: Thu, 16 Jul 2015 15:43:01 -0700 Subject: [PATCH] Make sure each file has a trailing newline. --- chkcrontab_lib.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chkcrontab_lib.py b/chkcrontab_lib.py index c1c1004..12778cd 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() -- GitLab