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
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).
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