From: Tristan Cacqueray Date: Fri, 3 Oct 2014 19:57:01 +0000 (+0000) Subject: Sync latest processutils from oslo-incubator X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5e4e1f7ea71f9b4c7bd15809c58bc7a1838ed567;p=openstack-build%2Fcinder-build.git Sync latest processutils from oslo-incubator An earlier commit (Ia92aab76fa83d01c5fbf6f9d31df2463fc26ba5c) failed to address ssh_execute(). This change set addresses ssh_execute. ------------------------------------------------ oslo-incubator head: commit 4990535fb5f3e2dc9b397e1a18c1b5dda94ef1c4 Merge: 9f5c700 2a130bf Author: Jenkins Date: Mon Sep 29 23:12:14 2014 +0000 Merge "Script to list unreleased changes in all oslo projects" ----------------------------------------------- The sync pulls in the following changes (newest to oldest): 6a60f842 - Mask passwords in exceptions and error messages (SSH) ----------------------------------------------- Change-Id: Ie0caf32469126dd9feb44867adf27acb6e383958 Closes-Bug: #1377981 --- diff --git a/cinder/openstack/common/processutils.py b/cinder/openstack/common/processutils.py index a1c68822e..a4dc6718b 100644 --- a/cinder/openstack/common/processutils.py +++ b/cinder/openstack/common/processutils.py @@ -242,7 +242,8 @@ def trycmd(*args, **kwargs): def ssh_execute(ssh, cmd, process_input=None, addl_env=None, check_exit_code=True): - LOG.debug('Running cmd (SSH): %s', cmd) + sanitized_cmd = strutils.mask_password(cmd) + LOG.debug('Running cmd (SSH): %s', sanitized_cmd) if addl_env: raise InvalidArgumentError(_('Environment not supported over SSH')) @@ -256,7 +257,10 @@ def ssh_execute(ssh, cmd, process_input=None, # NOTE(justinsb): This seems suspicious... # ...other SSH clients have buffering issues with this approach stdout = stdout_stream.read() + sanitized_stdout = strutils.mask_password(stdout) stderr = stderr_stream.read() + sanitized_stderr = strutils.mask_password(stderr) + stdin_stream.close() exit_status = channel.recv_exit_status() @@ -266,11 +270,11 @@ def ssh_execute(ssh, cmd, process_input=None, LOG.debug('Result was %s' % exit_status) if check_exit_code and exit_status != 0: raise ProcessExecutionError(exit_code=exit_status, - stdout=stdout, - stderr=stderr, - cmd=cmd) + stdout=sanitized_stdout, + stderr=sanitized_stderr, + cmd=sanitized_cmd) - return (stdout, stderr) + return (sanitized_stdout, sanitized_stderr) def get_worker_count():