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
Tags
No related merge requests found
...@@ -693,7 +693,7 @@ class CronLineTimeAction(object): ...@@ -693,7 +693,7 @@ class CronLineTimeAction(object):
Must be used as a subclass - subclass must implement _CheckTimeField. 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.time_field = time_field
self.user = user self.user = user
self.command = command self.command = command
...@@ -720,12 +720,15 @@ class CronLineTimeAction(object): ...@@ -720,12 +720,15 @@ class CronLineTimeAction(object):
log.LineError(log.MSG_INVALID_USER, 'Invalid username "%s"' % self.user) log.LineError(log.MSG_INVALID_USER, 'Invalid username "%s"' % self.user)
elif re.search(r'[\s!"#$%&\'()*+,/:;<=>?@[\\\]^`{|}~]', self.user): elif re.search(r'[\s!"#$%&\'()*+,/:;<=>?@[\\\]^`{|}~]', self.user):
log.LineError(log.MSG_INVALID_USER, 'Invalid username "%s"' % self.user) log.LineError(log.MSG_INVALID_USER, 'Invalid username "%s"' % self.user)
else: elif check_passwd:
try: try:
pwd.getpwnam(self.user) pwd.getpwnam(self.user)
except KeyError: except KeyError:
log.LineWarn(log.MSG_USER_NOT_FOUND, log.LineWarn(log.MSG_USER_NOT_FOUND,
'User "%s" not found.' % self.user) 'User "%s" not found.' % self.user)
else:
log.LineWarn(log.MSG_USER_NOT_FOUND,
'User "%s" not found.' % self.user)
# Command checks. # Command checks.
if self.command.startswith('%') or re.search(r'[^\\]%', self.command): 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