diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-02-17 07:03:40 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-02-17 07:03:40 +0000 |
commit | 82ccbba12401cefd9398f70fb2ad763025fa3919 (patch) | |
tree | f8a5aced7474c90ea4e74f2b07b873ffad493f47 | |
parent | ae06ad3a414c9d112e5aae92118ad9d134c00056 (diff) |
Move private key generation into the installer so that we're not
generating it lazily.
-rw-r--r-- | core/helpers/access.php | 6 | ||||
-rw-r--r-- | installer/cli.php | 2 | ||||
-rw-r--r-- | installer/installer.php | 8 | ||||
-rw-r--r-- | installer/web.php | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/core/helpers/access.php b/core/helpers/access.php index 9bf9da6c..6540e3b8 100644 --- a/core/helpers/access.php +++ b/core/helpers/access.php @@ -590,10 +590,6 @@ class access_Core { } static function private_key() { - if (!($key = module::get_var('core', 'private_key'))) { - $key = md5(uniqid(mt_rand(), true)) . md5(uniqid(mt_rand(), true)); - module::set_var('core', 'private_key', $key); - } - return $key; + return module::get_var("core", "private_key"); } } diff --git a/installer/cli.php b/installer/cli.php index fb497635..ee2d6880 100644 --- a/installer/cli.php +++ b/installer/cli.php @@ -53,6 +53,8 @@ if (!installer::connect($config)) { print " username: $user\n"; print " password: $password\n"; print "\n"; + + installer::create_private_key(); exit(0); } catch (Exception $e) { oops($e->getMessage()); diff --git a/installer/installer.php b/installer/installer.php index 62523308..32511541 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -94,4 +94,12 @@ class installer { return array("admin", $password); } + + static function create_private_key() { + $key = md5(uniqid(mt_rand(), true)) . md5(uniqid(mt_rand(), true)); + if (mysql_query("INSERT INTO `vars` VALUES(NULL, 'core', 'private_key', '$key')")) { + } else { + throw new Exception(mysql_error()); + } + } }
\ No newline at end of file diff --git a/installer/web.php b/installer/web.php index cfae7a33..47d60a34 100644 --- a/installer/web.php +++ b/installer/web.php @@ -55,6 +55,8 @@ if (installer::already_installed()) { try { list ($user, $password) = installer::create_admin($config); $content = render("success.html.php", array("user" => $user, "password" => $password)); + + installer::create_private_key(); } catch (Exception $e) { $content = oops($e->getMessage()); } |