From a62d19018b4a908ca1b888c42f23da61ecea1c28 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 23 Apr 2010 12:27:07 +0200 Subject: [PATCH] qa: Use qa_utils.UploadFile to upload rapi_users file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just using βechoβ would use whatever umask is set in the shell, in addition to potentially showing the password in the process list. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- qa/qa_cluster.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py index 489800b56..371fea325 100644 --- a/qa/qa_cluster.py +++ b/qa/qa_cluster.py @@ -61,12 +61,24 @@ def TestClusterInit(rapi_user, rapi_secret): master = qa_config.GetMasterNode() # First create the RAPI credentials - cred_string = "%s %s write" % (rapi_user, rapi_secret) - cmd = ("echo %s > %s" % - (utils.ShellQuote(cred_string), - utils.ShellQuote(constants.RAPI_USERS_FILE))) - AssertEqual(StartSSH(master['primary'], cmd).wait(), 0) + fh = tempfile.NamedTemporaryFile() + try: + fh.write("%s %s write\n" % (rapi_user, rapi_secret)) + fh.flush() + + tmpru = qa_utils.UploadFile(master["primary"], fh.name) + try: + cmd = ["mv", tmpru, constants.RAPI_USERS_FILE] + AssertEqual(StartSSH(master["primary"], + utils.ShellQuoteArgs(cmd)).wait(), 0) + finally: + cmd = ["rm", "-f", tmpru] + AssertEqual(StartSSH(master["primary"], + utils.ShellQuoteArgs(cmd)).wait(), 0) + finally: + fh.close() + # Initialize cluster cmd = ['gnt-cluster', 'init'] if master.get('secondary', None): -- GitLab