Revert "Don't print LDAP user passwords in log."

This reverts commit b1c9c81d58c80d6b313dd2b8a5c5727ecdf6ac49.

Conflicts:
	plinth/modules/first_boot/forms.py
This commit is contained in:
James Valleroy 2015-07-19 21:27:09 -04:00 committed by Sunil Mohan Adapa
parent cc365fb2eb
commit 86580c9121
3 changed files with 11 additions and 23 deletions

View File

@ -102,31 +102,29 @@ from plinth.errors import ActionError
LOGGER = logging.getLogger(__name__)
def run(action, options=None, async=False, log_full_command=True):
def run(action, options=None, async=False):
"""Safely run a specific action as the current user.
See actions._run for more information.
"""
return _run(action, options, async, False, log_full_command)
return _run(action, options, async, False)
def superuser_run(action, options=None, async=False, log_full_command=True):
def superuser_run(action, options=None, async=False):
"""Safely run a specific action as root.
See actions._run for more information.
"""
return _run(action, options, async, True, log_full_command)
return _run(action, options, async, True)
def _run(action, options=None, async=False, run_as_root=False,
log_full_command=True):
def _run(action, options=None, async=False, run_as_root=False):
"""Safely run a specific action as a normal user or root.
Actions are pulled from the actions directory.
- options are added to the action command.
- async: run asynchronously or wait for the command to complete.
- run_as_root: execute the command through sudo.
- log_full_command: print full command with options in the log.
"""
if options is None:
options = []
@ -161,10 +159,7 @@ def _run(action, options=None, async=False, run_as_root=False,
if run_as_root:
cmd = ['sudo', '-n'] + cmd
if log_full_command:
LOGGER.info('Executing command - %s', cmd)
else:
LOGGER.info('Executing command - %s (options not shown)', action)
LOGGER.info('Executing command - %s', cmd)
# Contract 3C: don't interpret shell escape sequences.
# Contract 5 (and 6-ish).
@ -178,12 +173,8 @@ def _run(action, options=None, async=False, run_as_root=False,
output, error = proc.communicate()
output, error = output.decode(), error.decode()
if proc.returncode != 0:
if log_full_command:
LOGGER.error('Error executing command - %s, %s, %s', cmd,
output, error)
else:
LOGGER.error('Error executing command - %s, %s, %s', action,
output, error)
LOGGER.error('Error executing command - %s, %s, %s', cmd, output,
error)
raise ActionError(action, output, error)
return output

View File

@ -68,8 +68,7 @@ than 63 characters in length.'),
try:
actions.superuser_run(
'create-ldap-user',
[user.get_username(), self.cleaned_data['password']],
log_full_command=False)
[user.get_username(), self.cleaned_data['password']])
except ActionError:
messages.error(self.request,
_('Creating LDAP user failed.'))

View File

@ -62,8 +62,7 @@ class CreateUserForm(UserCreationForm):
try:
actions.superuser_run(
'create-ldap-user',
[user.get_username(), self.cleaned_data['password1']],
log_full_command=False)
[user.get_username(), self.cleaned_data['password1']])
except ActionError:
messages.error(self.request,
_('Creating LDAP user failed.'))
@ -158,8 +157,7 @@ class UserChangePasswordForm(SetPasswordForm):
try:
actions.superuser_run(
'change-ldap-user-password',
[user.get_username(), self.cleaned_data['new_password1']],
log_full_command=False)
[user.get_username(), self.cleaned_data['new_password1']])
except ActionError:
messages.error(
self.request,