예제 #1
0
 protected function run1($stage)
 {
     $this->console->out(sprintf("Reencrypting %s database from %s/%s to %s/%s!", \Scalr::getContainer()->config->get('scalr.connections.mysql.name'), $this->source->getCryptoAlgo(), $this->source->getCipherMode(), $this->target->getCryptoAlgo(), $this->target->getCipherMode()));
     set_error_handler(function ($code, $message, $file, $line, $context) {
         \Scalr::errorHandler($code, $message, $file, $line, $context);
         if ($code == E_STRICT) {
             throw new Exception($message);
         }
     }, E_USER_ERROR | E_STRICT | E_RECOVERABLE_ERROR | E_ERROR);
     try {
         $this->db->Execute('START TRANSACTION;');
         $this->recrypt('ssh_keys', ['private_key', 'public_key']);
         $this->recrypt('services_ssl_certs', ['ssl_pkey', 'ssl_pkey_password']);
         $this->recrypt('account_user_settings', ['value'], "WHERE `name` = 'security.2fa.ggl.key'", ['user_id', 'name']);
         $this->recrypt('services_chef_servers', ['auth_key', 'v_auth_key']);
         $this->recrypt('variables', ['value'], '', ['name'], $this->globals);
         $this->recrypt('account_variables', ['value'], '', ['name', 'account_id'], $this->globals);
         $this->recrypt('client_environment_variables', ['value'], '', ['name', 'env_id'], $this->globals);
         $this->recrypt('role_variables', ['value'], '', ['name', 'role_id'], $this->globals);
         $this->recrypt('farm_variables', ['value'], '', ['name', 'farm_id'], $this->globals);
         $this->recrypt('farm_role_variables', ['value'], '', ['name', 'farm_role_id'], $this->globals);
         $this->recrypt('server_variables', ['value'], '', ['name', 'server_id'], $this->globals);
         $reflection = new ReflectionClass('Scalr_Environment');
         $method = $reflection->getMethod('getEncryptedVariables');
         $method->setAccessible(true);
         $this->recrypt('client_environment_properties', ['value'], "WHERE `name` IN ('" . implode("','", array_keys($method->invoke(null))) . "')");
         $this->db->Execute("COMMIT;");
     } catch (\Exception $e) {
         $this->rollback($e->getCode(), $e->getMessage());
         restore_error_handler();
         throw $e;
     }
     restore_error_handler();
 }