From dccbd662025af200e6d6ef205bdd082dca446056 Mon Sep 17 00:00:00 2001 From: Paul Reeves Date: Fri, 21 Jun 2024 11:42:07 +0200 Subject: [PATCH] Improve detection of existing configured security database --- .../arch-specific/win32/FirebirdInstall.iss | 10 +++++++- .../FirebirdInstallEnvironmentChecks.inc | 23 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/builds/install/arch-specific/win32/FirebirdInstall.iss b/builds/install/arch-specific/win32/FirebirdInstall.iss index 2cf4e00d4f..859fb1b72c 100644 --- a/builds/install/arch-specific/win32/FirebirdInstall.iss +++ b/builds/install/arch-specific/win32/FirebirdInstall.iss @@ -635,6 +635,10 @@ program Setup; // b) Debugged. // This hopefully keeps the main script simpler to follow. + +const + UNDEFINED = -1; + Var InstallRootDir: String; FirebirdConfSaved: String; @@ -650,6 +654,8 @@ Var SYSDBAPassword: String; // SYSDBA password + init_secdb: integer; // Is set to UNDEFINED by default in InitializeSetup + #ifdef setuplogging // Not yet implemented - leave log in %TEMP% // OkToCopyLog : Boolean; // Set when installation is complete. @@ -741,6 +747,7 @@ begin InitExistingInstallRecords; AnalyzeEnvironment; result := AnalysisAssessment; + init_secdb := UNDEFINED; end; @@ -1052,7 +1059,8 @@ begin IncrementSharedCount(Is64BitInstallMode, GetAppPath+'\security{#FB_MAJOR_VER}.fdb', false); IncrementSharedCount(Is64BitInstallMode, GetAppPath+'\replication.conf', false); - InitSecurityDB; + if init_secdb = 1 then + InitSecurityDB; //Fix up conf file UpdateFirebirdConf; diff --git a/builds/install/arch-specific/win32/FirebirdInstallEnvironmentChecks.inc b/builds/install/arch-specific/win32/FirebirdInstallEnvironmentChecks.inc index ec0e603eed..cbdd5c97a5 100644 --- a/builds/install/arch-specific/win32/FirebirdInstallEnvironmentChecks.inc +++ b/builds/install/arch-specific/win32/FirebirdInstallEnvironmentChecks.inc @@ -1480,14 +1480,27 @@ end; function ConfigureAuthentication: boolean; +// This function should only be called once - when the innosetup installer tries to +// install the secdb. If it is called a second time it will always find the secdb +// exists, even if it hasn't been configured. The only real way to test whether we +// should configure authentication is to actually _open_ a database and read the +// sec$users table. Except we cannot do that as we need this information before we +// install the files needed to read the database. begin - if IsNotServerInstall then - Result := false - else - if FileExists(WizardDirValue + '\security6.fdb') then + // if it is the first time we are called test for existence of the security db + if init_secdb = UNDEFINED then begin + if FileExists(WizardDirValue + '\security{#FB_MAJOR_VER}.fdb') then Result := false else - Result := true; + Result := true + end + else + // else the result is the current setting of init_secdb + Result := Boolean(init_secdb); + + // Whatever the result, cast it to an integer and update init_secdb + init_secdb := Integer(Result); + end;