CLOUDSTACK-10067: Fix a case where a user 'ro' or 'roo' exists on the system, or other variants. (#2252)

If one sets user=roo, this will return two directories and then it will fail.
This commit is contained in:
Lars Tobias Skjong-Børsting 2017-09-18 08:45:36 +02:00 committed by Rohit Yadav
parent 2bad9a6c11
commit a4036f7083
2 changed files with 3 additions and 3 deletions

View File

@ -84,7 +84,7 @@ else
exit 1 exit 1
fi fi
homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}') homedir=$(getent passwd $user|awk -F ":" '{print $6}')
sshdir=$homedir/.ssh sshdir=$homedir/.ssh
authorized=$sshdir/authorized_keys authorized=$sshdir/authorized_keys

View File

@ -49,7 +49,7 @@ if [ -z "$SSHKEY_SERVER_IP" ]; then
logger -t "cloud" "Unable to determine the password server, falling back to data-server" logger -t "cloud" "Unable to determine the password server, falling back to data-server"
SSHKEY_SERVER_IP=data-server SSHKEY_SERVER_IP=data-server
fi fi
logger -t "cloud" "Sending request to ssh key server at $SSHKEY_SERVER_IP" logger -t "cloud" "Sending request to ssh key server at $SSHKEY_SERVER_IP"
publickey=$(wget -q -t 3 -T 20 -O - http://$SSHKEY_SERVER_IP/latest/public-keys) publickey=$(wget -q -t 3 -T 20 -O - http://$SSHKEY_SERVER_IP/latest/public-keys)
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
@ -67,7 +67,7 @@ if [ -z "$publickey" ]; then
exit 1 exit 1
fi fi
homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}') homedir=$(getent passwd $user|awk -F ":" '{print $6}')
sshdir=$homedir/.ssh sshdir=$homedir/.ssh
authorized=$sshdir/authorized_keys authorized=$sshdir/authorized_keys