Skip to content

Commit

Permalink
Revert "checksum extensions light (#17619)" (#19873)
Browse files Browse the repository at this point in the history
This reverts commit 4d79fe2.
  • Loading branch information
wilsonge authored Mar 8, 2018
1 parent 4d79fe2 commit 7f7d72d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 112 deletions.
23 changes: 0 additions & 23 deletions administrator/components/com_installer/models/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,29 +170,6 @@ public function install()
}
}

// Check the package
$children = $installer->manifest->updateservers->children();

foreach ($children as $child)
{
$check = JInstallerHelper::isChecksumValid($package['packagefile'], (string) $child);

switch ($check)
{
case 0:
$app->enqueueMessage(\JText::_('COM_INSTALLER_INSTALL_CHECKSUM_WRONG'), 'warning');
break;

case 1:
$app->enqueueMessage(\JText::_('COM_INSTALLER_INSTALL_CHECKSUM_CORRECT'), 'message');
break;

case 2:
$app->enqueueMessage(\JText::_('COM_INSTALLER_INSTALL_CHECKSUM_NOT_FOUND'), 'notice');
break;
}
}

// Was the package unpacked?
if (!$package || !$package['type'])
{
Expand Down
23 changes: 3 additions & 20 deletions administrator/components/com_installer/models/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function update($uids, $minimum_stability = JUpdater::STABILITY_STABLE)
$this->preparePreUpdate($update, $instance);

// Install sets state and enqueues messages
$res = $this->install($update, $instance->detailsurl);
$res = $this->install($update);

if ($res)
{
Expand All @@ -388,14 +388,13 @@ public function update($uids, $minimum_stability = JUpdater::STABILITY_STABLE)
/**
* Handles the actual update installation.
*
* @param JUpdate $update An update definition
* @param string $updateurl Update Server manifest
* @param JUpdate $update An update definition
*
* @return boolean Result of install
*
* @since 1.6
*/
private function install($update, $updateurl)
private function install($update)
{
$app = JFactory::getApplication();

Expand Down Expand Up @@ -449,22 +448,6 @@ private function install($update, $updateurl)
$installer = JInstaller::getInstance();
$update->set('type', $package['type']);

// Check the package
$check = JInstallerHelper::isChecksumValid($package['packagefile'], (string) $updateurl);

switch ($check)
{
case 0:
$app->enqueueMessage(\JText::_('COM_INSTALLER_INSTALL_CHECKSUM_WRONG'), 'warning');
break;
case 1:
$app->enqueueMessage(\JText::_('COM_INSTALLER_INSTALL_CHECKSUM_CORRECT'), 'message');
break;
case 2:
$app->enqueueMessage(\JText::_('COM_INSTALLER_INSTALL_CHECKSUM_NOT_FOUND'), 'notice');
break;
}

// Install the package
if (!$installer->update($package['dir']))
{
Expand Down
3 changes: 0 additions & 3 deletions administrator/language/en-GB/en-GB.com_installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ COM_INSTALLER_HEADING_UPDATESITE_NAME_ASC="Update Site ascending"
COM_INSTALLER_HEADING_UPDATESITE_NAME_DESC="Update Site descending"
COM_INSTALLER_HEADING_UPDATESITEID="ID"
COM_INSTALLER_INSTALL_BUTTON="Install"
COM_INSTALLER_INSTALL_CHECKSUM_CORRECT="File Checksum OK"
COM_INSTALLER_INSTALL_CHECKSUM_NOT_FOUND="There were no checksums provided in the package."
COM_INSTALLER_INSTALL_CHECKSUM_WRONG="File Checksum Failed"
COM_INSTALLER_INSTALL_DIRECTORY="Install Folder"
COM_INSTALLER_INSTALL_ERROR="Error installing %s"
COM_INSTALLER_INSTALL_FROM_DIRECTORY="Install from Folder"
Expand Down
66 changes: 0 additions & 66 deletions libraries/src/Installer/InstallerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,6 @@
*/
abstract class InstallerHelper
{
/**
* Hash not validated identifier.
*
* @var integer
* @since __DEPLOY_VERSION__
*/
const HASH_NOT_VALIDATED = 0;

/**
* Hash validated identifier.
*
* @var integer
* @since __DEPLOY_VERSION__
*/
const HASH_VALIDATED = 1;

/**
* Hash not provided identifier.
*
* @var integer
* @since __DEPLOY_VERSION__
*/
const HASH_NOT_PROVIDED = 2;

/**
* Downloads a package
*
Expand Down Expand Up @@ -357,46 +333,4 @@ public static function splitSql($query)

return $db->splitSql($query);
}

/**
* Return the result of the checksum of a package with the SHA256/SHA384/SHA512 tags in the update server manifest
*
* @param string $packagefile Location of the package to be installed
* @param Installer $updateServerManifest Update Server manifest
*
* @return integer one if the hashes match, zero if hashes doesn't match, two if hashes not found
*
* @since __DEPLOY_VERSION__
*/
public static function isChecksumValid($packagefile, $updateServerManifest)
{
$hashes = array("sha256", "sha384", "sha512");
$hashOnFile = false;

$update = new \JUpdate;
$update->loadFromXml($updateServerManifest);

foreach ($hashes as $hash)
{
if ($update->get($hash, false))
{
$hash_package = hash_file($hash, $packagefile);
$hash_remote = $update->$hash->_data;

$hashOnFile = true;

if ($hash_package !== $hash_remote)
{
return self::HASH_NOT_VALIDATED;
}
}
}

if ($hashOnFile)
{
return self::HASH_VALIDATED;
}

return self::HASH_NOT_PROVIDED;
}
}

0 comments on commit 7f7d72d

Please sign in to comment.