From f2e0fa230d16cbab85d0de9f13d63d55ac9e1cb1 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 26 Sep 2012 11:14:33 +0530 Subject: [PATCH] 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 --- setup/bindir/cloud-setup-databases.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index 54c411d7f7b..a17b1312407 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])