From 789b4f29e2c1d0034d4c0409a91974ced828277f Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 3 Jun 2011 17:54:59 +0000 Subject: [PATCH] Have admin enter passwd twice, hide commands with passwords in them in verbose mode git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9740 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/db2sqlsetup | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/xCAT-client/bin/db2sqlsetup b/xCAT-client/bin/db2sqlsetup index 4ffdac8a0..fd6d53f72 100755 --- a/xCAT-client/bin/db2sqlsetup +++ b/xCAT-client/bin/db2sqlsetup @@ -288,11 +288,21 @@ if ((($odbconly == 0) && ($::xcatrunningdb2 == 0)) || (($::CLIENT) && ($odbconly else { #prompt for password - my $msg = "Input the password for xcatdb instance id: "; + my $msg = "Enter the password for xcatdb instance id: "; xCAT::MsgUtils->message('I', "$msg"); `stty -echo`; chop($::adminpassword = ); `stty echo`; + $msg = "Retype the password for xcatdb instance id: "; + xCAT::MsgUtils->message('I', "$msg"); + `stty -echo`; + chop(my $adminpwd2 = ); + `stty echo`; + if ($::adminpassword ne $adminpwd2) { # no match + $msg = "Sorry, passwords do not match. "; + xCAT::MsgUtils->message('I', "$msg"); + exit 1; + } } } @@ -677,6 +687,11 @@ sub mkdb2user } # set xcatdb id password + my $verboseflg=0; + if ($::VERBOSE) { # do not show commands with password + $verboseflg=1; + $::VERBOSE=undef; + } $cmd = qq~echo "xcatdb:$::adminpassword" | /bin/chpasswd -c~; xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) @@ -685,6 +700,9 @@ sub mkdb2user xCAT::MsgUtils->message("SE", " $cmd failed."); exit(1); } + if ($verboseflg == 1) { + $::VERBOSE=1; + } } else { # Linux @@ -738,6 +756,11 @@ sub mkdb2user } # set xcatdb id password + my $verboseflg=0; + if ($::VERBOSE) { # do not show commands with password + $verboseflg=1; + $::VERBOSE=undef; + } $cmd = qq~echo $::adminpassword | passwd xcatdb --stdin~; xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) @@ -746,6 +769,9 @@ sub mkdb2user xCAT::MsgUtils->message("SE", " $cmd failed."); exit(1); } + if ($verboseflg == 1) { + $::VERBOSE=1; + } } } @@ -1623,6 +1649,11 @@ sub createcfgloc xCAT::MsgUtils->message("E", " $cmd failed."); } } + my $verboseflg=0; + if ($::VERBOSE) { # do not show commands with password + $verboseflg=1; + $::VERBOSE=undef; + } my $db2entry = "DB2:xcatdb|xcatdb|$::adminpassword"; $cmd = "echo \"$db2entry\" > $cfgloc"; xCAT::Utils->runcmd($cmd, 0); @@ -1633,6 +1664,9 @@ sub createcfgloc exit(1); } + if ($verboseflg == 1) { + $::VERBOSE=1; + } # allow readonly by root chmod 0600, $cfgloc;