the item that default password for various configuration in passwd table.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11280 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
80e9d027ca
commit
afee4b8d4e
@ -769,26 +769,31 @@ sub credentials {
|
||||
###########################################
|
||||
# Check passwd tab
|
||||
###########################################
|
||||
my $tab = xCAT::Table->new( 'passwd' );
|
||||
if ( $tab ) {
|
||||
my $ent;
|
||||
if ( $user_specified)
|
||||
{
|
||||
($ent) = $tab->getAttribs( {key=>$hwtype,username=>$user},qw(password));
|
||||
}
|
||||
else
|
||||
{
|
||||
($ent) = $tab->getAttribs( {key=>$hwtype}, qw(username password));
|
||||
}
|
||||
if ( $ent ) {
|
||||
if (defined($ent->{password})) { $pass = $ent->{password}; }
|
||||
if (defined($ent->{username})) { $user = $ent->{username}; }
|
||||
}
|
||||
#my $tab = xCAT::Table->new( 'passwd' );
|
||||
#if ( $tab ) {
|
||||
#my $ent;
|
||||
# if ( $user_specified)
|
||||
# {
|
||||
# ($ent) = $tab->getAttribs( {key=>$hwtype,username=>$user},qw(password));
|
||||
# }
|
||||
# else
|
||||
# {
|
||||
# ($ent) = $tab->getAttribs( {key=>$hwtype}, qw(username password));
|
||||
# }
|
||||
# if ( $ent ) {
|
||||
# if (defined($ent->{password})) { $pass = $ent->{password}; }
|
||||
# if (defined($ent->{username})) { $user = $ent->{username}; }
|
||||
# }
|
||||
#}
|
||||
my ($ent) = get_usr_passwd($hwtype, $user);
|
||||
if ($ent) {
|
||||
if (defined($ent->{password})) { $pass = $ent->{password};}
|
||||
if (defined($ent->{username})) { $user = $ent->{username};}
|
||||
}
|
||||
##########################################
|
||||
# Check table based on specific node
|
||||
##########################################
|
||||
$tab = xCAT::Table->new( $hcptab{$hwtype} );
|
||||
my $tab = xCAT::Table->new( $hcptab{$hwtype} );
|
||||
if ( $tab ) {
|
||||
my $ent;
|
||||
if ( $user_specified)
|
||||
@ -825,6 +830,60 @@ sub credentials {
|
||||
return( $user,$pass );
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Get password for user in 'passwd' table, if doesn't exist, use default
|
||||
# password for this user.
|
||||
##########################################################################
|
||||
my %power_accounts = (
|
||||
HMC => 'abc123',
|
||||
general => 'general',
|
||||
admin => 'admin',
|
||||
);
|
||||
my %default_passwd_accounts = (
|
||||
system => { root => 'cluster',},
|
||||
hmc => { hscroot => 'abc123',},
|
||||
fsp => \%power_accounts,
|
||||
bpa => \%power_accounts,
|
||||
frame => \%power_accounts,
|
||||
cec => \%power_accounts,
|
||||
blade => { USERID => 'PASSW0RD',},
|
||||
ipmi => { USERID => 'PASSW0RD',},
|
||||
ivm => { padmin => 'padmin',},
|
||||
vmware => { root => '',},
|
||||
vcenter => { Administrator => ''},
|
||||
);
|
||||
|
||||
sub get_usr_passwd {
|
||||
my $key = shift;
|
||||
if ($key && ($key =~ /xCAT::/)) {
|
||||
$key = shift;
|
||||
}
|
||||
my $user = shift;
|
||||
my $ent;
|
||||
my $passwdtab = xCAT::Table->new('passwd');
|
||||
if (!$passwdtab) {
|
||||
return undef;
|
||||
}
|
||||
if ($user) {
|
||||
($ent) = $passwdtab->getAttribs({key => $key, username => $user}, qw(password cryptmethod));
|
||||
} else {
|
||||
($ent) = $passwdtab->getNodeAttribs($key, qw(username password));
|
||||
}
|
||||
if (!$ent or !$ent->{password}) {
|
||||
my $hash = $default_passwd_accounts{$key};
|
||||
if (!$hash or ($user and !defined($hash->{$user}))) {
|
||||
return undef;
|
||||
}
|
||||
if (!$user) {
|
||||
my @tmp_keys = keys (%$hash);
|
||||
$user = $tmp_keys[0];
|
||||
}
|
||||
$ent->{username} = $user;
|
||||
$ent->{password} = $hash->{$user};
|
||||
}
|
||||
return $ent;
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Set userids and passwords to tables
|
||||
##########################################################################
|
||||
|
@ -308,19 +308,22 @@ sub makescript
|
||||
#$os =~ tr/A-Z/a-z/; # Convert to lowercase
|
||||
if ($os eq "aix" || $os eq "AIX")
|
||||
{
|
||||
my $passwdtab = xCAT::Table->new('passwd');
|
||||
unless ($passwdtab)
|
||||
{
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Unable to open passwd table.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
}
|
||||
# my $passwdtab = xCAT::Table->new('passwd');
|
||||
# unless ($passwdtab)
|
||||
# {
|
||||
# my $rsp;
|
||||
# push @{$rsp->{data}}, "Unable to open passwd table.";
|
||||
# xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
# }
|
||||
|
||||
if ($passwdtab)
|
||||
# if ($passwdtab)
|
||||
# {
|
||||
# my $et =
|
||||
# $passwdtab->getAttribs({key => 'system', username => 'root'},
|
||||
# 'password', 'cryptmethod');
|
||||
{
|
||||
my $et =
|
||||
$passwdtab->getAttribs({key => 'system', username => 'root'},
|
||||
'password', 'cryptmethod');
|
||||
use xCAT::PPCdb qw(get_usr_passwd);
|
||||
my $et = xCAT::PPCdb::get_usr_passwd('system', 'root');
|
||||
if ($et and defined($et->{'password'}))
|
||||
{
|
||||
push @scriptd, "ROOTPW=" . $et->{'password'} . "\n";
|
||||
|
@ -3531,7 +3531,7 @@ sub mknimimage
|
||||
#
|
||||
# Set root password in diskless images
|
||||
#
|
||||
my $rootpw;
|
||||
my $rootpw = 'cluster';
|
||||
my $method;
|
||||
if (($::NIMTYPE eq "diskless") || ($::NIMTYPE eq "dataless"))
|
||||
{
|
||||
|
@ -292,27 +292,28 @@ sub process_request {
|
||||
copybootscript($installroot, $rootimg_dir, $osver, $arch, $profile, $callback);
|
||||
my $passtab = xCAT::Table->new('passwd');
|
||||
if ($passtab) {
|
||||
(my $pent) = $passtab->getAttribs({key=>'system',username=>'root'},'password');
|
||||
if ($pent and defined ($pent->{password})) {
|
||||
my $pass = $pent->{password};
|
||||
my $oldmask=umask(0077);
|
||||
my $shadow;
|
||||
open($shadow,"<","$rootimg_dir/etc/shadow");
|
||||
my @shadents = <$shadow>;
|
||||
close($shadow);
|
||||
open($shadow,">","$rootimg_dir/etc/shadow");
|
||||
unless ($pass =~ /^\$1\$/) {
|
||||
$pass = crypt($pass,'$1$'.genpassword(8));
|
||||
}
|
||||
print $shadow "root:$pass:13880:0:99999:7:::\n";
|
||||
foreach (@shadents) {
|
||||
unless (/^root:/) {
|
||||
print $shadow "$_";
|
||||
}
|
||||
}
|
||||
close($shadow);
|
||||
umask($oldmask);
|
||||
}
|
||||
my $pass = 'cluster';
|
||||
(my $pent) = $passtab->getAttribs({key=>'system',username=>'root'},'password');
|
||||
if ($pent and defined ($pent->{password})) {
|
||||
$pass = $pent->{password};
|
||||
}
|
||||
my $oldmask=umask(0077);
|
||||
my $shadow;
|
||||
open($shadow,"<","$rootimg_dir/etc/shadow");
|
||||
my @shadents = <$shadow>;
|
||||
close($shadow);
|
||||
open($shadow,">","$rootimg_dir/etc/shadow");
|
||||
unless ($pass =~ /^\$1\$/) {
|
||||
$pass = crypt($pass,'$1$'.genpassword(8));
|
||||
}
|
||||
print $shadow "root:$pass:13880:0:99999:7:::\n";
|
||||
foreach (@shadents) {
|
||||
unless (/^root:/) {
|
||||
print $shadow "$_";
|
||||
}
|
||||
}
|
||||
close($shadow);
|
||||
umask($oldmask);
|
||||
}
|
||||
|
||||
# sync fils configured in the synclist to the rootimage
|
||||
|
@ -163,9 +163,11 @@ sub process_request {
|
||||
#get the root password for the node
|
||||
my $passtab = xCAT::Table->new('passwd');
|
||||
if ($passtab) {
|
||||
my $pass = 'cluster';
|
||||
(my $pent) = $passtab->getAttribs({key=>'system',username=>'root'},'password');
|
||||
if ($pent and defined ($pent->{password})) {
|
||||
my $pass = $pent->{password};
|
||||
$pass = $pent->{password};
|
||||
}
|
||||
my $oldmask=umask(0077);
|
||||
my $shadow;
|
||||
open($shadow,"<","$rootimg_dir/etc/shadow");
|
||||
@ -183,7 +185,6 @@ sub process_request {
|
||||
}
|
||||
close($shadow);
|
||||
umask($oldmask);
|
||||
}
|
||||
}
|
||||
|
||||
# sync fils configured in the synclist to the rootimage
|
||||
|
Loading…
Reference in New Issue
Block a user