Skip to content
Snippets Groups Projects
Commit 5feecbf8 authored by Hanspeter Spalinger's avatar Hanspeter Spalinger
Browse files

option to disable passwd user check

parent 9cba8ec0
Branches
No related tags found
No related merge requests found
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment