From 5feecbf8b5ca5f263111d6c05f238bcb30a73c4e Mon Sep 17 00:00:00 2001 From: Hanspeter Spalinger <hanspeter@spahan.ch> Date: Wed, 10 Aug 2016 09:00:34 +0200 Subject: [PATCH] option to disable passwd user check --- chkcrontab_lib.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chkcrontab_lib.py b/chkcrontab_lib.py index 54cc703..0313c61 100755 --- a/chkcrontab_lib.py +++ b/chkcrontab_lib.py @@ -693,7 +693,7 @@ class CronLineTimeAction(object): Must be used as a subclass - subclass must implement _CheckTimeField. """ - def __init__(self, time_field, user, command): + def __init__(self, time_field, user, command, check_passwd=True): self.time_field = time_field self.user = user self.command = command @@ -720,12 +720,15 @@ class CronLineTimeAction(object): log.LineError(log.MSG_INVALID_USER, 'Invalid username "%s"' % self.user) elif re.search(r'[\s!"#$%&\'()*+,/:;<=>?@[\\\]^`{|}~]', self.user): log.LineError(log.MSG_INVALID_USER, 'Invalid username "%s"' % self.user) - else: + elif check_passwd: try: pwd.getpwnam(self.user) except KeyError: log.LineWarn(log.MSG_USER_NOT_FOUND, 'User "%s" not found.' % self.user) + else: + log.LineWarn(log.MSG_USER_NOT_FOUND, + 'User "%s" not found.' % self.user) # Command checks. if self.command.startswith('%') or re.search(r'[^\\]%', self.command): -- GitLab