You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2017/09/18 06:45:40 UTC

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

This is an automated email from the ASF dual-hosted git repository.

bhaisaab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new a4036f7  CLOUDSTACK-10067: Fix a case where a user 'ro' or 'roo' exists on the system, or other variants. (#2252)
a4036f7 is described below

commit a4036f708300077d1408ba9b6b930b79b06247c3
Author: Lars Tobias Skjong-Børsting <la...@relatime.no>
AuthorDate: Mon Sep 18 08:45:36 2017 +0200

    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.
---
 setup/bindir/cloud-set-guest-sshkey-configdrive.in | 2 +-
 setup/bindir/cloud-set-guest-sshkey.in             | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/setup/bindir/cloud-set-guest-sshkey-configdrive.in b/setup/bindir/cloud-set-guest-sshkey-configdrive.in
index df10b43..e8466e8 100644
--- a/setup/bindir/cloud-set-guest-sshkey-configdrive.in
+++ b/setup/bindir/cloud-set-guest-sshkey-configdrive.in
@@ -84,7 +84,7 @@ else
     exit 1
 fi
 
-homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}')
+homedir=$(getent passwd $user|awk -F ":" '{print $6}')
 sshdir=$homedir/.ssh
 authorized=$sshdir/authorized_keys
 
diff --git a/setup/bindir/cloud-set-guest-sshkey.in b/setup/bindir/cloud-set-guest-sshkey.in
index 80e4064..321c8dd 100755
--- a/setup/bindir/cloud-set-guest-sshkey.in
+++ b/setup/bindir/cloud-set-guest-sshkey.in
@@ -49,7 +49,7 @@ if [ -z "$SSHKEY_SERVER_IP" ]; then
      logger -t "cloud" "Unable to determine the password server, falling back to data-server"
      SSHKEY_SERVER_IP=data-server
 fi
- 
+
 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)
 if [ $? -eq 0 ]; then
@@ -67,7 +67,7 @@ if [ -z "$publickey" ]; then
     exit 1
 fi
 
-homedir=$(grep ^$user /etc/passwd|awk -F ":" '{print $6}')
+homedir=$(getent passwd $user|awk -F ":" '{print $6}')
 sshdir=$homedir/.ssh
 authorized=$sshdir/authorized_keys
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>'].