]> scripts.mit.edu Git - wizard.git/commitdiff
Fix migration security check bug, and add random keys support.
authorEdward Z. Yang <ezyang@mit.edu>
Wed, 16 Dec 2009 18:49:09 +0000 (13:49 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Wed, 16 Dec 2009 18:49:09 +0000 (13:49 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
wizard/app/__init__.py
wizard/app/wordpress.py
wizard/command/mass_migrate.py

index 597dbc0c9465d2181073cd9480b70a760c08ab4f..8f3dd81db54f46d49f275246f3191283d007d47b 100644 (file)
@@ -28,6 +28,8 @@ import shlex
 import logging
 import shutil
 import sqlalchemy
+import random
+import string
 
 import wizard
 from wizard import resolve, scripts, shell, util
@@ -67,7 +69,9 @@ class Application(object):
     parametrized_files = []
     #: Keys that are used in older versions of the application, but
     #: not for the most recent version.
-    deprecated_keys = []
+    deprecated_keys = set()
+    #: Keys that we can simply generate random strings for if they're missing
+    random_keys = set()
     #: Dictionary of variable names to extractor functions.  These functions
     #: take a :class:`wizard.deploy.Deployment` as an argument and return the value of
     #: the variable, or ``None`` if it could not be found.
@@ -124,6 +128,10 @@ class Application(object):
         result = {}
         for k,extractor in self.extractors.items():
             result[k] = extractor(deployment)
+        # XXX: ugh... we have to do quoting
+        for k in self.random_keys:
+            if result[k] is None:
+                result[k] = "'%s'" % ''.join(random.choice(string.letters + string.digits) for i in xrange(30))
         return result
     def dsn(self, deployment):
         """
index 883f5de2177fa4301508e5ee0a07ddeadde8d61f..d98add18b2c4c0e09fb8be8053f0034929ceb3cc 100644 (file)
@@ -32,6 +32,7 @@ class Application(app.Application):
     substitutions.update(php.substitutions)
     install_schema = install.ArgSchema("db", "email", "title")
     deprecated_keys = set(['WIZARD_SECRETKEY'])
+    random_keys = set(['WIZARD_SECRETKEY', 'WIZARD_AUTH_KEY', 'WIZARD_SECURE_AUTH_KEY', 'WIZARD_LOGGED_IN_KEY', 'WIZARD_NONCE_KEY'])
     def download(self, version):
         return "http://wordpress.org/wordpress-%s.tar.gz" % version
     def checkConfig(self, deployment):
index 036bed4f39526048fe2f37c3a8473b3fa1e944aa..fbaaa60217fd0b763fc1fe2a2cce6ddf6b9df05c 100644 (file)
@@ -23,7 +23,7 @@ def main(argv, baton):
         # check if we want to punt due to --limit
         if d.location in seen:
             continue
-        if is_root and not command.security_check_homedir(d):
+        if is_root and not command.security_check_homedir(d.location):
             continue
         logging.info("Processing %s" % d.location)
         child_args = list(base_args)