Skip to content

Commit ed04080

Browse files
committed
Fixed installer not importing old config
1 parent ada0986 commit ed04080

File tree

6 files changed

+54
-5
lines changed

6 files changed

+54
-5
lines changed

installer_lib/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,41 @@ else(WIN32)
6363
set(VERSION_ARCH Unknown)
6464
endif(WIN32)
6565

66+
set(INSTALL_FILES_BASE "")
67+
68+
set(CONFIG_BOOT_CONF_LOCATION
69+
"\${exe-path}/boot.ini"
70+
CACHE
71+
STRING
72+
"Location of boot ini (the file which specified where to load the config)"
73+
)
74+
set(CONFIG_DEFAULT_CONF_LOCATION
75+
"old"
76+
CACHE STRING "Default configuration store")
77+
set(CONFIG_DEFAULT_CONF_INI_BASE
78+
"ini://\${shared-path}/"
79+
CACHE STRING "Base location for ini files")
80+
set(CONFIG_MODULE_FOLDER
81+
"\${exe-path}/modules"
82+
CACHE STRING "modules folder")
83+
set(CONFIG_WEB_FOLDER
84+
"\${shared-path}/web"
85+
CACHE STRING "web folder")
86+
set(CONFIG_SCRIPTS_FOLDER
87+
"\${exe-path}/scripts"
88+
CACHE STRING "script folder")
89+
set(CONFIG_CERT_FOLDER
90+
"\${shared-path}/security"
91+
CACHE STRING "securoty (certificates) folder")
92+
set(CONFIG_DEFAULT_CACHE_PATH
93+
"\${shared-path}/cache"
94+
CACHE STRING "Path for caching stuff")
95+
set(CONFIG_LOG_FOLDER
96+
"\${shared-path}/log"
97+
CACHE STRING "Path for log files")
98+
set(CONFIG_DEFAULT_LOG_LOCATION
99+
"\${exe-path}/nsclient.log"
100+
CACHE STRING "PAth for log file")
66101

67102
configure_file(${NSCP_INCLUDEDIR}/config.h.in
68103
${PROJECT_BINARY_DIR}/include/config.h @ONLY)

installer_lib/installer_helper.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class msi_helper {
3535
logMessage(L"installer_lib::" + action);
3636
}
3737
~msi_helper() {
38-
MsiCloseHandle(hInstall_);
3938
hInstall_ = NULL;
4039
}
4140

