From 1fdcfdb95987fc175c7621d424bb3ecba8f46385 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 30 Aug 2012 16:05:33 +0000 Subject: [PATCH] fix for defect 3562802 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13670 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/mysqlsetup | 30 +++++++++++++++++++++++++++++- xCAT-client/bin/pgsqlsetup | 16 +++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index afa5b666d..088d692c8 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -205,20 +205,41 @@ if ($odbconly == 0) { # not just updating the odbc if ($ENV{'XCATMYSQLADMIN_PW'}) # input env sets the password { + my $pw= $ENV{'XCATMYSQLADMIN_PW'}; + if ($pw =~ m/[^a-zA-Z0-9]/){ # if not alpha-numerid + my $warning = + " The password in the env variable XCATMYSQLADMIN_PW is not alpha-numeric."; + xCAT::MsgUtils->message("E", $warning); + exit 1; + } $::adminpassword = $ENV{'XCATMYSQLADMIN_PW'}; } else # prompt for password { - my $msg = "Input the password for xcatadmin in the MySQL database: "; + my $msg = "Input the alpha-numberic password for xcatadmin in the MySQL database: "; xCAT::MsgUtils->message('I', "$msg"); `stty -echo`; chop($::adminpassword = ); `stty echo`; + + if ($::adminpassword =~ m/[^a-zA-Z0-9]/){ # if not alpha-numerid + my $warning = + "The input password is not alpha-numeric. Rerun the command an input an alpha-numeric password."; + xCAT::MsgUtils->message("E", $warning); + exit 1; + } } if ($ENV{'XCATMYSQLROOT_PW'}) # input env sets the password { + my $pw= $ENV{'XCATMYSQLROOT_PW'}; + if ($pw =~ m/[^a-zA-Z0-9]/){ # if not alpha-numerid + my $warning = + " The password in the env variable XCATMYSQLROOT_PW is not alpha-numeric."; + xCAT::MsgUtils->message("E", $warning); + exit 1; + } $::rootpassword = $ENV{'XCATMYSQLROOT_PW'}; @@ -231,6 +252,13 @@ if ($odbconly == 0) `stty -echo`; chop($::rootpassword = ); `stty echo`; + + if ($::rootpassword =~ m/[^a-zA-Z0-9]/){ # if not alpha-numerid + my $warning = + "The input password is not alpha-numeric. Rerun the command an input an alpha-numeric password."; + xCAT::MsgUtils->message("E", $warning); + exit 1; + } } } diff --git a/xCAT-client/bin/pgsqlsetup b/xCAT-client/bin/pgsqlsetup index 18316ad8e..ec27b44ef 100755 --- a/xCAT-client/bin/pgsqlsetup +++ b/xCAT-client/bin/pgsqlsetup @@ -211,14 +211,28 @@ if (($odbconly == 0) && ($xcatrunningpgsql == 0)) { # not just updating the odbc and xcat not already running on pg if ($ENV{'XCATPGPW'}) # passwd supplied { + my $pw=$ENV{'XCATPGPW'}; + if ($pw =~ m/[^a-zA-Z0-9]/){ # if not alpha-numerid + my $warning = + "The password in the env variable XCATPGPW is not alpha-numeric."; + xCAT::MsgUtils->message("E", $warning); + exit 1; + } $::adminpassword = $ENV{'XCATPGPW'}; } else { - my $msg = "Input the password for xcatadm userid: "; + my $msg = "Input the password for xcatadm id: "; xCAT::MsgUtils->message('I', "$msg"); `stty -echo`; chop($::adminpassword = ); `stty echo`; + if ($::adminpassword =~ m/[^a-zA-Z0-9]/){ # if not alpha-numerid + my $warning = + "The input password is not alpha-numeric. Rerun the command an input an alpha-numeric password."; + xCAT::MsgUtils->message("E", $warning); + exit 1; + } + } }