Harden installer update activation fallback
This commit is contained in:
@@ -23,7 +23,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
private const string ProductName = "BizTalk Platform Management Tool";
|
||||
|
||||
/// <summary>Aktuelle Produktversion des Installers und Uninstall-Eintrags.</summary>
|
||||
private const string ProductVersion = "2.2.2";
|
||||
private const string ProductVersion = "2.2.3";
|
||||
|
||||
/// <summary>
|
||||
/// Wartezeiten zwischen Wiederholungen atomarer Verzeichnisverschiebungen.
|
||||
@@ -244,19 +244,18 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
if (hadExistingInstallation || Directory.Exists(installDirectory)) throw;
|
||||
// Eine Neuinstallation hat noch keine aktive Vorversion. Deshalb ist ein
|
||||
// erneut hashgeprüfter Copy-Fallback sicher rückrollbar, ohne die strengere
|
||||
// atomare Update-Grenze für bestehende Installationen aufzuweichen.
|
||||
EnsureVerifiedCopyActivationIsSafe(hadExistingInstallation, backupCreated, installDirectory);
|
||||
// Bei einem Update bleibt die Vorversion vollständig im atomar erzeugten
|
||||
// Backup erhalten. Dadurch ist auch eine teilweise Zielkopie rückrollbar.
|
||||
activated = true;
|
||||
ActivateNewInstallationByVerifiedCopy(stagingDirectory, installDirectory, files, ex, log);
|
||||
ActivateByVerifiedCopy(stagingDirectory, installDirectory, files, hadExistingInstallation, ex, log);
|
||||
activationUsedCopyFallback = true;
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
if (hadExistingInstallation || Directory.Exists(installDirectory)) throw;
|
||||
EnsureVerifiedCopyActivationIsSafe(hadExistingInstallation, backupCreated, installDirectory);
|
||||
activated = true;
|
||||
ActivateNewInstallationByVerifiedCopy(stagingDirectory, installDirectory, files, ex, log);
|
||||
ActivateByVerifiedCopy(stagingDirectory, installDirectory, files, hadExistingInstallation, ex, log);
|
||||
activationUsedCopyFallback = true;
|
||||
}
|
||||
|
||||
@@ -899,27 +898,47 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aktiviert eine Neuinstallation durch eine erneut hashgeprüfte Kopie, wenn Windows
|
||||
/// ausschließlich die Verzeichnisumbenennung des erfolgreich geprüften Stagings sperrt.
|
||||
/// Stellt sicher, dass ein Kopierfallback keine aktive oder ungesicherte Vorversion überschreibt.
|
||||
/// </summary>
|
||||
/// <param name="hadExistingInstallation"><c>true</c>, wenn beim Start eine Installation vorhanden war.</param>
|
||||
/// <param name="backupCreated"><c>true</c>, wenn diese Vorversion bereits atomar gesichert wurde.</param>
|
||||
/// <param name="targetDirectory">Das erwartungsgemäß nicht vorhandene Installationsziel.</param>
|
||||
private static void EnsureVerifiedCopyActivationIsSafe(
|
||||
bool hadExistingInstallation,
|
||||
bool backupCreated,
|
||||
string targetDirectory)
|
||||
{
|
||||
if (Directory.Exists(targetDirectory) || File.Exists(targetDirectory))
|
||||
throw new InvalidOperationException("Verified copy activation refused because the target path already exists: " + targetDirectory);
|
||||
if (hadExistingInstallation && !backupCreated)
|
||||
throw new InvalidOperationException("Verified copy activation refused because the existing installation was not backed up.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aktiviert eine Neuinstallation oder ein bereits gesichertes Update durch eine erneut
|
||||
/// hashgeprüfte Kopie, wenn Windows nur die Staging-Umbenennung dauerhaft sperrt.
|
||||
/// </summary>
|
||||
/// <param name="stagingDirectory">Das bereits validierte Staging-Verzeichnis.</param>
|
||||
/// <param name="targetDirectory">Das noch nicht vorhandene Installationsverzeichnis.</param>
|
||||
/// <param name="files">Die validierten Manifesteinträge.</param>
|
||||
/// <param name="hadExistingInstallation"><c>true</c> für ein Update mit erhaltenem Backup.</param>
|
||||
/// <param name="moveException">Der vorausgegangene dauerhafte Move-Fehler.</param>
|
||||
/// <param name="log">Das Diagnoseprotokoll des aktuellen Setup-Laufs.</param>
|
||||
private static void ActivateNewInstallationByVerifiedCopy(
|
||||
private static void ActivateByVerifiedCopy(
|
||||
string stagingDirectory,
|
||||
string targetDirectory,
|
||||
IEnumerable<PackageFile> files,
|
||||
bool hadExistingInstallation,
|
||||
Exception moveException,
|
||||
SetupOperationLog log)
|
||||
{
|
||||
var scope = hadExistingInstallation ? "update_after_backup" : "new_install";
|
||||
log.Write(
|
||||
"WARN",
|
||||
"event=activation_fallback_started method=verified_copy reason=directory_move_exhausted "
|
||||
"event=activation_fallback_started method=verified_copy scope=" + scope + " reason=directory_move_exhausted "
|
||||
+ SetupOperationLog.FormatException(moveException));
|
||||
CopyPayload(stagingDirectory, targetDirectory, files);
|
||||
log.Write("INFO", "event=activation_fallback_complete method=verified_copy target=\"" + targetDirectory + "\"");
|
||||
log.Write("INFO", "event=activation_fallback_complete method=verified_copy scope=" + scope + " target=\"" + targetDirectory + "\"");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace BizTalkPlatformManagementTool.Setup
|
||||
{
|
||||
AutoSize = true,
|
||||
Font = new Font(Font.FontFamily, 14, FontStyle.Bold),
|
||||
Text = "BizTalk Platform Management Tool 2.2.2"
|
||||
Text = "BizTalk Platform Management Tool 2.2.3"
|
||||
});
|
||||
root.Controls.Add(new Label
|
||||
{
|
||||
|
||||
@@ -8,6 +8,6 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyProduct("BizTalk Platform Management Tool")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("675b68a9-bd80-46a5-b8c5-3b11b0b374e2")]
|
||||
[assembly: AssemblyVersion("2.2.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.2.2.0")]
|
||||
[assembly: AssemblyVersion("2.2.3.0")]
|
||||
[assembly: AssemblyFileVersion("2.2.3.0")]
|
||||
[assembly: InternalsVisibleTo("BizTalkPlatformManagementTool.Tests")]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="2.2.2.0" name="BizTalkPlatformManagementTool.Setup" />
|
||||
<assemblyIdentity version="2.2.3.0" name="BizTalkPlatformManagementTool.Setup" />
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security><requestedPrivileges><requestedExecutionLevel level="requireAdministrator" uiAccess="false" /></requestedPrivileges></security>
|
||||
</trustInfo>
|
||||
|
||||
@@ -9,6 +9,6 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © 2026")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("2c5b2c0a-f407-46c2-9e3b-1fa09fa8445a")]
|
||||
[assembly: AssemblyVersion("2.2.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.2.2.0")]
|
||||
[assembly: AssemblyVersion("2.2.3.0")]
|
||||
[assembly: AssemblyFileVersion("2.2.3.0")]
|
||||
[assembly: InternalsVisibleTo("BizTalkPlatformManagementTool.Tests")]
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace BizTalkPlatformManagementTool.Services
|
||||
/// <summary>
|
||||
/// Current tool version written into generated snapshots.
|
||||
/// </summary>
|
||||
public const string Version = "2.2.2-net461";
|
||||
public const string Version = "2.2.3-net461";
|
||||
|
||||
/// <summary>
|
||||
/// Fallback application name used when WMI does not expose an application property.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="2.2.2.0" name="BizTalkPlatformManagementTool" />
|
||||
<assemblyIdentity version="2.2.3.0" name="BizTalkPlatformManagementTool" />
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
|
||||
Reference in New Issue
Block a user