From 86580c912166688fec11a86419f0f5de0ad2f852 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sun, 19 Jul 2015 21:27:09 -0400 Subject: [PATCH] Revert "Don't print LDAP user passwords in log." This reverts commit b1c9c81d58c80d6b313dd2b8a5c5727ecdf6ac49. Conflicts: plinth/modules/first_boot/forms.py --- plinth/actions.py | 25 ++++++++----------------- plinth/modules/first_boot/forms.py | 3 +-- plinth/modules/users/forms.py | 6 ++---- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/plinth/actions.py b/plinth/actions.py index fbb6f273c..eae7a7944 100644 --- a/plinth/actions.py +++ b/plinth/actions.py @@ -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 diff --git a/plinth/modules/first_boot/forms.py b/plinth/modules/first_boot/forms.py index 28eea95c9..8261f2c96 100644 --- a/plinth/modules/first_boot/forms.py +++ b/plinth/modules/first_boot/forms.py @@ -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.')) diff --git a/plinth/modules/users/forms.py b/plinth/modules/users/forms.py index 97bde2e25..07de9a26c 100644 --- a/plinth/modules/users/forms.py +++ b/plinth/modules/users/forms.py @@ -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,