Updated Branches:
  refs/heads/master 6540ff8fa -> f2e0fa230

CLOUDSTACK-199: Fix how cloud-setup-databases parses user:password@host

Patch splits by right most @ in supplied argument to get user:password
and host substrings.

Signed-off-by: Rohit Yadav <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/f2e0fa23
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/f2e0fa23
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/f2e0fa23

Branch: refs/heads/master
Commit: f2e0fa230d16cbab85d0de9f13d63d55ac9e1cb1
Parents: 6540ff8
Author: Rohit Yadav <[email protected]>
Authored: Wed Sep 26 11:14:33 2012 +0530
Committer: Prasanna Santhanam <[email protected]>
Committed: Wed Sep 26 15:40:21 2012 +0530

----------------------------------------------------------------------
 setup/bindir/cloud-setup-databases.in |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f2e0fa23/setup/bindir/cloud-setup-databases.in
----------------------------------------------------------------------
diff --git a/setup/bindir/cloud-setup-databases.in 
b/setup/bindir/cloud-setup-databases.in
index 54c411d..a17b131 100755
--- a/setup/bindir/cloud-setup-databases.in
+++ b/setup/bindir/cloud-setup-databases.in
@@ -475,8 +475,15 @@ for example:
                 self.errorAndExit("There are more than one parameters for 
user:password@hostname (%s)"%self.args)
             
             arg = self.args[0]
-            stuff = arg.split("@", 1)
-            if len(stuff) == 1: stuff.append("localhost")
+            try:
+                splitIndex = arg.rindex('@')
+            except ValueError:
+                # If it failed to find @, use host=localhost
+                splitIndex = len(arg)
+                arg += "@localhost"
+            finally:
+                stuff = [arg[:splitIndex], arg[splitIndex+1:]]
+
             self.user,self.password = parseUserAndPassword(stuff[0])
             self.host,self.port = parseHostInfo(stuff[1])
             

Reply via email to