Skip to content

Commit a4036f7

Browse files
larstobiyadvr
authored andcommitted
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.
1 parent 2bad9a6 commit a4036f7

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

setup/bindir/cloud-set-guest-sshkey-configdrive.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ else
8484
exit 1
8585
fi
8686

87-
homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}')
87+
homedir=$(getent passwd $user|awk -F ":" '{print $6}')
8888
sshdir=$homedir/.ssh
8989
authorized=$sshdir/authorized_keys
9090

setup/bindir/cloud-set-guest-sshkey.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if [ -z "$SSHKEY_SERVER_IP" ]; then
4949
logger -t "cloud" "Unable to determine the password server, falling back to data-server"
5050
SSHKEY_SERVER_IP=data-server
5151
fi
52-
52+
5353
logger -t "cloud" "Sending request to ssh key server at $SSHKEY_SERVER_IP"
5454
publickey=$(wget -q -t 3 -T 20 -O - http://$SSHKEY_SERVER_IP/latest/public-keys)
5555
if [ $? -eq 0 ]; then
@@ -67,7 +67,7 @@ if [ -z "$publickey" ]; then
6767
exit 1
6868
fi
6969

70-
homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}')
70+
homedir=$(getent passwd $user|awk -F ":" '{print $6}')
7171
sshdir=$homedir/.ssh
7272
authorized=$sshdir/authorized_keys
7373

0 commit comments

Comments
 (0)