From fbeac6be1a9d68cc9dd19793003084b0f4e70151 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 29 Sep 2011 18:51:11 +0000 Subject: [PATCH] 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 --- perl-xCAT/xCAT/Utils.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 32f69eb8f..1c59d3629 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -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"))