]> scripts.mit.edu Git - wizard.git/commitdiff
Fix inability to access SQL password on n-b.
authorEdward Z. Yang <ezyang@mit.edu>
Sat, 3 Oct 2009 19:56:35 +0000 (15:56 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Sat, 3 Oct 2009 19:56:35 +0000 (15:56 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/mediawiki.py
wizard/scripts.py

index 6b39c8fd54d5721888c2a51ef13dde55a1fefc4b..dab8ba4681f408b3ac18cf8d1bcf3c347d1fc97b 100644 (file)
@@ -129,7 +129,7 @@ def get_mysql_args(d):
     vars = d.extract()
     if 'WIZARD_DBNAME' not in vars:
         raise app.BackupFailure("Could not determine database name")
-    triplet = scripts.get_sql_credentials()
+    triplet = scripts.get_sql_credentials(vars)
     args = []
     if triplet is not None:
         server, user, password = triplet
index 35b9ba942db0905aa5ab8e37ac03b9188cde4c97..8122c78ec5e3c9e5ce728de741b5eead0ce5dd73 100644 (file)
@@ -1,8 +1,9 @@
 import os
+import shlex
 
-from wizard import shell
+from wizard import shell, util
 
-def get_sql_credentials():
+def get_sql_credentials(vars=None):
     """
     Attempts to determine a user's MySQL credentials.  They are
     returned as a three-tuple (host, user, password).
@@ -13,8 +14,14 @@ def get_sql_credentials():
     password = os.getenv("WIZARD_MYSQL_PASSWORD")
     if host is not None and user is not None and password is not None:
         return (host, user, password)
+    # XXX: this is very fragile
+    elif vars and "WIZARD_DBSERVER" in vars and "WIZARD_DBUSER" in vars and "WIZARD_DBPASSWORD" in vars:
+        return (shlex.split(vars[x])[0] for x in ("WIZARD_DBSERVER", "WIZARD_DBUSER", "WIZARD_DBPASSWORD"))
     try:
-        return sh.eval("/mit/scripts/sql/bin/get-password").split()
+        tuple = sh.eval("/mit/scripts/sql/bin/get-password").split()
+        if len(tuple) == 3:
+            return tuple
+        return None
     except CallError:
         return None