-Change getHomeDir to tolerate more situations, not spawn a subprocess, and get current user home directory if no user specified.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3044 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2009-03-30 14:13:09 +00:00
parent 391b97d194
commit 56debd0d4b

View File

@ -1062,9 +1062,13 @@ sub runxcmd_output
sub getHomeDir
{
my ($class, $username) = @_;
my @user = split ':', (`/bin/grep ^$username /etc/passwd 2>&1`);
my $home = $user[5];
return $home;
my @user;
if ($username) {
@user = getpwnam($username);
} else {
@user = getpwuid($>);
}
return $user[7];
}
#--------------------------------------------------------------------------------