From d69ac67df902863b2ede284d10329b4e8cdee77e Mon Sep 17 00:00:00 2001 From: sjing Date: Tue, 24 Apr 2012 02:00:50 +0000 Subject: [PATCH] the fix for bug 3364300 - not display passwords in xcat commands or logs. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12317 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/mysqlsetup | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index 14ac419db..04b51dff3 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -973,8 +973,12 @@ sub setupmysqlroot { $cmd = "/usr/bin/mysqladmin -u root password $::rootpassword"; } - xCAT::Utils->runcmd($cmd, 0); + # secure passwd in verbose mode + my $tmpv = $::VERBOSE; + $::VERBOSE = 0; + xCAT::Utils->runcmd($cmd, 0); + $::VERBOSE = $tmpv; if ($::RUNCMD_RC != 0) { xCAT::MsgUtils->message( @@ -1549,14 +1553,18 @@ sub setupODBC my $entry = "[xCATDB]\nSERVER =$server\nDATABASE = xcatdb\nUSER = xcatadmin\nPASSWORD = $passwd"; $cmd = "echo \"$entry\" >> $rootodbcfile"; + # secure passwd in verbose mode + my $tmpv = $::VERBOSE; + $::VERBOSE = 0; xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - $message = "$cmd failed. Could not setup root ODBC file."; + $message = "command failed. Could not setup root ODBC file."; xCAT::MsgUtils->message("E", "$message"); exit(1); } + $::VERBOSE = $tmpv; } else { # entry already there @@ -1602,14 +1610,19 @@ sub createcfgloc my $mysqlentry = "mysql:dbname=xcatdb;host=$::MN|xcatadmin|$::adminpassword"; $cmd = "echo \"$mysqlentry\" > $cfglocmysql"; + + # secure passwd in verbose mode + my $tmpv = $::VERBOSE; + $::VERBOSE = 0; xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - $message = "$cmd failed. Could not setup cfgloc.mysql"; + $message = "command failed. Could not setup cfgloc.mysql"; xCAT::MsgUtils->message("E", "$message"); exit(1); } + $::VERBOSE = $tmpv; # allow readonly by root chmod 0600, $cfglocmysql;