#At file:///C:/Users/Reggie/work/wex/installer-updated/ based on revid:iggy@stripped
262 Reggie Burnett 2011-01-24
the updater tool now reads the manifest to do it's work. It also now checks the downloaded file's hash against the manifest
modified:
Setup_Net/products.xml
WexInstaller/Program.cs
WexInstallerUpdater/MainForm.cs
WexInstallerUpdater/WexInstallerUpdater.csproj
installer-vs2010.sln
=== modified file 'Setup_Net/products.xml'
=== modified file 'Setup_Net/products.xml'
--- a/Setup_Net/products.xml 2011-01-24 15:28:26 +0000
+++ b/Setup_Net/products.xml 2011-01-24 20:58:09 +0000
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ProductManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" format="1">
+ <UpdateURL>file://C:\Users\Reggie\work\wex\installer-updated\Setup_Net\Output\mysql-universal-installer-1.0.5.exe</UpdateURL>
+ <UpdateVersion>1.0.7</UpdateVersion>
+ <UpdateHash>CB69C60143875DA4A6CDCA6E6C9FDC60BFC9853C</UpdateHash>
<ProductCatalogs>
+ <ProductCatalogs>
<ProductCatalog id="mysql-5.5-gpl" name="MySQL 5.5" description="MySQL 5.5 Community Edition" commercial="false">
<SetupTypes>
<SetupType flag="1" name="Developer Default" description="Installs all products needed for MySQL development, including" />
=== modified file 'WexInstaller/Program.cs'
--- a/WexInstaller/Program.cs 2011-01-24 17:24:16 +0000
+++ b/WexInstaller/Program.cs 2011-01-24 20:58:09 +0000
@@ -57,7 +57,6 @@
}
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = updateTool;
- psi.Arguments = ProductManager.Manifest.UpdateUrl;
Process.Start(psi);
return true;
}
=== modified file 'WexInstallerUpdater/MainForm.cs'
--- a/WexInstallerUpdater/MainForm.cs 2011-01-24 18:24:06 +0000
+++ b/WexInstallerUpdater/MainForm.cs 2011-01-24 20:58:09 +0000
@@ -10,6 +10,9 @@
using System.IO;
using System.Diagnostics;
using System.Threading;
+using System.Xml.Serialization;
+using WexInstaller.Core;
+using System.Security.Cryptography;
namespace WexInstallerUpdater
{
@@ -19,26 +22,59 @@
private WebClient client;
private int counter;
private bool processingTimer;
+ private ProductManifest manifest;
public MainForm()
{
InitializeComponent();
+ LoadManifest();
StartDownload();
}
+ private void LoadManifest()
+ {
+ string fileName = String.Format("{0}\\MySQL\\MySQL Universal Installer\\products.xml",
+ Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
+
+ if (!File.Exists(fileName))
+ {
+ MessageBox.Show("Unable to locate MySQL Universal Installer product cache");
+ Close();
+ }
+
+ try
+ {
+ XmlRootAttribute productManifest = new XmlRootAttribute("ProductManifest");
+ XmlSerializer s = new XmlSerializer(typeof(ProductManifest));
+ TextReader w = new StreamReader(fileName);
+ manifest = (ProductManifest)s.Deserialize(w);
+ w.Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("There was an error loading the MySQL Universal Installer product cache");
+ Close();
+ }
+ }
+
private void StartDownload()
{
- string[] args = Environment.GetCommandLineArgs();
- string url = args[1];
client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
tempFile = Path.GetTempFileName().Replace(".tmp", ".exe");
- client.DownloadFileAsync(new Uri(url), tempFile);
+ client.DownloadFileAsync(new Uri(manifest.UpdateUrl), tempFile);
}
private void Install()
{
+ if (!VerifyHash())
+ {
+ MessageBox.Show("Update download failed security check");
+ Close();
+ return;
+ }
+
label1.Text = "Installing...";
downloadProgress.Value = 0;
ProcessStartInfo psi = new ProcessStartInfo();
@@ -47,6 +83,32 @@
Close();
}
+ private bool VerifyHash()
+ {
+ string hash = GetSHAHash(tempFile);
+ return String.Compare(hash, manifest.UpdateHash, false) == 0;
+ }
+
+ public static string GetSHAHash(string pathName)
+ {
+ SHA1CryptoServiceProvider hasher = new SHA1CryptoServiceProvider();
+
+ try
+ {
+ Stream stream = new FileStream(pathName, FileMode.Open);
+ byte[] hash = hasher.ComputeHash(stream);
+ stream.Close();
+
+ string stringHash = BitConverter.ToString(hash);
+ stringHash = stringHash.Replace("-", "");
+ return stringHash;
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Cancelled)
=== modified file 'WexInstallerUpdater/WexInstallerUpdater.csproj'
--- a/WexInstallerUpdater/WexInstallerUpdater.csproj 2011-01-24 16:20:32 +0000
+++ b/WexInstallerUpdater/WexInstallerUpdater.csproj 2011-01-24 20:58:09 +0000
@@ -52,6 +52,7 @@
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
+ <Compile Include="ProductManifest.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
=== modified file 'installer-vs2010.sln'
--- a/installer-vs2010.sln 2011-01-24 19:14:48 +0000
+++ b/installer-vs2010.sln 2011-01-24 20:58:09 +0000
@@ -10,6 +10,8 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManifestManager", "ManifestManager\ManifestManager.csproj", "{6BFB8E06-5036-4FC5-B189-14D7DBC4404F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WexInstallerUpdater", "WexInstallerUpdater\WexInstallerUpdater.csproj", "{A54EF986-DFDA-45BD-A901-C908C846A02B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,16 @@
{6BFB8E06-5036-4FC5-B189-14D7DBC4404F}.Release|Mixed Platforms.Build.0 = Release|x86
{6BFB8E06-5036-4FC5-B189-14D7DBC4404F}.Release|x86.ActiveCfg = Release|x86
{6BFB8E06-5036-4FC5-B189-14D7DBC4404F}.Release|x86.Build.0 = Release|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Debug|x86.ActiveCfg = Debug|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Debug|x86.Build.0 = Debug|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Release|Any CPU.ActiveCfg = Release|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Release|Mixed Platforms.Build.0 = Release|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Release|x86.ActiveCfg = Release|x86
+ {A54EF986-DFDA-45BD-A901-C908C846A02B}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20110124205809-se2qg7190hc0hmqt.bundle
| Thread |
|---|
| • bzr commit into wex-installer-1.0 branch (reggie.burnett:262) | Reggie Burnett | 24 Jan |