installer_lib/installer_lib.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ class msi_logger : public nsclient::logging::logger {
8585

8686

8787
void debug(const std::string& module, const char* file, const int line, const std::string& message) {
88+
do_log("debug: " + message);
8889
}
8990
void trace(const std::string& module, const char* file, const int line, const std::string& message) {
9091
}
9192
void info(const std::string& module, const char* file, const int line, const std::string& message) {
93+
do_log("info: " + message);
9294
}
9395
void warning(const std::string& module, const char* file, const int line, const std::string& message) {
9496
do_log("warning: " + message);
@@ -106,9 +108,11 @@ class msi_logger : public nsclient::logging::logger {
106108

107109

108110
void do_log(const std::string data) {
111+
109112
std::wstring str = utf8::cvt<std::wstring>(data);
110113
if (str.empty())
111114
return;
115+
h->setProperty(L"NSCP_ERROR_LOG", L"Error: " + str);
112116
if (boost::algorithm::starts_with(str, L"error:")) {
113117
if (!error_.empty())
114118
error_ += L"\n";
@@ -150,7 +154,7 @@ class msi_logger : public nsclient::logging::logger {
150154

151155

152156
void nsclient::logging::log_message_factory::log_fatal(std::string message) {
153-
// std::cout << message << "\n";
157+
// std::cout << message << "\n";
154158
}
155159

156160
std::string nsclient::logging::log_message_factory::create_critical(const std::string &module, const char* file, const int line, const std::string &message) {
@@ -318,6 +322,8 @@ std::wstring read_map_data(msi_helper &h) {
318322
#define KEY_CONF_OLD_ERROR KEY CONF_OLD_ERROR
319323
#define KEY_CONF_HAS_ERRORS KEY CONF_HAS_ERRORS
320324

325+
#define ERROR_KEY L"NSCP_ERROR"
326+
321327

322328
void dump_config(msi_helper &h, std::wstring title) {
323329
h.dumpReason(title);
@@ -446,6 +452,7 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
446452

447453
std::wstring map_data = read_map_data(h);
448454
if (allow == L"0") {
455+
h.setProperty(ERROR_KEY, L"Configuration is not allowed to change");
449456
h.logMessage(L"Configuration not allowed: " + allow);
450457
h.setProperty(KEY_CONF_CAN_CHANGE, L"0");
451458
h.setProperty(KEY_CONF_HAS_ERRORS, L"0");
@@ -454,7 +461,8 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
454461
}
455462

456463
if (!boost::filesystem::is_directory(utf8::cvt<std::string>(target))) {
457-
h.logMessage(L"Target folder not found: " + target);
464+
h.setProperty(ERROR_KEY, L"Configuration not found: " + target);
465+
h.logMessage(L"Target folder not found: " + target);
458466
h.setProperty(KEY_CONF_CAN_CHANGE, L"1");
459467
h.setProperty(KEY_CONF_HAS_ERRORS, L"0");
460468
dump_config(h, L"After ImportConfig");
@@ -463,6 +471,7 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
463471

464472
installer_settings_provider provider(&h, target, map_data);
465473
if (!settings_manager::init_installer_settings(&provider, "")) {
474+
h.setProperty(ERROR_KEY, L"Settings context had fatal errors");
466475
h.logMessage(L"Settings context had fatal errors");
467476
h.setProperty(KEY_CONF_OLD_ERROR, provider.get_error());
468477
h.setProperty(KEY_CONF_CAN_CHANGE, L"0");
@@ -554,12 +563,14 @@ extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
554563
dump_config(h, L"After ImportConfig");
555564

556565
} catch (installer_exception e) {
566+
h.setProperty(ERROR_KEY, L"Installer exception");
557567
h.logMessage(L"Failed to read old configuration file: " + e.what());
558568
h.setProperty(KEY_CONF_OLD_ERROR, e.what());
559569
h.setProperty(KEY_CONF_CAN_CHANGE, L"0");
560570
h.setProperty(KEY_CONF_HAS_ERRORS, L"1");
561571
return ERROR_SUCCESS;
562572
} catch (...) {
573+
h.setProperty(ERROR_KEY, L"Unknown exception");
563574
h.logMessage(L"Failed to read old configuration file: Unknown exception");
564575
h.setProperty(KEY_CONF_OLD_ERROR, L"Unknown exception!");
565576
h.setProperty(KEY_CONF_CAN_CHANGE, L"0");

installers/installer-NSCP/Product.wxs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
<CustomAction Id='ImportConfig' BinaryKey='InstallerHelper' DllEntry='ImportConfig' Impersonate='yes' Execute="immediate" Return="check" />
272272
<CustomAction Id='ScheduleWriteConfig' BinaryKey='InstallerHelper' DllEntry='ScheduleWriteConfig' Impersonate='yes' Execute="immediate" Return="check" />
273273
<CustomAction Id="ApplyTool" BinaryKey="InstallerHelper" DllEntry="ApplyTool" Impersonate="yes" Execute="immediate" Return="check" />
274-
<CustomAction Id="DetectTool" BinaryKey="InstallerHelper" DllEntry="DetectTool" Impersonate="no" Execute="immediate" Return="check" />
274+
<CustomAction Id="DetectTool" BinaryKey="InstallerHelper" DllEntry="DetectTool" Impersonate="yes" Execute="immediate" Return="check" />
275275
<CustomAction Id="ExecWriteConfig" BinaryKey="InstallerHelper" DllEntry="ExecWriteConfig" Impersonate="no" Execute="deferred" Return="check" />
276276

277277
<CustomAction Id='NeedUninstall' BinaryKey='InstallerHelper' DllEntry='NeedUninstall' Impersonate='yes' Execute="immediate" Return="check" />
@@ -310,6 +310,8 @@
310310
<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWAPPFOUND</Custom>
311311
<Custom Action="NeedUninstall" After="FindRelatedProducts">1</Custom>
312312
<Custom Action="DetectTool" After="NeedUninstall">1</Custom>
313+
314+
313315
</InstallUISequence>
314316

315317
<Property Id="ALLUSERS">

installers/ui/WixUI_MondoNSCP.wxs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Patch dialog sequence:
6363
<Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="InvalidConfigureationDlg" Order="4">KEY_CONF_HAS_ERRORS = "1"</Publish>
6464
<Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="ConfigureDlg" Order="2">KEY_CONF_CAN_CHANGE = "1"</Publish>
6565
<Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="NewDialog" Value="VerifyReadyDlg" Order="1">1</Publish>
66+
<Publish Dialog="SetupTypeDlg" Control="TypicalButton" Event="DoAction" Value="ImportConfig">1</Publish>
67+
6668
<Publish Dialog="SetupTypeDlg" Control="CustomButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
6769
<Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="InvalidConfigureationDlg" Order="4">KEY_CONF_HAS_ERRORS = "1"</Publish>
6870
<Publish Dialog="SetupTypeDlg" Control="CompleteButton" Event="NewDialog" Value="SelectConfigurationDlg" Order="3">CONF_OLD_FOUND="0"</Publish>

libs/settings_manager/settings_manager_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace settings_manager {
9898
return settings::instance_raw_ptr(new settings::INISettings(this, alias, key));
9999
if (settings::INISettings::context_exists(this, DEFAULT_CONF_INI_BASE + key))
100100
return settings::instance_raw_ptr(new settings::INISettings(this,alias, DEFAULT_CONF_INI_BASE + key));
101-
throw settings::settings_exception(__FILE__, __LINE__, "Undefined settings protocol: " + url.protocol);
101+
throw settings::settings_exception(__FILE__, __LINE__, "Undefined settings protocol: " + url.protocol + ", key=" + key);
102102
}
103103

104104
bool NSCSettingsImpl::supports_edit(const std::string key) {

0 commit comments

Comments
 (0)