fix for xdsh -K for non-root userid in LDAP defect 3414742

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10678 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
lissav 2011-09-29 18:51:11 +00:00
parent 347b5878d2
commit fbeac6be1a

View File

@ -1653,7 +1653,12 @@ sub setupSSH
print FILE "#!/bin/sh
umask 0077
home=`egrep \"^$to_userid:\" /etc/passwd | cut -f6 -d :`
dest_dir=\"\$home/.ssh\"
if [ $home ]; then
dest_dir=\"\$home/.ssh\"
else
home=`su - root -c pwd`
dest_dir=\"\$home/.ssh\"
fi
mkdir -p \$dest_dir
cat /tmp/$to_userid/.ssh/authorized_keys >> \$home/.ssh/authorized_keys 2>&1
cp /tmp/$to_userid/.ssh/id_rsa \$home/.ssh/id_rsa 2>&1
@ -1935,6 +1940,11 @@ sub bldnonrootSSHFiles
xCAT::MsgUtils->message("I", $rsp, $::CALLBACK);
}
my $home = xCAT::Utils->getHomeDir($from_userid);
# Handle non-root userid may not be in /etc/passwd maybe LDAP
if (!$home) {
$home=`su - $from_userid -c pwd`;
chop $home;
}
my $roothome = xCAT::Utils->getHomeDir("root");
if (xCAT::Utils->isMN()) { # if on Management Node
if (!(-e "$home/.ssh/id_rsa.pub"))