Changeset b7d17f8 in nscp


Ignore:
Timestamp:
04/11/11 06:33:49 (2 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
d66ccee
Parents:
c391984
Message:

0.4.x: Major update with a lot of fixes and what not.
Now NSCA is working with old config file as well as a brand new http settings store and many many other fixes.

Files:
15 added
1 deleted
28 edited
1 moved

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    rc391984 rb7d17f8  
    8282SET(VERSION_TXT ${CMAKE_CURRENT_SOURCE_DIR}/version.txt) 
    8383 
    84 execute_process( 
     84EXECUTE_PROCESS( 
    8585  COMMAND ${PYTHON_EXECUTABLE} 
    86     "${BUILD_PYTHON_FOLDER}/version.py" 
    87     --file ${VERSION_TXT} 
    88     --display 
     86    "${BUILD_PYTHON_FOLDER}/version.py"  
     87    --file ${VERSION_TXT}  
     88    --display  
     89    --generate-hpp "${BUILD_PYTHON_FOLDER}/version.hpp" 
    8990  OUTPUT_VARIABLE TMP_VERSION_OUT 
    9091  ) 
     
    385386MESSAGE(STATUS "Build path: ${PROJECT_BINARY_DIR}") 
    386387SET(NSCP_PROJECT_BINARY_DIR ${PROJECT_BINARY_DIR}) 
     388ADD_SUBDIRECTORY("helpers/settings_manager") 
    387389ADD_SUBDIRECTORY("service") 
    388390SET(MAIN_NSCP_TARGET "nscp") 
  • build.cmake

    r197b263 rb7d17f8  
    2626  SET(INC_PROTOBUF_DIR "D:/source/libraries/protobuf-2.4.0a") 
    2727 
    28   SET(INC_CRYPTOPP_DIR "D:/source/libraries/cryptopp-5.6.1") 
     28  SET(INC_CRYPTOPP_DIR "D:/source/libraries/crypto++-5.6.1") 
    2929 
    3030  SET(INC_LUA_DIR "D:/source/libraries/lua-5.1.4") 
  • build/cmake/wix.cmake

    r197b263 rb7d17f8  
    1515 
    1616if (WIN32) 
    17     MACRO(DBG_MSG _MSG) 
    18         #MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}):\r\n ${_MSG}") 
    19     ENDMACRO(DBG_MSG) 
     17  MACRO(DBG_MSG _MSG) 
     18#   MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}):\r\n ${_MSG}") 
     19  ENDMACRO(DBG_MSG) 
    2020 
    2121 
     
    2525        "$ENV{WIX}" 
    2626        "$ENV{WIX_ROOT_DIR}" 
     27        "$ENV{ProgramFiles}/Windows Installer XML v3.5" 
     28        "$ENV{ProgramFiles}/Windows Installer XML v3" 
    2729        "$ENV{ProgramFiles}/Windows Installer XML" 
    28         "$ENV{ProgramFiles}/Windows Installer XML v3" 
    2930        ) 
    3031 
     
    4142        PATHS ${WIX_POSSIBLE_ROOT_DIRS}) 
    4243    DBG_MSG("WIX_ROOT_DIR=${WIX_ROOT_DIR}") 
     44   
     45  IF(EXISTS "${WIX_ROOT_DIR}/bin/pyro.exe") 
     46    SET(WIX_VERSION 3) 
     47  ELSE(EXISTS "${WIX_ROOT_DIR}/bin/pyro.exe") 
     48    SET(WIX_VERSION 2) 
     49  ENDIF(EXISTS "${WIX_ROOT_DIR}/bin/pyro.exe") 
     50   
    4351 
    4452 
     
    106114          OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ} 
    107115          COMMAND   ${WIX_CANDLE} 
    108           ARGS      ${WIX_CANDLE_FLAGS} ${SOURCE_WIX_FILE} 
     116          ARGS        
     117                -ext WixFirewallExtension  
     118                -ext WixUtilExtension 
     119                ${WIX_CANDLE_FLAGS}  
     120                ${SOURCE_WIX_FILE} 
    109121          DEPENDS   ${SOURCE_WIX_FILE} ${_extra_dep} 
    110           COMMENT   "Compiling ${SOURCE_WIX_FILE} -> ${OUTPUT_WIXOBJ}" 
     122          COMMENT   "Compiling ${SOURCE_WIX_FILE} -ext WixFirewallExtension -ext WixUtilExtension ${WIX_CANDLE_FLAGS} -> ${OUTPUT_WIXOBJ}" 
    111123          ) 
    112124        SET (OUTPUT_WIXOBJ ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ}) 
     
    142154                COMMAND   ${WIX_HEAT} 
    143155                ARGS      file ${SOURCE_WIX_FILE} 
     156              -ext WixFirewallExtension 
     157              -ext WixUtilExtension 
    144158                          -out ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_WIXOBJ} 
    145159                          ${WIX_HEAT_FLAGS} 
     
    162176    MACRO(WIX_LINK _target _sources _loc_files) 
    163177        DBG_MSG("WIX command: ${WIX_LIGHT}\n WIX target: ${_target} objs: ${${_sources}}") 
    164  
    165         SET( WIX_LINK_FLAGS_A ${WIX_LINK_FLAGS} ) 
     178        DBG_MSG("WIX version: ${WIX_VERSION}") 
     179 
     180        SET(WIX_LINK_FLAGS_A ${WIX_LINK_FLAGS}) 
    166181        # Add localization 
    167         FOREACH (_current_FILE ${_loc_files}) 
    168             SET( WIX_LINK_FLAGS_A ${WIX_LINK_FLAGS_A} -loc "${_current_FILE}" ) 
     182        FOREACH(_current_FILE ${_loc_files}) 
     183      IF(${WIX_VERSION} EQUAL 3) 
     184        SET(WIX_LINK_FLAGS_A ${WIX_LINK_FLAGS_A} -cultures:"${_current_FILE}") 
     185      ELSE(${WIX_VERSION} EQUAL 3) 
     186        SET(WIX_LINK_FLAGS_A ${WIX_LINK_FLAGS_A} -loc "${_current_FILE}") 
     187      ENDIF(${WIX_VERSION} EQUAL 3) 
    169188            DBG_MSG("WIX link localization: ${_current_FILE}") 
    170         ENDFOREACH (_current_FILE) 
     189        ENDFOREACH(_current_FILE) 
    171190        DBG_MSG("WIX link flags: ${WIX_LINK_FLAGS_A}") 
    172 #   SET(_src_list ${_sources}) 
    173 #   FOREACH( _cpp ${_sources} ) 
    174 #     SET( _arguments ${_arguments} ${_cpp} ) 
    175 #   ENDFOREACH( _cpp ) 
    176  #       DBG_MSG("SRC ===> : ${_arguments}") 
    177  
    178         ADD_CUSTOM_COMMAND( 
    179       OUTPUT    ${_target} 
    180             COMMAND   ${WIX_LIGHT} 
    181             ARGS      ${WIX_LINK_FLAGS_A} -out "${_target}" ${${_sources}} 
    182             DEPENDS   ${${_sources}} 
    183             COMMENT   "Linking ${_sources} -> ${_target}" 
    184             ) 
     191 
     192    IF(${WIX_VERSION} EQUAL 3) 
     193      ADD_CUSTOM_COMMAND( 
     194        OUTPUT    ${_target} 
     195        COMMAND   ${WIX_LIGHT} 
     196        ARGS      ${WIX_LINK_FLAGS_A}  
     197              -ext WixUIExtension  
     198              -ext WixFirewallExtension  
     199              -ext WixUtilExtension  
     200              -out "${_target}"  
     201              ${${_sources}} 
     202        DEPENDS   ${${_sources}} 
     203        COMMENT   "Linking ${${_sources}} -> ${_target} (${WIX_LIGHT} ${WIX_LINK_FLAGS_A} -ext WixUIExtension -ext WixFirewallExtension -out "${_target}" ${${_sources}})" 
     204        ) 
     205    ELSE(${WIX_VERSION} EQUAL 3) 
     206      ADD_CUSTOM_COMMAND( 
     207        OUTPUT    ${_target} 
     208        COMMAND   ${WIX_LIGHT} 
     209        ARGS      ${WIX_LINK_FLAGS_A} -out "${_target}" ${${_sources}} 
     210        DEPENDS   ${${_sources}} 
     211        COMMENT   "Linking ${${_sources}} -> ${_target} (${WIX_LINK_FLAGS_A})" 
     212        ) 
     213    ENDIF(${WIX_VERSION} EQUAL 3) 
    185214    ENDMACRO(WIX_LINK) 
    186215   
  • files/old-settings.map

    rc391984 rb7d17f8  
    1616modules/NRPEClient.dll=/modules/NRPEClient 
    1717modules/CheckTaskSched.dll=/modules/CheckTaskSched 
     18modules/Scheduler.dll=/modules/Scheduler 
    1819 
    1920# Crash section 
     
    7374includes/*=/include/* 
    7475 
    75 #NSCA Agent/interval= 
    76 #NSCA Agent/encryption_method= 
    77 #NSCA Agent/password= 
     76NSCA Agent/interval=/settings/scheduler/default/interval 
     77NSCA Agent/hostname=/settings/NSCA/agent/hostname 
     78NSCA Commands/*=/settings/scheduler/schedules 
     79 
     80 
     81NSCA Agent/encryption_method=/settings/NSCA/agent/server/encryption method 
     82NSCA Agent/nsca_host=/settings/NSCA/agent/server/host 
     83NSCA Agent/password=/settings/NSCA/agent/server/password 
     84NSCA Agent/nsca_port=/settings/NSCA/agent/server/port 
     85NSCA Agent/time_delay=/settings/NSCA/agent/delay 
    7886#NSCA Agent/bind_to_address= 
    79 #NSCA Agent/hostname= 
    80 #NSCA Agent/nsca_host=192.168.0.1 
    81 #NSCA Agent/nsca_port=5667 
    8287 
    83 #NSCA Commands/*= 
    8488 
    8589#NRPE Client Handlers/*= 
  • helpers/installer-dlls/main_dll/CMakeLists.txt

    r197b263 rb7d17f8  
    3131  Msi.lib 
    3232  bufferoverflowu.lib 
     33  settings_manager 
    3334) 
    3435 
  • helpers/installer-dlls/main_dll/installer_helper.hpp

    r197b263 rb7d17f8  
    5151  } 
    5252 
     53  bool propertyTouched(std::wstring path) { 
     54    std::wstring old = getPropery(path + _T("_DEFAULT")); 
     55    std::wstring cur = getPropery(path); 
     56    return old != cur; 
     57  } 
    5358  std::wstring getPropery(std::wstring path) { 
    5459    TCHAR tmpBuf[MAX_PATH]; 
     
    7782    return buffer; 
    7883  } 
    79 /* 
    80   void setPropertyAndOld(std::wstring key, std::wstring value) { 
    81     MsiSetProperty (hInstall_, key.c_str(), value.c_str()); 
    82     MsiSetProperty (hInstall_, (key+_T("_OLD")).c_str(), value.c_str()); 
    83   } 
    84   */ 
    85   void setupMyProperty(std::wstring key, std::wstring val) { 
    86     logMessage(_T("Setting old values: ") + key + _T("_OLD=") + val); 
    87     setPropertyIfEmpty(key+_T("_OLD"), val); 
    88     std::wstring oldDef = getPropery(key+_T("_DEFAULT")); 
    89     if (!oldDef.empty()) 
    90       val = oldDef; 
    91     if (val == MY_EMPTY) 
    92       val = _T(""); 
    93     logMessage(_T("Setting old values: ") + key + _T("=") + val); 
    94     setPropertyIfEmpty(key, val); 
    95   } 
    96   void setMyProperty(std::wstring key, std::wstring val) { 
    97     setProperty(key, val); 
    98   } 
    99    
     84 
    10085  void setPropertyIfEmpty(std::wstring key, std::wstring val) { 
    10186    std::wstring old = getPropery(key); 
     
    10388      setProperty(key, val); 
    10489  } 
    105   void setPropertyAndOld(std::wstring key, std::wstring value, std::wstring oldvalue) { 
    106     MsiSetProperty (hInstall_, key.c_str(), value.c_str()); 
    107     std::wstring old_key = key+_T("_OLD"); 
    108     if (getPropery(old_key).empty()) 
    109       setProperty(old_key, oldvalue); 
    110     //MsiSetProperty (hInstall_, (key+_T("_OLD")).c_str(), oldvalue.c_str()); 
    111   } 
    112   void setPropertyOld(std::wstring key, std::wstring oldvalue) { 
    113     MsiSetProperty (hInstall_, (key+_T("_OLD")).c_str(), oldvalue.c_str()); 
     90  void setPropertyAndOld(std::wstring key, std::wstring value) { 
     91    MsiSetProperty(hInstall_, key.c_str(), value.c_str()); 
     92    MsiSetProperty(hInstall_, (key+_T("_OLD")).c_str(), value.c_str()); 
    11493  } 
    11594  void setProperty(std::wstring key, std::wstring value) { 
     
    651630    for (int i=0; ::MsiEnumProducts(i, reinterpret_cast<TCHAR*>(&buffer)) == ERROR_SUCCESS; i++) { 
    652631      std::wstring name = getProductName(buffer); 
    653       logMessage(_T("Found a product: ") + (std::wstring)buffer + _T("=") + name); 
    654632      ret.push_back(buffer); 
    655633    } 
  • helpers/installer-dlls/main_dll/main_dll.cpp

    r2d69ab6 rb7d17f8  
    99#include <file_helpers.hpp> 
    1010#include "installer_helper.hpp" 
     11#include "../../settings_manager/settings_manager_impl.h" 
    1112 
    1213const UINT COST_SERVICE_INSTALL = 2000; 
    13  
    14 LPCWSTR vcsServiceQuery = 
    15 L"SELECT `ShortName`, `LongName`, `Description`, `Program`, `Dependencies`, `Attributes`, `Component_` FROM `Services`"; 
    16 enum eServiceQuery { feqShortName = 1, feqLongName, feqDesc, feqProgram, feqDeps, feqAttributes, feqComponent }; 
    17 enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; 
    1814 
    1915bool install(msi_helper &h, std::wstring exe, std::wstring service_short_name, std::wstring service_long_name, std::wstring service_description, std::wstring service_deps); 
    2016bool uninstall(msi_helper &h, std::wstring service_name); 
    21 UINT SchedServiceMgmt(__in MSIHANDLE hInstall, msi_helper::WCA_TODO todoSched); 
    22  
    23 extern "C" UINT __stdcall ScheduleInstallService(MSIHANDLE hInstall) { 
    24   return SchedServiceMgmt(hInstall, msi_helper::WCA_TODO_INSTALL); 
    25 } 
    26 extern "C" UINT __stdcall ScheduleUnInstallService(MSIHANDLE hInstall) { 
    27   return SchedServiceMgmt(hInstall, msi_helper::WCA_TODO_UNINSTALL); 
    28 } 
    29 extern "C" UINT __stdcall ExecServiceInstall(__in MSIHANDLE hInstall) { 
    30   HRESULT hr = S_OK; 
    31   // initialize 
    32   msi_helper h(hInstall, _T("ExecServiceInstall")); 
    33   try { 
    34     msi_helper::custom_action_data_r data(h.getPropery(L"CustomActionData")); 
    35  
    36     // loop through all the passed in data 
    37     while (data.has_more()) { 
    38       // extract the custom action data and if rolling back, swap INSTALL and UNINSTALL 
    39       int iTodo = data.get_next_int(); 
    40       if (::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK)) 
    41       { 
    42         if (msi_helper::WCA_TODO_INSTALL == iTodo) 
    43         { 
    44           iTodo = msi_helper::WCA_TODO_UNINSTALL; 
    45         } 
    46         else if (msi_helper::WCA_TODO_UNINSTALL == iTodo) 
    47         { 
    48           iTodo = msi_helper::WCA_TODO_INSTALL; 
    49         } 
    50       } 
    51  
    52       std::wstring shortname = data.get_next_string(); 
    53       std::wstring longname = data.get_next_string(); 
    54       std::wstring desc = data.get_next_string(); 
    55       std::wstring deps = data.get_next_string(); 
    56       int attr = data.get_next_int(); 
    57       BOOL fIgnoreFailures = feaIgnoreFailures == (attr & feaIgnoreFailures); 
    58       std::wstring file = data.get_next_string(); 
    59       switch (iTodo) { 
    60       case msi_helper::WCA_TODO_INSTALL: 
    61       case msi_helper::WCA_TODO_REINSTALL: 
    62         h.logMessage(_T("Installing service install: ") + shortname + _T(", ") + file); 
    63         install(h, file, shortname, longname, desc, deps); 
    64         break; 
    65  
    66       case msi_helper::WCA_TODO_UNINSTALL: 
    67         h.logMessage(_T("Installing service install: ") + shortname + _T(", ") + file); 
    68         uninstall(h, shortname); 
    69         break; 
    70       default: 
    71         h.logMessage(_T("IGNORING service install: ") + shortname + _T(", ") + file); 
    72       } 
    73     } 
    74   } catch (installer_exception e) { 
    75     h.errorMessage(_T("Failed to install service: ") + e.what()); 
    76     return ERROR_SUCCESS; 
    77   } catch (...) { 
    78     h.errorMessage(_T("Failed to install service: <UNKNOWN EXCEPTION>")); 
    79     return ERROR_INSTALL_FAILURE; 
    80   } 
    81   return ERROR_SUCCESS; 
    82  
    83 } 
    84  
    8517 
    8618UINT SchedServiceMgmt(__in MSIHANDLE hInstall, msi_helper::WCA_TODO todoSched) 
    8719{ 
    88   msi_helper h(hInstall, _T("SchedServiceInstall")); 
    89   try { 
    90     int cFirewallExceptions = 0; 
    91     h.logMessage(_T("SchedServiceInstall: ") + strEx::itos(todoSched)); 
    92     // anything to do? 
    93     if (!h.table_exists(L"Services")) { 
    94       h.logMessage(_T("Services table doesn't exist, so there are no services to configure.")); 
    95       return ERROR_SUCCESS; 
    96     } 
    97  
    98     // query and loop through all the firewall exceptions 
    99     PMSIHANDLE hView = h.open_execute_view(vcsServiceQuery); 
    100     if (h.isNull(hView)) { 
    101       h.logMessage(_T("Failed to query service view!")); 
    102       return ERROR_INSTALL_FAILURE; 
    103     } 
    104  
    105     msi_helper::custom_action_data_w custom_data; 
    106     PMSIHANDLE hRec = h.fetch_record(hView); 
    107     while (hRec != NULL) 
    108     { 
    109       std::wstring shortname = h.get_record_formatted_string(hRec, feqShortName); 
    110       std::wstring longname = h.get_record_formatted_string(hRec, feqLongName); 
    111       std::wstring desc = h.get_record_formatted_string(hRec, feqDesc); 
    112       std::wstring deps = h.get_record_formatted_string(hRec, feqDeps); 
    113       std::wstring program = h.get_record_formatted_string(hRec, feqProgram); 
    114       int attributes = h.get_record_integer(hRec, feqAttributes); 
    115       std::wstring component = h.get_record_string(hRec, feqComponent); 
    116  
    117       // figure out what we're doing for this exception, treating reinstall the same as install 
    118       msi_helper::WCA_TODO todoComponent = h.get_component_todo(component); 
    119       if ((msi_helper::WCA_TODO_REINSTALL == todoComponent ? msi_helper::WCA_TODO_INSTALL : todoComponent) != todoSched) { 
    120         h.logMessage(_T("Component '") + component + _T("' action state (") + strEx::itos(todoComponent) + _T(") doesn't match request (") + strEx::itos(todoSched) + _T(")")); 
    121         hRec = h.fetch_record(hView); 
    122         continue; 
    123       } 
    124       h.logMessage(_T("Adding data to CA chunk... ")); 
    125       // action :: name :: remoteaddresses :: attributes :: target :: {port::protocol | path} 
    126       ++cFirewallExceptions; 
    127       custom_data.write_int(todoComponent); 
    128       custom_data.write_string(shortname); 
    129       custom_data.write_string(longname); 
    130       custom_data.write_string(desc); 
    131       custom_data.write_string(deps); 
    132       custom_data.write_int(attributes); 
    133       //custom_data.write_int(fetApplication); 
    134       custom_data.write_string(program); 
    135       h.logMessage(_T("Adding data to CA chunk... DONE")); 
    136       h.logMessage(_T("CA chunk: ") + custom_data.to_string()); 
    137       hRec = h.fetch_record(hView); 
    138     } 
    139     // schedule ExecFirewallExceptions if there's anything to do 
    140     if (custom_data.has_data()) { 
    141       h.logMessage(_T("Scheduling (WixExecServiceInstall) firewall exception: ") + custom_data.to_string()); 
    142       if (msi_helper::WCA_TODO_INSTALL == todoSched) { 
    143         HRESULT hr = h.do_deferred_action(L"WixRollbackServiceInstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
    144         if (FAILED(hr)) { 
    145           h.errorMessage(_T("failed to schedule service install exceptions rollback")); 
    146           return hr; 
    147         } 
    148         hr = h.do_deferred_action(L"WixExecServiceInstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
    149         if (FAILED(hr)) { 
    150           h.errorMessage(_T("failed to schedule service install exceptions execution")); 
    151           return hr; 
    152         } 
    153       } 
    154       else 
    155       { 
    156         h.logMessage(_T("Scheduling (WixExecServiceUninstall) firewall exception: ") + custom_data.to_string()); 
    157         HRESULT hr = h.do_deferred_action(L"WixRollbackServiceUninstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
    158         if (FAILED(hr)) { 
    159           h.errorMessage(_T("failed to schedule service install exceptions rollback")); 
    160           return hr; 
    161         } 
    162         hr = h.do_deferred_action(L"WixExecServiceUninstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
    163         if (FAILED(hr)) { 
    164           h.errorMessage(_T("failed to schedule service install exceptions execution")); 
    165           return hr; 
    166         } 
    167       } 
    168     } else 
    169       h.logMessage(_T("No services scheduled")); 
    170   } catch (installer_exception e) { 
    171     h.errorMessage(_T("Failed to install service: ") + e.what()); 
    172     return ERROR_INSTALL_FAILURE; 
    173   } catch (...) { 
    174     h.errorMessage(_T("Failed to install service: <UNKNOWN EXCEPTION>")); 
    175     return ERROR_INSTALL_FAILURE; 
    176   } 
     20// msi_helper h(hInstall, _T("SchedServiceInstall")); 
     21// try { 
     22//    int cFirewallExceptions = 0; 
     23//    h.logMessage(_T("SchedServiceInstall: ") + strEx::itos(todoSched)); 
     24//    // anything to do? 
     25//    if (!h.table_exists(L"Services")) { 
     26//      h.logMessage(_T("Services table doesn't exist, so there are no services to configure.")); 
     27//      return ERROR_SUCCESS; 
     28//    } 
     29//  
     30//    // query and loop through all the firewall exceptions 
     31//    PMSIHANDLE hView = h.open_execute_view(vcsServiceQuery); 
     32//    if (h.isNull(hView)) { 
     33//      h.logMessage(_T("Failed to query service view!")); 
     34//      return ERROR_INSTALL_FAILURE; 
     35//    } 
     36//  
     37//    msi_helper::custom_action_data_w custom_data; 
     38//    PMSIHANDLE hRec = h.fetch_record(hView); 
     39//    while (hRec != NULL) 
     40//    { 
     41//      std::wstring shortname = h.get_record_formatted_string(hRec, feqShortName); 
     42//      std::wstring longname = h.get_record_formatted_string(hRec, feqLongName); 
     43//      std::wstring desc = h.get_record_formatted_string(hRec, feqDesc); 
     44//      std::wstring deps = h.get_record_formatted_string(hRec, feqDeps); 
     45//      std::wstring program = h.get_record_formatted_string(hRec, feqProgram); 
     46//      int attributes = h.get_record_integer(hRec, feqAttributes); 
     47//      std::wstring component = h.get_record_string(hRec, feqComponent); 
     48//  
     49//      // figure out what we're doing for this exception, treating reinstall the same as install 
     50//      msi_helper::WCA_TODO todoComponent = h.get_component_todo(component); 
     51//      if ((msi_helper::WCA_TODO_REINSTALL == todoComponent ? msi_helper::WCA_TODO_INSTALL : todoComponent) != todoSched) { 
     52//        h.logMessage(_T("Component '") + component + _T("' action state (") + strEx::itos(todoComponent) + _T(") doesn't match request (") + strEx::itos(todoSched) + _T(")")); 
     53//        hRec = h.fetch_record(hView); 
     54//        continue; 
     55//      } 
     56//      h.logMessage(_T("Adding data to CA chunk... ")); 
     57//      // action :: name :: remoteaddresses :: attributes :: target :: {port::protocol | path} 
     58//      ++cFirewallExceptions; 
     59//      custom_data.write_int(todoComponent); 
     60//      custom_data.write_string(shortname); 
     61//      custom_data.write_string(longname); 
     62//      custom_data.write_string(desc); 
     63//      custom_data.write_string(deps); 
     64//      custom_data.write_int(attributes); 
     65//      //custom_data.write_int(fetApplication); 
     66//      custom_data.write_string(program); 
     67//      h.logMessage(_T("Adding data to CA chunk... DONE")); 
     68//      h.logMessage(_T("CA chunk: ") + custom_data.to_string()); 
     69//      hRec = h.fetch_record(hView); 
     70//    } 
     71//    // schedule ExecFirewallExceptions if there's anything to do 
     72//    if (custom_data.has_data()) { 
     73//      h.logMessage(_T("Scheduling (WixExecServiceInstall) firewall exception: ") + custom_data.to_string()); 
     74//      if (msi_helper::WCA_TODO_INSTALL == todoSched) { 
     75//        HRESULT hr = h.do_deferred_action(L"WixRollbackServiceInstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
     76//        if (FAILED(hr)) { 
     77//          h.errorMessage(_T("failed to schedule service install exceptions rollback")); 
     78//          return hr; 
     79//        } 
     80//        hr = h.do_deferred_action(L"WixExecServiceInstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
     81//        if (FAILED(hr)) { 
     82//          h.errorMessage(_T("failed to schedule service install exceptions execution")); 
     83//          return hr; 
     84//        } 
     85//      } 
     86//      else 
     87//      { 
     88//        h.logMessage(_T("Scheduling (WixExecServiceUninstall) firewall exception: ") + custom_data.to_string()); 
     89//        HRESULT hr = h.do_deferred_action(L"WixRollbackServiceUninstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
     90//        if (FAILED(hr)) { 
     91//          h.errorMessage(_T("failed to schedule service install exceptions rollback")); 
     92//          return hr; 
     93//        } 
     94//        hr = h.do_deferred_action(L"WixExecServiceUninstall", custom_data, cFirewallExceptions * COST_SERVICE_INSTALL); 
     95//        if (FAILED(hr)) { 
     96//          h.errorMessage(_T("failed to schedule service install exceptions execution")); 
     97//          return hr; 
     98//        } 
     99//      } 
     100//    } else 
     101//      h.logMessage(_T("No services scheduled")); 
     102// } catch (installer_exception e) { 
     103//    h.errorMessage(_T("Failed to install service: ") + e.what()); 
     104//    return ERROR_INSTALL_FAILURE; 
     105// } catch (...) { 
     106//    h.errorMessage(_T("Failed to install service: <UNKNOWN EXCEPTION>")); 
     107//    return ERROR_INSTALL_FAILURE; 
     108// } 
    177109  return ERROR_SUCCESS; 
    178110 
    179111} 
     112 
     113 
     114class installer_logger : public settings::logger_interface { 
     115public: 
     116  msi_helper &h; 
     117  std::wstring error; 
     118 
     119  installer_logger(msi_helper &h) : h(h) {} 
     120 
     121  virtual void err(std::string file, int line, std::wstring message) { 
     122    error = message; 
     123    h.logMessage(_T("ERROR: ") + message); 
     124  } 
     125  virtual void warn(std::string file, int line, std::wstring message) { 
     126    h.logMessage(_T("WARN: ") + message); 
     127  } 
     128  virtual void info(std::string file, int line, std::wstring message) { 
     129    h.logMessage(_T("INFO: ") + message); 
     130  } 
     131  virtual void debug(std::string file, int line, std::wstring message) {} 
     132}; 
     133 
     134struct installer_settings_provider : public settings_manager::provider_interface { 
     135 
     136  msi_helper &h; 
     137  std::wstring basepath; 
     138  installer_logger logger; 
     139 
     140  installer_settings_provider(msi_helper &h, std::wstring basepath) : h(h), logger(h), basepath(basepath) {} 
     141 
     142  virtual std::wstring expand_path(std::wstring file) { 
     143    strEx::replace(file, _T("${base-path}"), basepath); 
     144    strEx::replace(file, _T("${exe-path}"), basepath); 
     145    strEx::replace(file, _T("${shared-path}"), basepath); 
     146    return file; 
     147  } 
     148  virtual void log_fatal_error(std::wstring error) { 
     149    logger.err("", 0, error); 
     150  } 
     151  virtual settings::logger_interface* create_logger() { 
     152    return &logger; 
     153  } 
     154  boolean has_error() { 
     155    return !logger.error.empty(); 
     156  } 
     157  std::wstring get_error() { 
     158    return logger.error; 
     159  } 
     160}; 
     161 
     162std::wstring has_key(std::wstring path, std::wstring key) { 
     163  return settings_manager::get_settings()->has_key(path, key)?_T("1"):_T(""); 
     164} 
     165 
    180166///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    181  
    182 //#pragma comment(linker, "/EXPORT:ImportConfig=_ImportConfig@4") 
    183 extern "C" UINT __stdcall ImportConfig (MSIHANDLE hInstall) { 
     167// Many options: 
     168// - configuration not allowed    => CONF_CAN_CHANGE=0, CONF_OLD_FOUND=0, CONF_HAS_ERRORS=0 
     169// - target not found       => CONF_CAN_CHANGE=1, CONF_OLD_FOUND=0, CONF_HAS_ERRORS=0 
     170// - target found + config read   => CONF_CAN_CHANGE=1, CONF_OLD_FOUND=1, CONF_HAS_ERRORS=0 
     171// - target found + config NOT read => CONF_CAN_CHANGE=0, CONF_OLD_FOUND=?, CONF_HAS_ERRORS=1 
     172// 
     173// Interpretation: 
     174// CONF_HAS_ERRORS=1  => Dont allow anything (inform of issue) 
     175// CONF_CAN_CHANGE=1  => Allow change 
     176// CONF_OLD_FOUND=0   => Allow setting boot.ini 
     177 
     178extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) { 
    184179  msi_helper h(hInstall, _T("ImportConfig")); 
    185180  try { 
     
    187182    std::wstring main = h.getPropery(_T("MAIN_CONFIGURATION_FILE")); 
    188183    std::wstring custom = h.getPropery(_T("CUSTOM_CONFIGURATION_FILE")); 
    189  
    190 //    h.setupMyProperty(_T("ALLOWED_HOSTS"), MAIN_ALLOWED_HOSTS_DEFAULT); 
    191 //    h.setupMyProperty(_T("NSCLIENT_PWD"), MAIN_SETTINGS_PWD_DEFAULT); 
    192     h.setupMyProperty(_T("CONF_NRPE"), _T("")); 
    193     h.setupMyProperty(_T("CONF_NSCLIENT"), _T("")); 
    194     h.setupMyProperty(_T("CONF_NSCA"), _T("")); 
    195     h.setupMyProperty(_T("CONF_CHECKS"), _T("")); 
    196     h.setupMyProperty(_T("CONF_WMI"), _T("")); 
    197  
    198     std::wstring filename = target + _T("\\") + main; 
    199     if (!file_helpers::checks::exists(filename)) { 
    200       h.setProperty(_T("CONF_CHECKS_GRAY"), _T("")); 
    201       h.setProperty(_T("CONF_CAN_WRITE"), _T("1")); 
    202       h.setProperty(_T("CONF_OLD_NOT_FOUND"), _T("1")); 
     184    std::wstring allow = h.getPropery(_T("ALLOW_CONFIGURATION")); 
     185    if (allow == _T("0")) { 
     186      h.logMessage(_T("Configuration not allowed: ") + allow); 
     187      h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 
     188      h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 
     189      h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); 
    203190      return ERROR_SUCCESS; 
    204191    } 
    205192 
    206 //    Settings::getInstance()->setFile(target, main); 
    207 //    if (Settings::getInstance()->getActiveType() == _T("INI-file")) { 
    208 //      h.setProperty(_T("CONF_CAN_WRITE"), _T("1")); 
    209 //      CopyFile(filename.c_str(), (h.getTempPath() + _T("\\old_nsc.ini")).c_str(), FALSE); 
    210 //    } else 
    211 //      h.setProperty(_T("CONF_CAN_WRITE"), _T("0")); 
    212  
    213  
    214  
    215  
    216 //    std::wstring allowed_hosts = Settings::getInstance()->getString(MAIN_SECTION_TITLE, MAIN_ALLOWED_HOSTS, MAIN_ALLOWED_HOSTS_DEFAULT); 
    217 //    h.setMyProperty(_T("ALLOWED_HOSTS"), allowed_hosts); 
    218 //  
    219 //    std::wstring password = Settings::getInstance()->getString(MAIN_SECTION_TITLE, MAIN_SETTINGS_PWD, MAIN_SETTINGS_PWD_DEFAULT); 
    220 //    h.setMyProperty(_T("NSCLIENT_PWD"), password); 
    221  
    222     int found_common_checks = 0; 
    223 //    settings_base::sectionList list = Settings::getInstance()->getSection(_T("modules")); 
    224 //    for (settings_base::sectionList::const_iterator cit=list.begin(); cit!=list.end();++cit) { 
    225 //      if (*cit == _T("NRPEListener.dll")) { 
    226 //        h.setMyProperty(_T("CONF_NRPE"), _T("1")); 
    227 //      } 
    228 //      if (*cit == _T("NSClientListener.dll")) { 
    229 //        h.setMyProperty(_T("CONF_NSCLIENT"), _T("1")); 
    230 //      } 
    231 //      if (*cit == _T("NSCAAgent.dll")) { 
    232 //        h.setMyProperty(_T("CONF_NSCA"), _T("1")); 
    233 //      } 
    234 //      if (*cit == _T("CheckWMI.dll")) { 
    235 //        h.setMyProperty(_T("CONF_WMI"), _T("1")); 
    236 //      } 
    237 //      if ( 
    238 //        (*cit == _T("FileLogger.dll")) || 
    239 //        (*cit == _T("CheckSystem.dll")) || 
    240 //        (*cit == _T("CheckDisk.dll")) || 
    241 //        (*cit == _T("CheckEventLog.dll")) || 
    242 //        (*cit == _T("CheckHelpers.dll")) 
    243 //        ) { 
    244 //        found_common_checks++; 
    245 //      } 
    246 //    } 
    247 //    if (found_common_checks == 5) { 
    248 //      h.setMyProperty(_T("CONF_CHECKS"), _T("1")); 
    249 //      h.setProperty(_T("CONF_CHECKS_GRAY"), _T("")); 
    250 //    } else if (found_common_checks == 0) { 
    251 //      h.setMyProperty(_T("CONF_CHECKS"), _T("")); 
    252 //      h.setProperty(_T("CONF_CHECKS_GRAY"), _T("")); 
    253 //    } else { 
    254 //      h.setMyProperty(_T("CONF_CHECKS"), _T("1")); 
    255 //      h.setProperty(_T("CONF_CHECKS_GRAY"), _T("1")); 
    256 //    } 
    257 //    Settings::destroyInstance(); 
    258     h.setProperty(_T("CONF_OLD_NOT_FOUND"), _T("0")); 
     193    if (!file_helpers::checks::exists(target)) { 
     194      h.logMessage(_T("Target folder not found: ") + target); 
     195      h.setProperty(_T("CONF_CAN_CHANGE"), _T("1")); 
     196      h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 
     197      h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); 
     198      return ERROR_SUCCESS; 
     199    } 
     200 
     201    installer_settings_provider provider(h, target); 
     202    if (!settings_manager::init_settings(&provider, _T(""))) { 
     203      h.setProperty(_T("CONF_OLD_ERROR"), provider.get_error()); 
     204      h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 
     205      h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 
     206      h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 
     207      return ERROR_SUCCESS; 
     208    } 
     209    if (provider.has_error()) { 
     210      h.setProperty(_T("CONF_OLD_ERROR"), provider.get_error()); 
     211      h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 
     212      h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 
     213      h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 
     214      return ERROR_SUCCESS; 
     215    } 
     216    h.setProperty(_T("CONFIGURATION_TYPE"), settings_manager::get_settings()->get_context()); 
     217    h.setProperty(_T("CONF_CAN_CHANGE"), _T("1")); 
     218    h.setProperty(_T("CONF_OLD_FOUND"), _T("1")); 
     219    h.setProperty(_T("CONF_HAS_ERRORS"), _T("0")); 
     220 
     221    h.setPropertyAndOld(_T("ALLOWED_HOSTS"), settings_manager::get_settings()->get_string(_T("/settings/default/"), _T("allowed hosts"), _T(""))); 
     222    h.setPropertyAndOld(_T("NSCLIENT_PWD"), settings_manager::get_settings()->get_string(_T("/settings/default/"), _T("password"), _T(""))); 
     223 
     224    std::wstring modpath = _T("/modules"); 
     225    h.setPropertyAndOld(_T("CONF_NRPE"), has_key(modpath, _T("NRPEServer"))); 
     226    h.setPropertyAndOld(_T("CONF_SCHEDULER"), has_key(modpath, _T("Scheduler"))); 
     227    h.setPropertyAndOld(_T("CONF_NSCA"), has_key(modpath, _T("NSCAAgent"))); 
     228    h.setPropertyAndOld(_T("CONF_NSCLIENT"), has_key(modpath, _T("NSClientServer"))); 
     229    h.setPropertyAndOld(_T("CONF_WMI"), has_key(modpath, _T("CheckWMI"))); 
     230 
     231    if (settings_manager::get_settings()->has_key(modpath, _T("CheckSystem")) && 
     232      settings_manager::get_settings()->has_key(modpath, _T("CheckDisk")) && 
     233      settings_manager::get_settings()->has_key(modpath, _T("CheckEventLog")) && 
     234      settings_manager::get_settings()->has_key(modpath, _T("CheckHelpers")) && 
     235      settings_manager::get_settings()->has_key(modpath, _T("CheckExternalScripts")) && 
     236      settings_manager::get_settings()->has_key(modpath, _T("CheckNSCP")) 
     237      ) { 
     238        h.setPropertyAndOld(_T("CONF_CHECKS"), _T("1")); 
     239    } else { 
     240      h.setPropertyAndOld(_T("CONF_CHECKS"), _T("0")); 
     241    } 
     242    settings_manager::destroy_settings(); 
     243 
    259244  } catch (installer_exception e) { 
    260     h.errorMessage(_T("Failed to read old configuration file: ") + e.what()); 
    261     h.setProperty(_T("INSCON_CONFIGURE"),_T("0")); 
    262     h.setProperty(_T("CONF_CAN_WRITE"), _T("0")); 
    263     return ERROR_INSTALL_FAILURE; 
    264 //  } catch (SettingsException e) { 
    265 //    h.errorMessage(_T("Failed to read old configuration file: ") + e.getMessage()); 
    266 //    h.setProperty(_T("INSCON_CONFIGURE"),_T("0")); 
    267 //    h.setProperty(_T("CONF_CAN_WRITE"), _T("0")); 
    268 //    return ERROR_SUCCESS; 
     245    h.logMessage(_T("Failed to read old configuration file: ") + e.what()); 
     246    h.setProperty(_T("CONF_OLD_ERROR"), e.what()); 
     247    h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 
     248    h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 
     249    h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 
     250    return ERROR_SUCCESS; 
    269251  } catch (...) { 
    270     h.errorMessage(_T("Failed to read old configuration file: <UNKNOWN EXCEPTION>")); 
    271     h.setProperty(_T("INSCON_CONFIGURE"),_T("0")); 
    272     h.setProperty(_T("CONF_CAN_WRITE"), _T("0")); 
    273     return ERROR_INSTALL_FAILURE; 
     252    h.logMessage(_T("Failed to read old configuration file: Unknown exception")); 
     253    h.setProperty(_T("CONF_OLD_ERROR"), _T("Unknown exception!")); 
     254    h.setProperty(_T("CONF_CAN_CHANGE"), _T("0")); 
     255    h.setProperty(_T("CONF_OLD_FOUND"), _T("0")); 
     256    h.setProperty(_T("CONF_HAS_ERRORS"), _T("1")); 
     257    return ERROR_SUCCESS; 
    274258  } 
    275259  return ERROR_SUCCESS; 
    276260} 
    277261 
    278  
    279 bool install(msi_helper &h, std::wstring exe, std::wstring service_short_name, std::wstring service_long_name, std::wstring service_desc, std::wstring service_deps) { 
    280   h.updateProgress(_T("Preparing to install service"), service_short_name); 
    281   try { 
    282     if (serviceControll::isStarted(service_short_name)) { 
    283       h.updateProgress(_T("Stopping service"), service_short_name); 
    284       serviceControll::Stop(service_short_name); 
    285     } 
    286     if (serviceControll::isInstalled(service_short_name)) { 
    287       h.updateProgress(_T("Uninstalling service"), service_short_name); 
    288       serviceControll::Uninstall(service_short_name); 
    289     } 
    290     h.updateProgress(_T("Installing service"), service_short_name); 
    291     serviceControll::Install(service_short_name, service_long_name, service_deps, SERVICE_WIN32_OWN_PROCESS, exe); 
    292   } catch (const serviceControll::SCException& e) { 
    293     h.errorMessage(_T("Failed to install service: ") + e.error_); 
    294     return false; 
    295   } 
    296   try { 
    297     serviceControll::SetDescription(service_short_name, service_desc); 
    298   } catch (const serviceControll::SCException& e) { 
    299     h.errorMessage(_T("Failed to set description of service: ") + e.error_); 
    300   } 
    301   return true; 
    302 } 
    303  
    304 bool uninstall(msi_helper &h, std::wstring service_name) { 
    305   h.updateProgress(_T("Preparing to uninstall service"), service_name); 
    306   try { 
    307     if (!serviceControll::isInstalled(service_name)) 
    308       return true; 
    309     if (serviceControll::isStarted(service_name)) { 
    310       h.updateProgress(_T("Stopping service"), service_name); 
    311       serviceControll::Stop(service_name); 
    312     } 
    313     h.updateProgress(_T("Uninstalling service"), service_name); 
    314     serviceControll::Uninstall(service_name); 
    315   } catch (const serviceControll::SCException& e) { 
    316     h.errorMessage(_T("Failed to uninstall service: ") + e.error_); 
    317     return false; 
    318   } 
    319   return true; 
    320 } 
    321262 
    322263///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    323264bool write_config(msi_helper &h, std::wstring path, std::wstring file); 
     265 
     266 
     267void write_changed_key(msi_helper &h, msi_helper::custom_action_data_w &data, std::wstring prop, std::wstring path, std::wstring key, std::wstring val = _T("")) { 
     268  data.write_int(h.propertyTouched(prop)?1:2); 
     269  data.write_string(path); 
     270  data.write_string(key); 
     271  if (val.empty()) 
     272    data.write_string(h.getPropery(prop)); 
     273  else 
     274    data.write_string(val); 
     275} 
     276 
     277void write_key(msi_helper::custom_action_data_w &data, int mode, std::wstring path, std::wstring key, std::wstring val) { 
     278  data.write_int(mode); 
     279  data.write_string(path); 
     280  data.write_string(key); 
     281  data.write_string(val); 
     282} 
    324283 
    325284extern "C" UINT __stdcall ScheduleWriteConfig (MSIHANDLE hInstall) { 
    326285  msi_helper h(hInstall, _T("ScheduleWriteConfig")); 
    327286  try { 
    328     std::wstring target = h.getTargetPath(_T("INSTALLLOCATION")); 
    329     std::wstring main_conf = h.getPropery(_T("MAIN_CONFIGURATION_FILE")); 
    330     std::wstring custom_conf = h.getPropery(_T("CUSTOM_CONFIGURATION_FILE")); 
    331  
    332     std::wstring write = target + _T("\\") + custom_conf; 
    333     h.logMessage(_T("config file (update): ") + write); 
    334  
    335     if (h.getPropery(_T("CONF_CAN_WRITE")) == _T("1")) { 
    336       if (h.getPropery(_T("KEEP_WHICH_CONFIG")) == _T("OLD")) { 
    337         CopyFile((target + _T("\\nsc.ini")).c_str(), (target + _T("\\nsc.new")).c_str(), FALSE); 
    338         CopyFile((h.getTempPath() + _T("\\old_nsc.ini")).c_str(), (target + _T("\\nsc.ini")).c_str(), FALSE); 
    339       } else { 
    340         CopyFile((h.getTempPath() + _T("\\old_nsc.ini")).c_str(), (target + _T("\\nsc.old")).c_str(), FALSE); 
    341       } 
    342     } 
    343     if (h.getPropery(_T("KEEP_WHICH_CONFIG")) == _T("NEW")) { 
    344       if (!write_config(h, target, custom_conf)) { 
    345         h.logMessage(_T("Failed to write configuration")); 
    346         return ERROR_INSTALL_FAILURE; 
     287    if (h.getPropery(_T("CONF_CAN_CHANGE")) != _T("1")) { 
     288      return ERROR_SUCCESS; 
     289    } 
     290    msi_helper::custom_action_data_w data; 
     291    data.write_string(h.getTargetPath(_T("INSTALLLOCATION"))); 
     292    data.write_string(h.getPropery(_T("CONFIGURATION_TYPE"))); 
     293    data.write_int(h.getPropery(_T("ADD_DEFAULTS"))==_T("1")?1:0); 
     294 
     295    std::wstring modpath = _T("/modules"); 
     296    std::wstring modval = _T(""); 
     297    write_changed_key(h, data, _T("CONF_NRPE"), modpath, _T("NRPEServer"), modval); 
     298    write_changed_key(h, data, _T("CONF_SCHEDULER"), modpath, _T("Scheduler"), modval); 
     299    write_changed_key(h, data, _T("CONF_NSCA"), modpath, _T("NSCAAgent"), modval); 
     300    write_changed_key(h, data, _T("CONF_NSCLIENT"), modpath, _T("NSClientServer"), modval); 
     301    write_changed_key(h, data, _T("CONF_WMI"), modpath, _T("CheckWMI"), modval); 
     302 
     303    if (h.propertyTouched(_T("CONF_CHECKS"))) { 
     304      write_key(data, 1, modpath, _T("CheckSystem"), modval); 
     305      write_key(data, 1, modpath, _T("CheckDisk"), modval); 
     306      write_key(data, 1, modpath, _T("CheckEventLog"), modval); 
     307      write_key(data, 1, modpath, _T("CheckHelpers"), modval); 
     308      write_key(data, 1, modpath, _T("CheckExternalScripts"), modval); 
     309      write_key(data, 1, modpath, _T("CheckNSCP"), modval); 
     310    } 
     311 
     312    std::wstring defpath = _T("/settings/default/"); 
     313    write_changed_key(h, data, _T("ALLOWED_HOSTS"), defpath, _T("allowed hosts")); 
     314    write_changed_key(h, data, _T("NSCLIENT_PWD"), defpath, _T("password")); 
     315 
     316    if (data.has_data()) { 
     317      h.logMessage(_T("Scheduling (ExecWriteConfig): ") + data.to_string()); 
     318      HRESULT hr = h.do_deferred_action(L"ExecWriteConfig", data, 1000); 
     319      if (FAILED(hr)) { 
     320        h.errorMessage(_T("failed to schedule config update")); 
     321        return hr; 
    347322      } 
    348323    } 
     
    362337    msi_helper::custom_action_data_r data(h.getPropery(L"CustomActionData")); 
    363338    h.logMessage(_T("Got CA data: ") + data.to_string()); 
    364     std::wstring path = data.get_next_string(); 
    365     std::wstring file = data.get_next_string(); 
    366 //    Settings::getInstance()->setFile(path, file, true); 
     339    std::wstring target = data.get_next_string(); 
     340    std::wstring context = data.get_next_string(); 
     341    int add_defaults = data.get_next_int(); 
     342 
     343    installer_settings_provider provider(h, target); 
     344    if (!settings_manager::init_settings(&provider, _T(""))) { 
     345      h.errorMessage(_T("Failed to boot settings: ") + provider.get_error()); 
     346      return ERROR_INSTALL_FAILURE; 
     347    } 
     348    settings_manager::change_context(context); 
    367349 
    368350    while (data.has_more()) { 
    369351      unsigned int mode = data.get_next_int(); 
     352      std::wstring path = data.get_next_string(); 
     353      std::wstring key = data.get_next_string(); 
     354      std::wstring val = data.get_next_string(); 
     355 
    370356      if (mode == 1) { 
    371       // loop through all the passed in data 
    372         std::wstring path = data.get_next_string(); 
    373         std::wstring key = data.get_next_string(); 
    374         std::wstring prop = data.get_next_string(); 
    375         h.logMessage(_T("Writing to config file: ") + path + _T("/") + key + _T(" = ") + prop); 
    376 //        Settings::getInstance()->setString(path, key, prop); 
    377         //TODO write config 
     357        h.logMessage(_T("Set key: ") + path + _T("/") + key + _T(" = ") + val); 
     358        settings_manager::get_settings()->set_string(path, key, val); 
    378359      } else if (mode == 2) { 
    379         std::list<std::wstring> list = data.get_next_list(); 
    380         h.logMessage(_T("Writing modules section: ") + strEx::itos(list.size())); 
    381 //        Settings::getInstance()->writeSection(_T("modules"), list); 
     360        h.logMessage(_T("***UNSUPPORTED*** Remove key: ") + path + _T("/") + key + _T(" = ") + val); 
    382361      } else { 
    383362        h.errorMessage(_T("Unknown mode in CA data: ") + strEx::itos(mode) + _T(": ") + data.to_string()); 
     
    385364      } 
    386365    } 
    387 //    Settings::getInstance()->write(); 
    388 //  } catch (SettingsException e) { 
    389 //    h.errorMessage(_T("Failed to write configuration file: ") + e.getMessage()); 
    390 //    return ERROR_SUCCESS; 
     366    settings_manager::get_settings()->save(); 
    391367  } catch (installer_exception e) { 
    392     h.errorMessage(_T("Failed to install service: ") + e.what()); 
     368    h.errorMessage(_T("Failed to write configuration: ") + e.what()); 
    393369    return ERROR_INSTALL_FAILURE; 
    394370  } catch (...) { 
    395     h.errorMessage(_T("Failed to install service: <UNKNOWN EXCEPTION>")); 
     371    h.errorMessage(_T("Failed to write configuration: <UNKNOWN EXCEPTION>")); 
    396372    return ERROR_INSTALL_FAILURE; 
    397373  } 
     
    399375} 
    400376 
    401 inline void write_string_item_if_changed(msi_helper &h, msi_helper::custom_action_data_w &data, std::wstring property, std::wstring path, std::wstring key) { 
    402   if (h.isChangedProperyAndOld(property)) { 
    403     data.write_int(1); 
    404     data.write_string(path); 
    405     data.write_string(key); 
    406     data.write_string(h.getPropery(property)); 
    407   } else 
    408     h.logMessage(property + _T(" was not changed...")); 
    409 } 
    410 bool write_config(msi_helper &h, std::wstring path, std::wstring file) { 
    411   std::wstring t; 
    412   msi_helper::custom_action_data_w data; 
    413  
    414   data.write_string(path); 
    415   data.write_string(file); 
    416  
    417   //cd_prop.write_int(1); 
    418   if (h.getPropery(_T("CONF_CAN_WRITE")) != _T("1")) { 
    419     h.updateProgress(_T("File is not writable (writing to registry not supported)"), file); 
    420     return true; 
    421   } 
    422  
    423   //Settings::getInstance()->setFile(path, file, true); 
    424 //  write_string_item_if_changed(h, data, _T("ALLOWED_HOSTS"), MAIN_SECTION_TITLE, MAIN_ALLOWED_HOSTS); 
    425 //  write_string_item_if_changed(h, data, _T("NSCLIENT_PWD"), MAIN_SECTION_TITLE, MAIN_SETTINGS_PWD); 
    426  
    427 //  settings_base::sectionList list; 
    428 //  if (h.isChangedProperyAndOld(_T("CONF_NRPE"))) 
    429 //    list.push_back(_T("NRPEListener.dll")); 
    430 //  if (h.isChangedProperyAndOld(_T("CONF_NSCLIENT"))) 
    431 //    list.push_back(_T("NSClientListener.dll")); 
    432 //  if (h.isChangedProperyAndOld(_T("CONF_NSCA"))) 
    433 //    list.push_back(_T("NSCAAgent.dll")); 
    434 //  if (h.isChangedProperyAndOld(_T("CONF_WMI"))) 
    435 //    list.push_back(_T("CheckWMI.dll")); 
    436 //  if (h.isChangedProperyAndOld(_T("CONF_CHECKS"))) { 
    437 //    list.push_back(_T("FileLogger.dll")); 
    438 //    list.push_back(_T("CheckSystem.dll")); 
    439 //    list.push_back(_T("CheckDisk.dll")); 
    440 //    list.push_back(_T("CheckEventLog.dll")); 
    441 //    list.push_back(_T("CheckHelpers.dll")); 
    442 //  } 
    443 //  if (list.size() > 0) { 
    444 //    data.write_int(2); 
    445 //    data.write_list(list); 
    446 //  } 
    447   if (data.has_data()) { 
    448     h.logMessage(_T("Scheduling (ExecWriteConfig): ") + data.to_string()); 
    449     HRESULT hr = h.do_deferred_action(L"ExecWriteConfig", data, 1000); 
    450     if (FAILED(hr)) { 
    451       h.errorMessage(_T("failed to schedule config update")); 
    452       return hr; 
    453     } 
    454   } 
    455 } 
    456  
    457  
    458 bool start(msi_helper &h, std::wstring service_name) { 
    459   if (!serviceControll::isInstalled(service_name)) { 
    460     h.logMessage(_T("Service was not installed (so we cannot start it): ")+ service_name); 
    461     return false; 
    462   } 
    463  
    464   h.updateProgress(_T("Preparing to start service"), service_name); 
    465   try { 
    466     if (!serviceControll::isStarted(service_name)) { 
    467       h.updateProgress(_T("Starting service"), service_name); 
    468       serviceControll::Start(service_name); 
    469     } 
    470   } catch (const serviceControll::SCException& e) { 
    471     h.errorMessage(_T("Failed to start service: ") + e.error_); 
    472     return false; 
    473   } 
    474   return true; 
    475 } 
    476  
    477 bool stop(msi_helper &h, std::wstring service_name) { 
    478   h.updateProgress(_T("Preparing to stopp service"), service_name); 
    479   try { 
    480     if (serviceControll::isStarted(service_name)) { 
    481       h.updateProgress(_T("Stopping service"), service_name); 
    482       serviceControll::Stop(service_name); 
    483     } 
    484   } catch (const serviceControll::SCException& e) { 
    485     h.errorMessage(_T("Failed to stop service: ") + e.error_); 
    486     return false; 
    487   } 
    488   return true; 
    489 } 
    490  
    491  
    492 //#pragma comment(linker, "/EXPORT:UpdateConfig=_UpdateConfig@4") 
    493  
    494 extern "C" UINT __stdcall StartAllServices (MSIHANDLE hInstall) { 
    495   msi_helper h(hInstall, _T("StartService")); 
    496   try { 
    497     std::wstring val = h.getPropery(_T("START_SERVICE_ON_EXIT")); 
    498     if (val == _T("1")) { 
    499       // anything to do? 
    500       if (h.table_exists(L"Services")) { 
    501         PMSIHANDLE hView = h.open_execute_view(vcsServiceQuery); 
    502         if (h.isNull(hView)) { 
    503           h.logMessage(_T("Failed to query service view!")); 
    504           return ERROR_INSTALL_FAILURE; 
    505         } 
    506  
    507         msi_helper::custom_action_data_w custom_data; 
    508         PMSIHANDLE hRec = h.fetch_record(hView); 
    509         while (hRec != NULL) 
    510         { 
    511           std::wstring shortname = h.get_record_formatted_string(hRec, feqShortName); 
    512           std::wstring component = h.get_record_string(hRec, feqComponent); 
    513  
    514           // figure out what we're doing for this exception, treating reinstall the same as install 
    515           msi_helper::WCA_TODO todoComponent = h.get_component_todo(component); 
    516           if ((msi_helper::WCA_TODO_REINSTALL == todoComponent ? msi_helper::WCA_TODO_INSTALL : todoComponent) != msi_helper::WCA_TODO_INSTALL) { 
    517             h.logMessage(_T("Component '") + component + _T("' action state (") + strEx::itos(todoComponent) + _T(") doesn't match request (") + strEx::itos(msi_helper::WCA_TODO_INSTALL) + _T(")")); 
    518             hRec = h.fetch_record(hView); 
    519             continue; 
    520           } 
    521           try { 
    522             if (!serviceControll::isStarted(shortname)) { 
    523               h.updateProgress(_T("Starting service"), shortname); 
    524               serviceControll::Start(shortname); 
    525             } 
    526           } catch (const serviceControll::SCException& e) { 
    527             h.logMessage(_T("Failed to start service: ") + shortname + _T(": ") + e.error_); 
    528           } 
    529           hRec = h.fetch_record(hView); 
    530         } 
    531       } 
    532     } 
    533     val = h.getPropery(_T("DONATE_ON_EXIT")); 
    534     if (val == _T("1")) { 
    535       long r = (long)ShellExecute(NULL, _T("open"), _T("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=michael@medin.name&item_name=Fans+of+NSClient%2B%2B&item_number=Installer+Campaign&amount=10%2e00&currency_code=EUR&return=http%3A//nsclient.org"), NULL, NULL, SW_SHOWNORMAL); 
    536       if (r > 32) 
    537         return ERROR_SUCCESS; 
    538       h.errorMessage(_T("Failed to start web browser for donations...")); 
    539       return ERROR_INSTALL_FAILURE; 
    540     } 
    541   } catch (installer_exception e) { 
    542     h.errorMessage(_T("Failed to process finalizing stuff: ") + e.what()); 
    543     return ERROR_INSTALL_FAILURE; 
    544   } catch (...) { 
    545     h.errorMessage(_T("Failed to process finalizing stuff: <UNKNOWN EXCEPTION>")); 
    546     return ERROR_INSTALL_FAILURE; 
    547   } 
    548   return ERROR_SUCCESS; 
    549 } 
    550  
    551  
    552 extern "C" UINT __stdcall StopAllServices (MSIHANDLE hInstall) { 
    553   msi_helper h(hInstall, _T("StopAllServices")); 
    554   try { 
    555  
    556     // anything to do? 
    557     if (!h.table_exists(L"Services")) { 
    558       h.logMessage(_T("Services table doesn't exist, so there are no services to configure.")); 
    559       return ERROR_SUCCESS; 
    560     } 
    561  
    562     // query and loop through all the firewall exceptions 
    563     PMSIHANDLE hView = h.open_execute_view(vcsServiceQuery); 
    564     if (h.isNull(hView)) { 
    565       h.logMessage(_T("Failed to query service view!")); 
    566       return ERROR_INSTALL_FAILURE; 
    567     } 
    568  
    569     msi_helper::custom_action_data_w custom_data; 
    570     PMSIHANDLE hRec = h.fetch_record(hView); 
    571     while (hRec != NULL) 
    572     { 
    573       std::wstring shortname = h.get_record_formatted_string(hRec, feqShortName); 
    574       std::wstring component = h.get_record_string(hRec, feqComponent); 
    575  
    576       // figure out what we're doing for this exception, treating reinstall the same as install 
    577       msi_helper::WCA_TODO todoComponent = h.get_component_todo(component); 
    578       if (todoComponent == msi_helper::WCA_TODO_REINSTALL) 
    579         todoComponent = msi_helper::WCA_TODO_INSTALL; 
    580       h.logMessage(_T("Component '") + component + _T("' action state (") + strEx::itos(todoComponent)); 
    581       if (todoComponent != msi_helper::WCA_TODO_INSTALL && todoComponent != msi_helper::WCA_TODO_UNINSTALL) { 
    582         h.logMessage(_T("Component '") + component + _T("' action state (") + strEx::itos(todoComponent) + _T(") doesn't match request (IN/UN/RE)")); 
    583         hRec = h.fetch_record(hView); 
    584         continue; 
    585       } 
    586       try { 
    587         if (serviceControll::isStarted(shortname)) { 
    588           h.updateProgress(_T("Stopping service"), shortname); 
    589           serviceControll::Stop(shortname); 
    590         } 
    591       } catch (const serviceControll::SCException& e) { 
    592         h.logMessage(_T("Failed to stop service: ") + shortname + _T(": ") + e.error_); 
    593       } 
    594       hRec = h.fetch_record(hView); 
    595     } 
    596   } catch (installer_exception e) { 
    597     h.errorMessage(_T("Failed to stop service: ") + e.what()); 
    598     return ERROR_INSTALL_FAILURE; 
    599   } catch (...) { 
    600     h.errorMessage(_T("Failed to stop service: <UNKNOWN EXCEPTION>")); 
    601     return ERROR_INSTALL_FAILURE; 
    602   } 
    603   return ERROR_SUCCESS; 
    604 } 
     377 
    605378 
    606379extern "C" UINT __stdcall NeedUninstall (MSIHANDLE hInstall) { 
  • helpers/installer-dlls/main_dll/main_dll.def

    r197b263 rb7d17f8  
    55  ScheduleWriteConfig 
    66  ExecWriteConfig 
    7   StartAllServices 
    8   StopAllServices 
    9   ScheduleInstallService 
    10   ScheduleUnInstallService 
    11   ExecServiceInstall 
    127  NeedUninstall 
  • helpers/installers/installer/CMakeLists.txt

    r7443b58 rb7d17f8  
    77SET(SRCS 
    88  Product.wxs 
    9   WixUI.wixlib 
     9 
     10  ../ui/ConfigureDlg.wxs 
     11  ../ui/InvalidConfigureationDlg.wxs 
     12  ../ui/SelectConfigurationDlg.wxs 
     13  ../ui/WixUI_MondoNSCP.wxs 
    1014) 
     15# WixUI.wixlib 
    1116SET(DEPENDENCIES 
    1217  nscp 
     18  main_dll 
    1319) 
    14 GET_FILENAME_COMPONENT(_tmp_FILE WixUI_en-us.wxl ABSOLUTE) 
     20#GET_FILENAME_COMPONENT(_tmp_FILE WixUI_en-us.wxl ABSOLUTE) 
    1521 
    1622SET(LOCALIZATIONS 
    17   ${_tmp_FILE} 
     23  en-us 
    1824) 
    1925 
  • helpers/installers/installer/Product.wxs

    rc391984 rb7d17f8  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi"> 
    3   <?define PlatForm = "$(var.arch)" ?> 
    4   <?define Mode = "Nightly" ?> 
    5   <?define SysTray.ConfigurationName = "BOOST BUILD" ?> 
    6  
    7   <?if "$(var.PlatForm)" = "x64"?> 
    8     <?define PlatForm.x64 ?> 
     2<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:fire="http://schemas.microsoft.com/wix/FirewallExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 
     3 
     4  <?if "$(var.arch)" = "x64"?> 
    95    <?define Postfix.GUID = "DD5862EE637C" ?> 
     6    <?define ProgramFiles = "ProgramFiles64Folder" ?> 
     7    <?define Win64 = "yes" ?> 
     8    <?define Plattform = "x64" ?> 
    109  <?else?> 
    1110    <?define Postfix.GUID = "DD5862EE637B" ?> 
    12     <?define PlatForm.Win32 ?> 
    13   <?endif?> 
    14    
    15   <?ifdef var.PlatForm.Win32?> 
    1611    <?define ProgramFiles = "ProgramFilesFolder" ?> 
    1712    <?define Win64 = "no" ?> 
    1813    <?define Plattform = "Intel" ?> 
    19   <?else?> 
    20     <?define ProgramFiles = "ProgramFiles64Folder" ?> 
    21     <?define Win64 = "yes" ?> 
    22     <?define Plattform = "x64" ?> 
    23   <?endif?> 
    24   <?ifndef var.Source ?> 
    25     <?define Source = "../../$(var.PlatForm)/$(var.Mode)/" ?> 
    2614  <?endif?> 
    2715 
    2816  <?define Version.String = "$(var.Version.Major).$(var.Version.Minor).$(var.Version.Revision).$(var.Version.Build)" ?> 
    2917  <?define UpgradeCode = "0B36E3B7-0042-452d-B376-57E0C07ADDAA" ?> 
     18   
    3019  <?include config.wxs ?> 
    3120 
    32   <Product Id="????????-????-????-????-????????????" Name="$(var.App.Title) ($(var.PlatForm))" Language="1033" Version="$(var.Version.String)" Manufacturer="MySolutions NORDIC" 
    33           UpgradeCode="$(var.UpgradeCode)"> 
    34  
    35     <Package Id="????????-????-????-????-????????????" Description="A simple windows monitor agent for (amongst others) Nagios." 
    36              Comments="This will appear in the file summary stream." InstallerVersion="200" Compressed="yes" Languages="1033" Platforms="$(var.Plattform)" /> 
     21  <Product Id="*" Name="$(var.App.Title) ($(var.arch))" Language="1033" Version="$(var.Version.String)" Manufacturer="MySolutions NORDIC" UpgradeCode="$(var.UpgradeCode)"> 
     22 
     23    <Package Id="*" Description="A simple windows monitor agent for (amongst others) Nagios." 
     24             Comments="This will appear in the file summary stream." InstallerVersion="200" Compressed="yes" Languages="1033" Platform="$(var.Plattform)" /> 
    3725 
    3826    <Upgrade Id="$(var.UpgradeCode)"> 
    39       <UpgradeVersion Property="OLDAPPFOUND" IncludeMinimum="yes" Minimum="0.3.0.0" IncludeMaximum="yes" Maximum="$(var.Version.String)"/> 
     27      <UpgradeVersion Property="OLDAPPFOUND" IncludeMinimum="yes" Minimum="0.3.0.0" IncludeMaximum="no" Maximum="$(var.Version.String)"/> 
    4028      <UpgradeVersion Property="NEWAPPFOUND" IncludeMinimum="no" Minimum="$(var.Version.String)" OnlyDetect="yes"/> 
    4129    </Upgrade> 
    4230 
    43     <?ifdef var.PlatForm.Win32?> 
     31    <?if "$(var.arch)" = "x64"?> 
     32      <Condition Message="Win32 bit version not supported (by installer) on x64 bit platform (get x64 bit version instead)">VersionNT64</Condition> 
     33    <?else?> 
    4434      <Condition Message="x64 bit version not supported (by installer) on Win32 bit platform (get Win32 bit version instead)">NOT VersionNT64</Condition> 
    45     <?else?> 
    46       <Condition Message="Win32 bit version not supported (by installer) on x64 bit platform (get x64 bit version instead)">VersionNT64</Condition> 
    4735    <?endif?> 
    48     <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" CompressionLevel="high"> 
    49     </Media> 
     36    <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" CompressionLevel="high" /> 
    5037    <Directory Id="TARGETDIR" Name="SourceDir"> 
    5138      <Directory Id="$(var.ProgramFiles)"> 
    52           <Directory Id="INSTALLLOCATION" Name="$(var.App.ShortPath)" LongName="$(var.App.Path)"> 
    53             <Component Id="MainClient" Guid="F6636DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    54               <File Id="NSClientEXE" Name="nscp.exe" LongName="nscp.exe" DiskId="1" 
    55                     Source="$(var.Source)/nscp.exe" Vital="yes"> 
    56                 <Shortcut Id="StartmenuNSClientTest" Directory="ProgramMenuDir" Name="NSCPTest" 
    57                           LongName="$(var.App.Title) ($(var.PlatForm), test)" WorkingDirectory="INSTALLDIR" Icon="nscp.exe" 
    58                           IconIndex="0" Arguments="/test" Description="Run $(var.App.Title) in test mode"/> 
    59                 <Shortcut Id="StartmenuNSClientStart" Directory="ProgramMenuDir" Name="NSCPStrt" 
    60                           LongName="Start $(var.App.Title) ($(var.PlatForm))" WorkingDirectory='INSTALLDIR' Icon="nscp.exe" 
    61                           IconIndex="0" Arguments="/start" Description="Start the $(var.App.Title) service"/> 
    62                 <Shortcut Id="StartmenuNSClientStop" Directory="ProgramMenuDir" Name="NSCPStop" 
    63                           LongName="Stop $(var.App.Title) ($(var.PlatForm))" WorkingDirectory='INSTALLDIR' Icon="nscp.exe" 
    64                           IconIndex="0" Arguments="/stop" Description="Stop the $(var.App.Title) service"/> 
    65                 <Shortcut Id="StarmentNSCHelp" Target="[HELP_LINK]" Icon="doc.ico" Directory="ProgramMenuDir" Name="Help" LongName="Documentation" Description="Visit the NSClient++ WIKI for documentation"> 
    66                   <Icon Id="doc.ico" SourceFile="help.ico"/> 
    67                 </Shortcut> 
    68               </File> 
     39        <Directory Id="INSTALLLOCATION" Name="$(var.App.Path)"> 
     40          <Component Id="MainClient" Guid="F6636DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     41            <File Id="NSClientEXE" Name="nscp.exe" DiskId="1" KeyPath="yes" 
     42                Source="$(var.Source)/nscp.exe" Vital="yes"> 
     43              <Shortcut Id="StartmenuNSClientTest" Directory="ProgramMenuDir" 
     44                Name="$(var.App.Title) ($(var.arch), test)" WorkingDirectory="INSTALLDIR" Icon="nscp.exe" 
     45                Advertise="yes" IconIndex="0" Arguments="--test" Description="Run $(var.App.Title) in test mode" /> 
     46              <fire:FirewallException Id="FWX1" Name="NSClient++ Monitoring Agent" Scope="any" IgnoreFailure="yes" /> 
     47            </File> 
     48            <ServiceInstall Id="SWCNSCP" 
     49              Name="[SERVICE_NAME]" DisplayName="$(var.App.Title) ($(var.arch))" 
     50              Type="ownProcess" Start="auto" ErrorControl="normal" Interactive="no" 
     51              Description="Monitoring agent for nagios (and others) used to respond to status queries" 
     52              Arguments="--service --run --name [SERVICE_NAME]" /> 
     53            <ServiceControl Id="StartSWCNSCP" Name="[SERVICE_NAME]" Start="install" Wait="no" /> 
     54            <ServiceControl Id="StopSWCNSCP" Name="[SERVICE_NAME]" Stop="both" Wait="yes" Remove="uninstall" /> 
     55            <RemoveFolder Id="RemoveMenuShortcuts" Directory="ProgramMenuDir" On="uninstall" /> 
     56          </Component> 
     57          <Component Id="Shortcuts" Guid="E6636DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     58            <Shortcut Id="StartmenuNSClientStart" Directory="ProgramMenuDir" Name="Start $(var.App.Title) ($(var.arch))" 
     59                  WorkingDirectory='INSTALLDIR' Icon="nscp.exe" IconIndex="0" 
     60                  Arguments="--service --name [SERVICE_NAME] --start" Description="Start the $(var.App.Title) service" /> 
     61            <Shortcut Id="StartmenuNSClientStop" Directory="ProgramMenuDir" Name="Stop $(var.App.Title) ($(var.arch))" 
     62                  WorkingDirectory='INSTALLDIR' Icon="nscp.exe" IconIndex="0" 
     63                  Arguments="--service --name [SERVICE_NAME] --stop" Description="Stop the $(var.App.Title) service" /> 
     64            <Shortcut Id="StarmentNSCHelp" Directory="ProgramMenuDir" Name="Documentation" 
     65                  Target="[HELP_LINK]" Icon="doc.ico" 
     66                  Description="Visit the NSClient++ WIKI for documentation"> 
     67            </Shortcut> 
     68            <RegistryValue Root="HKCU" Key="Software\NSClient++\Installer" Name="shortcuts" Type="integer" Value="1" KeyPath="yes"/> 
     69          </Component> 
     70          <Component Id="Helpers" Guid="A6636DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     71            <!-- 
     72            <File Id="NSClientTRAY" Name="nstray.exe" DiskId="1" 
     73                Source="$(var.Source)/nstray.exe" Vital="yes"> 
     74              <Shortcut Id="StartmenuNSClientTray" Directory="ProgramMenuDir" Name="NSCPTray" 
     75                LongName="$(var.App.Title) ($(var.arch)) system tray)" WorkingDirectory="INSTALLDIR" Icon="nstray.exe" 
     76                IconIndex="0" Description="Start the $(var.App.Title) systemtray agent"/> 
     77            </File> 
     78            --> 
     79            <File Id="ErrorReporter" Name="reporter.exe" DiskId="1" Source="$(var.Source)/reporter.exe" Vital="yes" /> 
     80            <!-- 
     81              <File Id="NSClientINI" Name="NSC.ini" LongName="NSC.ini" DiskId="1" Source="$(var.Path.ini)/NSC.ini" Vital="yes"/> 
     82            --> 
     83          </Component> 
     84          <Component Id="RandomFiles" Guid="B4636DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     85            <File Id="Changelog" Name="changelog.txt" DiskId="1" Source="$(var.Source)/changelog" Vital="no" /> 
     86            <File Id="Counters" Name="counters.defs" DiskId="1" Source="$(var.Source)/counters.defs" Vital="no" /> 
     87            <File Id="License" Name="license.txt" DiskId="1" Source="$(var.Source)/license.txt" Vital="no" KeyPath="yes" /> 
     88            <File Id="settingsMap" Name="old-settings.map" DiskId="1" Source="$(var.Source)/old-settings.map" Vital="no" /> 
     89 
     90            <RemoveFile Id="LogFile1" Name="nsclient.log" On="uninstall" /> 
     91            <RemoveFile Id="LogFile2" Name="nsc.log" On="uninstall" /> 
     92            <RemoveFile Id="OldConfig" Name="nsc.old" On="uninstall" /> 
     93            <RemoveFile Id="NewConfig" Name="nsc.new" On="uninstall" /> 
     94          </Component> 
     95          <Component Id="NagiosDocumentation" Guid="9B490E67-5472-4267-889C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     96            <File Id="doc.usage.nagios" Name="Nagios Usage Guide.pdf" DiskId="1" Source="$(var.Source)/docs/Nagios Usage Guide.pdf" Vital="no" KeyPath="yes"> 
     97              <Shortcut Id="Startmenu.doc.nagios" Directory="ProgramMenuDir" Name="Nagios Usage Guide" Advertise="yes"  
     98                    WorkingDirectory="INSTALLDIR" Description="Nagios Usage Guide"/> 
     99            </File> 
     100          </Component> 
     101          <Component Id="ReferenceDocumentation" Guid="8B490E67-5472-4267-889C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     102            <File Id="doc.reference" Name="NSClient++ Reference Manual.pdf" DiskId="1" Source="$(var.Source)/docs/NSClient++ Reference Manual.pdf" Vital="no" KeyPath="yes"> 
     103              <Shortcut Id="Startmenu.doc.ref" Directory="ProgramMenuDir" Name="NSClient++ Reference Manual" Advertise="yes"  
     104                    WorkingDirectory="INSTALLDIR" Description="NSClient++ Reference Manual"/> 
     105            </File> 
     106          </Component> 
     107          <Directory Id="INSTALLLOCATION_SECURITY" Name="security"> 
     108            <Component Id="NRPEServerCert" Guid="5A0246F8-5167-45db-2E46-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     109              <File Id="NRPECert" Name="nrpe_dh_512.pem" DiskId="1" Source="$(var.Source)/security/nrpe_dh_512.pem" Vital="no"/> 
     110            </Component> 
     111          </Directory> 
     112          <Directory Id="INSTALLLOCATION_MODS" Name="modules"> 
     113            <Component Id="NRPEServer" Guid="5A0246F8-5167-45db-B246-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     114              <File Id="NRPEListenerDLL" Name="NRPEListener.dll" DiskId="1" Source="$(var.Source)/modules/NRPEServer.dll" Vital="no" /> 
     115              <File Id="NRPEClientDLL" Name="NRPEClient.dll" DiskId="1" Source="$(var.Source)/modules/NRPEClient.dll" Vital="no" /> 
     116            </Component> 
     117            <Component Id="NSCListener" Guid="6DAF8BB9-9A56-48f5-B2C5-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     118              <File Id="NSCListenerDLL" Name="NSClientListener.dll" DiskId="1" Source="$(var.Source)/modules/NSClientServer.dll" Vital="no" /> 
     119            </Component> 
     120            <Component Id="NSCA" Guid="8820A304-C596-4393-A72F-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     121              <File Id="NSCAAgentDLL" Name="NSCAAgent.dll" DiskId="1" Source="$(var.Source)/modules/NSCAAgent.dll" Vital="no" /> 
     122              <File Id="SchedulerDLL" Name="Scheduler.dll" DiskId="1" Source="$(var.Source)/modules/Scheduler.dll" Vital="no" /> 
     123            </Component> 
     124            <Component Id="Plugins" Guid="9B490E67-5472-4266-96DC-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     125              <!-- NOT PORTED MODULES ! 
     126                <File Id="ModRemoteConfiguration.dll" Name="RmtCfg.dll" LongName="RemoteConfiguration.dll" DiskId="1" Source="$(var.Source)/modules/RemoteConfiguration.dll" Vital="no" /> 
     127                <File Id="ModSysTray.dll" Name="SysTray.dll" LongName="SysTray.dll" DiskId="1" Source="$(var.Source)/modules/SysTray.dll" Vital="no" /> 
     128                <File Id="A_DebugLogMetrics.dll" Name="ADebug.dll" LongName="A_DebugLogMetrics.dll" DiskId="1" Source="$(var.Source)/modules/A_DebugLogMetrics.dll" Vital="no" /> 
     129              --> 
     130              <File Id="ModCheckEventLog.dll" Name="CheckEventLog.dll" DiskId="1" Source="$(var.Source)/modules/CheckEventLog.dll" Vital="no" /> 
     131              <File Id="ModCheckExternalScripts.dll" Name="CheckExternalScripts.dll" DiskId="1" Source="$(var.Source)/modules/CheckExternalScripts.dll" Vital="no" /> 
     132              <File Id="ModCheckHelpers.dll" Name="CheckHelpers.dll" DiskId="1" Source="$(var.Source)/modules/CheckHelpers.dll" Vital="no" /> 
     133              <File Id="ModCheckSystem.dll" Name="CheckSystem.dll" DiskId="1" Source="$(var.Source)/modules/CheckSystem.dll" Vital="no" /> 
     134              <File Id="ModCheckWMI.dll" Name="CheckWMI.dll" DiskId="1" Source="$(var.Source)/modules/CheckWMI.dll" Vital="no" /> 
     135              <File Id="ModFileLogger.dll" Name="FileLogger.dll" DiskId="1" Source="$(var.Source)/modules/FileLogger.dll" Vital="no" /> 
     136              <File Id="ModLUAScript.dll" Name="LUAScript.dll" DiskId="1" Source="$(var.Source)/modules/LUAScript.dll" Vital="no" /> 
     137              <File Id="ModCheckNSCP.dll" Name="CheckNSCP.dll" DiskId="1" Source="$(var.Source)/modules/CheckNSCP.dll" Vital="no" /> 
     138              <File Id="ModCheckDisk.dll" Name="CheckDisk.dll" DiskId="1" Source="$(var.Source)/modules/CheckDisk.dll" Vital="no" /> 
     139              <File Id="ModCheckTaskSched.dll" Name="CheckTaskSched.dll" DiskId="1" Source="$(var.Source)/modules/CheckTaskSched.dll" Vital="no" /> 
     140              <File Id="ModCheckTaskSched2.dll" Name="CheckTaskSched2.dll" DiskId="1" Source="$(var.Source)/modules/CheckTaskSched2.dll" Vital="no" /> 
     141            </Component> 
     142          </Directory> 
     143          <Directory Id="INSTALLLOCATION_SCRIPTS" Name="scripts"> 
     144            <Component Id="Scripts" Guid="9B490E67-5472-4268-96DF-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     145              <File Id="script001" Name="check_60s.bat" DiskId="1" Source="$(var.Source)/scripts/check_60s.bat" Vital="no" /> 
     146              <File Id="script002" Name="check_battery.vbs" DiskId="1" Source="$(var.Source)/scripts/check_battery.vbs" Vital="no" /> 
     147              <File Id="script003" Name="check_no_rdp.bat" DiskId="1" Source="$(var.Source)/scripts/check_no_rdp.bat" Vital="no" /> 
     148              <File Id="script004" Name="check_printer.vbs" DiskId="1" Source="$(var.Source)/scripts/check_printer.vbs" Vital="no" /> 
     149              <File Id="script005" Name="check_ok.bat" DiskId="1" Source="$(var.Source)/scripts/check_ok.bat" Vital="no" /> 
     150              <File Id="script006" Name="check_files.vbs" DiskId="1" Source="$(var.Source)/scripts/check_files.vbs" Vital="no" /> 
     151              <File Id="script007" Name="check_ping.bat" DiskId="1" Source="$(var.Source)/scripts/check_ping.bat" Vital="no" /> 
     152              <File Id="script008" Name="check_updates.vbs" DiskId="1" Source="$(var.Source)/scripts/check_updates.vbs" Vital="no" /> 
     153              <File Id="sample002" Name="check_test.ps1" DiskId="1" Source="$(var.Source)/scripts/check_test.ps1" Vital="no" /> 
     154              <File Id="sample003" Name="check_test.vbs" DiskId="1" Source="$(var.Source)/scripts/check_test.vbs" Vital="no" /> 
    69155              <!-- 
    70               <File Id="NSClientTRAY" Name="nstray.exe" DiskId="1" 
    71                     Source="$(var.Source)/nstray.exe" Vital="yes"> 
    72                 <Shortcut Id="StartmenuNSClientTray" Directory="ProgramMenuDir" Name="NSCPTray" 
    73                           LongName="$(var.App.Title) ($(var.PlatForm)) system tray)" WorkingDirectory="INSTALLDIR" Icon="nstray.exe" 
    74                           IconIndex="0" Description="Start the $(var.App.Title) systemtray agent"/> 
    75               </File> 
     156                Scripts missing 
     157              <File Id="lua001" Name="test.lua" LongName="test.lua" DiskId="1" Source="$(var.Source)/scripts/test.lua" Vital="no" /> 
    76158              --> 
    77               <File Id="NSClientErrorReporter" Name="reporter.exe" DiskId="1" Source="$(var.Source)/reporter.exe" Vital="yes" /> 
    78  
    79               <!-- 
    80               <File Id="NSClientINI" Name="NSC.ini" LongName="NSC.ini" DiskId="1" Source="$(var.Path.ini)/NSC.ini" Vital="yes"/> 
    81               --> 
    82               <File Id="Changelog" Name="change.log" LongName="changelog.txt" DiskId="1" Source="$(var.Source)/changelog" Vital="no"/> 
    83               <File Id="Counters" Name="counters.def" LongName="counters.defs" DiskId="1" Source="$(var.Source)/counters.defs" Vital="no"/> 
    84               <File Id="License" Name="license.txt" LongName="license.txt" DiskId="1" Source="$(var.Source)/license.txt" Vital="no"/> 
    85                
    86               <RemoveFile Id="LogFile1" Name="nsclient.log" On="uninstall" /> 
    87               <RemoveFile Id="LogFile2" Name="nsc.log" On="uninstall" /> 
    88               <RemoveFile Id="OldConfig" Name="nsc.old" On="uninstall" /> 
    89               <RemoveFile Id="NewConfig" Name="nsc.new" On="uninstall" /> 
    90             </Component> 
    91             <Component Id="FireWallException" Guid="F6636DB0-A0B9-4dA2-B75D-$(var.Postfix.GUID)" Win64="$(var.Win64)" /> 
    92             <Component Id="ServiceRegistration" Guid="F6636DB0-A0B9-4dA2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)" /> 
    93             <Component Id="Documentation" Guid="9B490E67-5472-4267-889C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    94               <File Id="doc.usage.nagios" Name="nagios.pdf" LongName="Nagios Usage Guide.pdf" DiskId="1" Source="$(var.Source)/docs/Nagios Usage Guide.pdf" Vital="no" > 
    95                 <Shortcut Id="Startmenu.doc.nagios" Directory="ProgramMenuDir" Name="nagios" 
    96                           LongName="Nagios Usage Guide" WorkingDirectory="INSTALLDIR" Description="Nagios Usage Guide"/> 
    97               </File> 
    98               <File Id="doc.reference" Name="nsclient.pdf" LongName="NSClient++ Reference Manual.pdf" DiskId="1" Source="$(var.Source)/docs/NSClient++ Reference Manual.pdf" Vital="no" > 
    99                 <Shortcut Id="Startmenu.doc.ref" Directory="ProgramMenuDir" Name="refman" 
    100                           LongName="NSClient++ Reference Manual" WorkingDirectory="INSTALLDIR" Description="NSClient++ Reference Manual"/> 
    101               </File> 
    102             </Component> 
    103             <Directory Id="INSTALLLOCATION_SECURITY" Name="security"> 
    104               <Component Id="NRPEServerCert" Guid="5A0246F8-5167-45db-2E46-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    105                 <File Id="NRPECert" Name="nrpe_dh.pem" LongName="nrpe_dh_512.pem" DiskId="1" Source="$(var.Source)/security/nrpe_dh_512.pem" Vital="no"/> 
     159            </Component> 
     160            <Directory Id="INSTALLLOCATION_SCRIPTS_LIB" Name="lib"> 
     161              <Component Id="ScriptLibs" Guid="9B490E67-5472-4267-96DF-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     162                <File Id="lib001" Name="NagiosPlugins.vbs" DiskId="1" Source="$(var.Source)/scripts/lib/NagiosPlugins.vbs" Vital="no" /> 
     163                <File Id="lib002" Name="wrapper.vbs" DiskId="1" Source="$(var.Source)/scripts/lib/wrapper.vbs" Vital="no" /> 
    106164              </Component> 
    107165            </Directory> 
    108             <Directory Id="INSTALLLOCATION_MODS" Name="modules"> 
    109               <Component Id="NRPEServer" Guid="5A0246F8-5167-45db-B246-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    110                 <File Id="NRPEListenerDLL" Name="NRPELsnr.dll" LongName="NRPEListener.dll" DiskId="1" Source="$(var.Source)/modules/NRPEServer.dll" Vital="no" /> 
    111                 <File Id="NRPEClientDLL" Name="NRPEClnt.dll" LongName="NRPEClient.dll" DiskId="1" Source="$(var.Source)/modules/NRPEClient.dll" Vital="no" /> 
    112               </Component> 
    113               <Component Id="NSCListener" Guid="6DAF8BB9-9A56-48f5-B2C5-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    114                 <File Id="NSCListenerDLL" Name="NSCLsnr.dll" LongName="NSClientListener.dll" DiskId="1" Source="$(var.Source)/modules/NSClientServer.dll" Vital="no" /> 
    115               </Component> 
    116               <Component Id="NSCA" Guid="8820A304-C596-4393-A72F-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    117                 <File Id="NSCAAgentDLL" Name="NSCAAgnt.dll" LongName="NSCAAgent.dll" DiskId="1" Source="$(var.Source)/modules/NSCAAgent.dll" Vital="no" /> 
    118                 <File Id="SchedulerDLL" Name="Sched.dll" LongName="Scheduler.dll" DiskId="1" Source="$(var.Source)/modules/Scheduler.dll" Vital="no" /> 
    119               </Component> 
    120               <Component Id="Plugins" Guid="9B490E67-5472-4266-96DC-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    121                            <!-- 
    122                 <File Id="A_DebugLogMetrics.dll" Name="ADebug.dll" LongName="A_DebugLogMetrics.dll" DiskId="1" Source="$(var.Source)/modules/A_DebugLogMetrics.dll" Vital="no" /> 
    123                             --> 
    124                 <File Id="ModCheckEventLog.dll" Name="EvntLg.dll" LongName="CheckEventLog.dll" DiskId="1" Source="$(var.Source)/modules/CheckEventLog.dll" Vital="no" /> 
    125                 <File Id="ModCheckExternalScripts.dll" Name="ExtScr.dll" LongName="CheckExternalScripts.dll" DiskId="1" Source="$(var.Source)/modules/CheckExternalScripts.dll" Vital="no" /> 
    126                 <File Id="ModCheckHelpers.dll" Name="Helpers.dll" LongName="CheckHelpers.dll" DiskId="1" Source="$(var.Source)/modules/CheckHelpers.dll" Vital="no" /> 
    127                 <File Id="ModCheckSystem.dll" Name="System.dll" LongName="CheckSystem.dll" DiskId="1" Source="$(var.Source)/modules/CheckSystem.dll" Vital="no" /> 
    128                 <File Id="ModCheckWMI.dll" Name="WMI.dll" LongName="CheckWMI.dll" DiskId="1" Source="$(var.Source)/modules/CheckWMI.dll" Vital="no" /> 
    129                 <File Id="ModFileLogger.dll" Name="Logger.dll" LongName="FileLogger.dll" DiskId="1" Source="$(var.Source)/modules/FileLogger.dll" Vital="no" /> 
    130                 <File Id="ModLUAScript.dll" Name="LUAScr.dll" LongName="LUAScript.dll" DiskId="1" Source="$(var.Source)/modules/LUAScript.dll" Vital="no" /> 
    131                 <File Id="ModCheckNSCP.dll" Name="CNSCP.dll" LongName="CheckNSCP.dll" DiskId="1" Source="$(var.Source)/modules/CheckNSCP.dll" Vital="no" /> 
    132                 <!-- 
    133                 <File Id="ModRemoteConfiguration.dll" Name="RmtCfg.dll" LongName="RemoteConfiguration.dll" DiskId="1" Source="$(var.Source)/modules/RemoteConfiguration.dll" Vital="no" /> 
    134                 <File Id="ModSysTray.dll" Name="SysTray.dll" LongName="SysTray.dll" DiskId="1" Source="$(var.Source)/modules/SysTray.dll" Vital="no" /> 
    135                             --> 
    136                 <File Id="ModCheckDisk.dll" Name="CheckDsk.dll" LongName="CheckDisk.dll" DiskId="1" Source="$(var.Source)/modules/CheckDisk.dll" Vital="no" /> 
    137                 <File Id="ModCheckTaskSched.dll" Name="TaskSch.dll" LongName="CheckTaskSched.dll" DiskId="1" Source="$(var.Source)/modules/CheckTaskSched.dll" Vital="no" /> 
    138                 <File Id="ModCheckTaskSched2.dll" Name="TaskSch2.dll" LongName="CheckTaskSched2.dll" DiskId="1" Source="$(var.Source)/modules/CheckTaskSched2.dll" Vital="no" /> 
    139               </Component> 
    140             </Directory> 
    141             <Directory Id="INSTALLLOCATION_SCRIPTS" Name="scripts"> 
    142               <Component Id="Scripts" Guid="9B490E67-5472-4268-96DF-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    143                 <File Id="script001" Name="c_60s.bat" LongName="check_60s.bat" DiskId="1" Source="$(var.Source)/scripts/check_60s.bat" Vital="no" /> 
    144                 <File Id="script002" Name="c_btry.vbs" LongName="check_battery.vbs" DiskId="1" Source="$(var.Source)/scripts/check_battery.vbs" Vital="no" /> 
    145                 <File Id="script003" Name="c_nrdb.bat" LongName="check_no_rdp.bat" DiskId="1" Source="$(var.Source)/scripts/check_no_rdp.bat" Vital="no" /> 
    146                 <File Id="script004" Name="c_prt.vbs" LongName="check_printer.vbs" DiskId="1" Source="$(var.Source)/scripts/check_printer.vbs" Vital="no" /> 
    147                 <File Id="script005" Name="c_ok.bat" LongName="check_ok.bat" DiskId="1" Source="$(var.Source)/scripts/check_ok.bat" Vital="no" /> 
    148                 <File Id="script006" Name="c_files.vbs" LongName="check_files.vbs" DiskId="1" Source="$(var.Source)/scripts/check_files.vbs" Vital="no" /> 
    149                 <File Id="script007" Name="c_ping.bat" LongName="check_ping.bat" DiskId="1" Source="$(var.Source)/scripts/check_ping.bat" Vital="no" /> 
    150                 <File Id="sample002" Name="c_test.ps1" LongName="check_test.ps1" DiskId="1" Source="$(var.Source)/scripts/check_test.ps1" Vital="no" /> 
    151                 <File Id="sample003" Name="c_test.vbs" LongName="check_test.vbs" DiskId="1" Source="$(var.Source)/scripts/check_test.vbs" Vital="no" /> 
    152           <!-- 
    153                 <File Id="lua001" Name="test.lua" LongName="test.lua" DiskId="1" Source="$(var.Source)/scripts/test.lua" Vital="no" /> 
    154         --> 
    155               </Component> 
    156               <Directory Id="INSTALLLOCATION_SCRIPTS_LIB" Name="lib"> 
    157                 <Component Id="ScriptLibs" Guid="9B490E67-5472-4267-96DF-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    158                   <File Id="lib001" Name="nagplug.vbs" LongName="NagiosPlugins.vbs" DiskId="1" Source="$(var.Source)/scripts/lib/NagiosPlugins.vbs" Vital="no" /> 
    159                   <File Id="lib002" Name="wrapper.vbs" LongName="wrapper.vbs" DiskId="1" Source="$(var.Source)/scripts/lib/wrapper.vbs" Vital="no" /> 
    160                 </Component> 
    161               </Directory> 
    162             </Directory> 
    163166          </Directory> 
    164167        </Directory> 
     168      </Directory> 
    165169 
    166170      <!-- ### Start Menu Items ### --> 
    167         <Directory Id="ProgramMenuFolder" Name="PMenu" LongName="Programs"> 
    168           <Directory Id="ProgramMenuDir" Name='NSClient' LongName="$(var.App.StartMenuPath)" /> 
    169         </Directory> 
     171      <Directory Id="ProgramMenuFolder" Name="Programs"> 
     172        <Directory Id="ProgramMenuDir" Name="$(var.App.StartMenuPath)" /> 
    170173      </Directory> 
     174    </Directory> 
    171175 
    172176    <!-- ### FEATURES START ### --> 
    173       <Feature Id="ProductFeature" Title="NSClient++ $(var.PlatForm)" Description="Binaries for $(var.PlatForm)" 
     177    <Feature Id="ProductFeature" Title="NSClient++ $(var.arch)" Description="Binaries for $(var.arch)" 
    174178               Display="expand"  Level="1" ConfigurableDirectory="INSTALLLOCATION" Absent="disallow"> 
    175         <Feature Id="MainProgram" Title="Program" Description="Main Service" Level="1" Absent="disallow"> 
    176           <ComponentRef Id="MainClient" /> 
    177         </Feature> 
    178         <Feature Id="FireWallException" Title="Firewall Exception" Description="Add an exception to the windows firewall" Level="1"> 
    179           <ComponentRef Id="FireWallException" /> 
    180         </Feature> 
    181         <Feature Id="ServiceRegistration" Title="Register service" Description="Register the NSClient++ service" Level="1"> 
    182           <ComponentRef Id="ServiceRegistration" /> 
    183         </Feature> 
    184         <Feature Id="Documentation" Title="Documentation (pdf)" Description="Documentation for NSClient++ and how to use it from Nagios" Level="1"> 
    185           <ComponentRef Id="Documentation" /> 
    186         </Feature> 
    187         <Feature Id="Plugins" Title="Plugins" Description="Plugins" Level="1" Absent="disallow"> 
     179      <Feature Id="MainProgram" Title="Program" Description="Main Service" Level="1" Absent="disallow"> 
     180        <ComponentRef Id="MainClient" /> 
     181        <ComponentRef Id="Shortcuts" /> 
     182        <ComponentRef Id="Helpers" /> 
     183        <ComponentRef Id="RandomFiles" /> 
     184      </Feature> 
     185      <Feature Id="Documentation" Title="Documentation (pdf)" Description="Documentation for NSClient++ and how to use it from Nagios" Level="1"> 
     186        <ComponentRef Id="NagiosDocumentation" /> 
     187        <ComponentRef Id="ReferenceDocumentation" /> 
     188      </Feature> 
     189      <Feature Id="Plugins" Title="Plugins" Description="Plugins" Level="1" Absent="disallow"> 
    188190        <Feature Id="CheckPlugins" Title="Check Plugins" Description="Various plugins to check your system. (Includes all check plugins)" Level="1"> 
    189191          <ComponentRef Id="Plugins" /> 
     
    200202        </Feature> 
    201203        <Feature Id="SampleScripts" Title="Sample Scripts" Description="Some sample client-side scripts to use with NRPE" Level="1" Absent="disallow"> 
    202           <ComponentRef Id="Scripts" /> 
    203           <ComponentRef Id="ScriptLibs" /> 
    204         </Feature> 
     204          <ComponentRef Id="Scripts" /> 
     205          <ComponentRef Id="ScriptLibs" /> 
     206        </Feature> 
    205207      </Feature> 
    206208    </Feature> 
    207209 
    208     <CustomTable Id="WixFirewallException"> 
    209       <Column Id="Id"         Category="Identifier" PrimaryKey="yes"  Type="string" Width="72"  Modularize="Column"                     Description="The primary key, a non-localized token."/> 
    210       <Column Id="Name"       Category="Formatted"  PrimaryKey="no"   Type="string" Width="255" Modularize="Property" Nullable="yes" Localizable="yes" Description="Localizable display name."/> 
    211       <Column Id="RemoteAddresses"  Category="Formatted"  PrimaryKey="no"   Type="string" Width="2" Modularize="Property" Nullable="yes"                  Description="Remote address to accept incoming connections from."/> 
    212       <Column Id="Port"       Category="Formatted"  PrimaryKey="no"   Type="int"    Width="2" Modularize="Property" Nullable="yes" MinValue="1"     Description="Port number."/> 
    213       <Column Id="Protocol"     Category="Integer"    PrimaryKey="no"   Type="int"    Width="2" MinValue="6" Nullable="yes" MaxValue="17"             Description="Protocol (6=TCP; 17=UDP)."/> 
    214       <Column Id="Program"      Category="Formatted"  PrimaryKey="no"   Type="string" Width="255" Modularize="Property" Nullable="yes"    Description="Exception for a program (formatted path name)."/> 
    215       <Column Id="Attributes"     Category="Integer"    PrimaryKey="no"   Type="int"    Width="4" Nullable="yes" MinValue="0" MaxValue="65536" Description="Vital=1"/> 
    216       <Column Id="Component_"     Category="Identifier" PrimaryKey="no"   Type="string" Width="72"  Modularize="Column"                     Description="Foreign key into the Component table referencing component that controls the firewall configuration."/> 
    217       <Row> 
    218         <Data Column="Id">FWX1</Data> 
    219         <Data Column="Name">NSClient++ Monitoring Agent</Data> 
    220         <Data Column="Component_">FireWallException</Data> 
    221         <Data Column="Program">[#NSClientEXE]</Data> 
    222       </Row> 
    223     </CustomTable> 
    224  
    225     <CustomTable Id="Services"> 
    226       <Column Id="Id"     Category="Identifier" PrimaryKey="yes"  Type="string" Width="72"  Modularize="Column" 
    227           Description="The primary key, a non-localized token."/> 
    228       <Column Id="ShortName"  Category="Formatted"  PrimaryKey="no"   Type="string" Width="255" Modularize="Property" Nullable="yes" Localizable="yes"  
    229           Description="Service name."/> 
    230       <Column Id="LongName" Category="Formatted"  PrimaryKey="no"   Type="string" Width="255" Modularize="Property" Nullable="yes" 
    231           Description="Service long name."/> 
    232       <Column Id="Description" Category="Formatted" PrimaryKey="no"   Type="string" Width="255" Modularize="Property" Nullable="yes" 
    233           Description="The description"/> 
    234       <Column Id="Program"  Category="Formatted"  PrimaryKey="no"   Type="string" Width="255" Modularize="Property" Nullable="yes" 
    235           Description="Exception for a program (formatted path name)."/> 
    236       <Column Id="Dependencies" Category="Formatted"  PrimaryKey="no"   Type="string" Width="255" Modularize="Property" Nullable="yes" 
    237           Description="Service Dependencies"/> 
    238       <Column Id="Attributes" Category="Integer"    PrimaryKey="no"   Type="int"    Width="4"             Nullable="yes" MinValue="0" MaxValue="65536"  
    239           Description="Vital=1"/> 
    240       <Column Id="Component_" Category="Identifier" PrimaryKey="no"   Type="string" Width="72"  Modularize="Column"  
    241           Description="Foreign key into the Component table referencing component that controls the firewall configuration."/> 
    242       <Row> 
    243         <Data Column="Id">SVC</Data> 
    244         <Data Column="ShortName">nscp</Data> 
    245         <Data Column="LongName">$(var.App.Title) ($(var.PlatForm))</Data> 
    246         <Data Column="Description">Monitoring agent for nagios (and others) used to respond to status queries.</Data> 
    247         <Data Column="Component_">ServiceRegistration</Data> 
    248         <Data Column="Program">[#NSClientEXE] --service --run --name nscp</Data> 
    249         <Data Column="Dependencies"></Data> 
    250       </Row> 
    251     </CustomTable> 
    252  
    253     <?include properties.wxs ?> 
    254  
    255     <CustomAction Id='ImportConfig'             BinaryKey='InstallerHelper' DllEntry='ImportConfig'               Impersonate='no' Execute="immediate" Return="check" /> 
    256     <CustomAction Id='ScheduleWriteConfig'      BinaryKey='InstallerHelper' DllEntry='ScheduleWriteConfig'        Impersonate='no' Execute="immediate" Return="check" /> 
    257     <CustomAction Id="ExecWriteConfig"          BinaryKey="InstallerHelper" DllEntry="ExecWriteConfig"            Impersonate="no" Execute="deferred" Return="check"  /> 
    258  
    259     <CustomAction Id='NeedUninstall'            BinaryKey='InstallerHelper' DllEntry='NeedUninstall'              Impersonate='no' Execute="immediate" Return="check" /> 
    260      
    261  
    262     <CustomAction Id="PreventDowngrading"       Error="Newer version already installed." /> 
    263  
    264     <CustomAction Id='SchedServiceInstall'        BinaryKey='InstallerHelper' DllEntry='ScheduleInstallService'   Impersonate="no" Execute="immediate" Return="check" /> 
    265     <CustomAction Id='SchedServiceUnInstall'      BinaryKey='InstallerHelper' DllEntry='ScheduleUnInstallService' Impersonate="no" Execute="immediate" Return="check" /> 
    266     <CustomAction Id="WixRollbackServiceInstall"  BinaryKey="InstallerHelper" DllEntry="ExecServiceInstall"       Impersonate="no" Execute="rollback"  Return="check"  /> 
    267     <CustomAction Id="WixExecServiceInstall"      BinaryKey="InstallerHelper" DllEntry="ExecServiceInstall"       Impersonate="no" Execute="deferred"  Return="check"  /> 
    268     <CustomAction Id="WixRollbackServiceUninstall" BinaryKey="InstallerHelper" DllEntry="ExecServiceInstall"      Impersonate="no" Execute="rollback"  Return="check"  /> 
    269     <CustomAction Id="WixExecServiceUninstall"    BinaryKey="InstallerHelper" DllEntry="ExecServiceInstall"       Impersonate="no" Execute="deferred"  Return="check" /> 
    270  
    271     <CustomAction Id='SchedStopAllServices'       BinaryKey='InstallerHelper' DllEntry='SchedStopAllServices'     Impersonate="no" Execute="immediate" Return="check" /> 
    272     <CustomAction Id='ExitDialogExec'             BinaryKey='InstallerHelper' DllEntry='ExitDialogExec'           Impersonate="no" Execute="immediate" Return="check" /> 
    273     <CustomAction Id='StartAllServices'           BinaryKey='InstallerHelper' DllEntry='StartAllServices'         Impersonate="no" Execute="deferred" Return="check" /> 
    274     <CustomAction Id='StopAllServices'            BinaryKey='InstallerHelper' DllEntry='StopAllServices'          Impersonate="no" Execute="deferred" Return="check" /> 
    275     <CustomAction Id='ExecCopyFileDefered'        BinaryKey='InstallerHelper' DllEntry='ExecCopyFileDefered'      Impersonate="no" Execute="deferred" Return="check" /> 
    276  
    277     <CustomAction Id="WixSchedFirewallExceptionsInstall"  
    278                                                   BinaryKey="WixFirewallCA" DllEntry="SchedFirewallExceptionsInstall"   Impersonate="no" Execute="immediate" Return="check" /> 
    279     <CustomAction Id="WixSchedFirewallExceptionsUninstall" 
    280                                                   BinaryKey="WixFirewallCA" DllEntry="SchedFirewallExceptionsUninstall" Impersonate="no" Execute="immediate" Return="check" /> 
    281     <CustomAction Id="WixRollbackFirewallExceptionsInstall"  
    282                                                   BinaryKey="WixFirewallCA" DllEntry="ExecFirewallExceptions"           Impersonate="no" Execute="rollback" Return="check" /> 
    283     <CustomAction Id="WixExecFirewallExceptionsInstall" 
    284                                                   BinaryKey="WixFirewallCA" DllEntry="ExecFirewallExceptions"           Impersonate="no" Execute="deferred" Return="check" /> 
    285     <CustomAction Id="WixRollbackFirewallExceptionsUninstall"  
    286                                                   BinaryKey="WixFirewallCA" DllEntry="ExecFirewallExceptions"           Impersonate="no" Execute="rollback" Return="check" /> 
    287     <CustomAction Id="WixExecFirewallExceptionsUninstall" 
    288                                                   BinaryKey="WixFirewallCA" DllEntry="ExecFirewallExceptions"           Impersonate="no" Execute="deferred" Return="check" /> 
    289  
     210    <CustomAction Id='ImportConfig'     BinaryKey='InstallerHelper' DllEntry='ImportConfig'     Impersonate='yes' Execute="immediate" Return="check" /> 
     211    <CustomAction Id='ScheduleWriteConfig'  BinaryKey='InstallerHelper' DllEntry='ScheduleWriteConfig'  Impersonate='yes' Execute="immediate" Return="check" /> 
     212    <CustomAction Id="ExecWriteConfig"    BinaryKey="InstallerHelper" DllEntry="ExecWriteConfig"    Impersonate="no" Execute="deferred" Return="check"  /> 
     213 
     214    <CustomAction Id='NeedUninstall'    BinaryKey='InstallerHelper' DllEntry='NeedUninstall'    Impersonate='yes' Execute="immediate" Return="check" /> 
     215    <CustomAction Id="PreventDowngrading" Error="Newer version already installed." /> 
    290216 
    291217    <Binary Id='InstallerHelper' SourceFile='$(var.Helpers)/main_dll.dll' /> 
    292     <Binary Id='WixFirewallCA' SourceFile='$(var.Helpers)/fw_dll.dll' /> 
    293218 
    294219    <InstallExecuteSequence> 
    295220      <RemoveExistingProducts After='InstallInitialize'/> 
    296       <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWAPPFOUND</Custom> 
    297       <Custom Action="ScheduleWriteConfig" After='InstallFiles' /> 
    298       <Custom Action="SchedServiceInstall" After="InstallFiles" /> 
    299       <Custom Action="SchedServiceUnInstall" Before="RemoveFiles" /> 
    300       <Custom Action="SchedStopAllServices" Before="RemoveFiles" /> 
    301  
    302       <Custom Action="WixSchedFirewallExceptionsUninstall" Before="RemoveFiles"> 
    303         <![CDATA[ VersionNT >= 501 AND (ServicePackLevel >= 2 OR VersionNT >= 600) ]]> 
    304       </Custom> 
    305       <Custom Action="WixSchedFirewallExceptionsInstall" After="InstallFiles"> 
    306         <![CDATA[ VersionNT >= 501 AND (ServicePackLevel >= 2 OR VersionNT >= 600) ]]> 
    307       </Custom> 
     221      <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWAPPFOUND</Custom> 
     222      <Custom Action="ScheduleWriteConfig" After='InstallFiles' /> 
    308223    </InstallExecuteSequence> 
    309224 
    310225    <InstallUISequence> 
    311226      <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWAPPFOUND</Custom> 
    312       <Custom Action="NeedUninstall" After="FindRelatedProducts" /> 
     227      <Custom Action="NeedUninstall" After="FindRelatedProducts" >1</Custom> 
     228      <Custom Action="ImportConfig" After="CostFinalize" >1</Custom> 
    313229    </InstallUISequence> 
    314230 
    315     <Property Id="ALLUSERS"><![CDATA[2]]></Property> 
     231    <Property Id="ALLUSERS"> 
     232      <![CDATA[2]]> 
     233    </Property> 
     234    <?include properties.wxs ?> 
    316235 
    317236    <!-- ### User Interfaces ### --> 
    318     <UIRef Id="WixUI_Mondo" /> 
     237    <UIRef Id="WixUI_MondoNSCP" /> 
    319238    <UIRef Id="WixUI_ErrorProgressText" /> 
    320239 
    321240    <!-- ### Icons --> 
    322241    <Icon Id="nscp.exe" SourceFile="$(var.Source)/nscp.exe" /> 
    323     <!-- 
    324     <Icon Id="nstray.exe" SourceFile="$(var.Source)/nstray.exe" /> 
    325         --> 
     242    <Icon Id="doc.ico" SourceFile="$(var.Source)/res/help.ico"/> 
    326243  </Product> 
    327244</Wix> 
  • helpers/installers/installer/properties.wxs

    r47d3b0b rb7d17f8  
    11<Include> 
    2 <Property Id='ARPCOMMENTS'>NSClient++ is a </Property> 
    3 <Property Id='ARPCONTACT'>michael@medin.name</Property> 
    4 <Property Id='ARPHELPLINK'>http://nsclient.org</Property> 
    5 <Property Id='ARPURLINFOABOUT'>http://nsclient.org</Property> 
    6 <Property Id='ARPURLUPDATEINFO'>http://nsclient.org</Property> 
    7 <Property Id='ARPHELPTELEPHONE'>http://nsclient.org</Property> 
    8 <Property Id='ARPPRODUCTICON'>nsclient.exe</Property> 
     2  <!-- CONFIGURE APPLICATION INFORMATION --> 
     3  <Property Id="ARPCOMMENTS">NSClient++ is a monitoring Agent for amongst other systems Nagios</Property> 
     4  <Property Id="ARPCONTACT">michael@medin.name</Property> 
     5  <Property Id="ARPHELPLINK">http://nsclient.org</Property> 
     6  <Property Id="ARPURLINFOABOUT">http://nsclient.org</Property> 
     7  <Property Id="ARPURLUPDATEINFO">http://nsclient.org</Property> 
     8  <Property Id="ARPHELPTELEPHONE">http://nsclient.org</Property> 
     9  <Property Id="ARPPRODUCTICON">nscp.exe</Property> 
    910 
    10 <Property Id="CONF_CHECKS_DEFAULT"></Property> 
    11 <Property Id="CONF_NSCLIENT_DEFAULT"></Property> 
    12 <Property Id="CONF_NRPE_DEFAULT"></Property> 
    13 <Property Id="CONF_NSCA_DEFAULT"></Property> 
    14 <Property Id="CONF_WMI_DEFAULT"></Property> 
    15 <Property Id="ALLOW_CONFIGURATION" /> 
     11  <!-- CONFIGURE DEFAULT VALUES (what will happen if missing from config) --> 
     12  <!-- 
     13  <Property Id="CONF_CHECKS_DEFAULT">0</Property> 
     14  <Property Id="CONF_NSCLIENT_DEFAULT">0</Property> 
     15  <Property Id="CONF_NRPE_DEFAULT">0</Property> 
     16  <Property Id="CONF_NSCA_DEFAULT">0</Property> 
     17  <Property Id="CONF_WMI_DEFAULT">0</Property> 
     18  <Property Id="ALLOWED_HOSTS_DEFAULT"></Property> 
     19  <Property Id="NSCLIENT_PWD_DEFAULT"></Property> 
     20   --> 
     21  <Property Id="CONFIGURATION_TYPE_DEFAULT">ini://${shared-path}/nsclient.ini</Property> 
    1622 
    17 <!-- CONFIGURE DEFAULT VALUES--> 
    18 <Property Id="ALLOWED_HOSTS_DEFAULT">$$EMPTY$$</Property> 
    19 <Property Id="NSCLIENT_PWD_DEFAULT">$$EMPTY$$</Property> 
     23  <!-- CONFIGURE INITAL VALUES IN CONFIG UI --> 
     24  <!-- 
     25  <Property Id="CONF_CHECKS">0</Property> 
     26  <Property Id="CONF_NSCLIENT">0</Property> 
     27  <Property Id="CONF_NRPE">0</Property> 
     28  <Property Id="CONF_NSCA">0</Property> 
     29  <Property Id="CONF_WMI">0</Property> 
     30  <Property Id="ALLOWED_HOSTS"></Property> 
     31  <Property Id="NSCLIENT_PWD"></Property> 
     32   --> 
     33  <Property Id="CONFIGURATION_TYPE">ini://${shared-path}/nsclient.ini</Property> 
    2034 
    21 <!-- CONFIGURE THE INSTALLER --> 
    22 <Property Id='INSCON_CONFIGURE'>1</Property> 
    23 <Property Id='MAIN_CONFIGURATION_FILE'>NSC.ini</Property> 
    24 <Property Id='CUSTOM_CONFIGURATION_FILE'>NSC.ini</Property> 
    25 <Property Id='HELP_LINK'>http://nsclient.org/nscp/</Property> 
     35  <!-- CONFIGURE THE INSTALLER --> 
     36  <Property Id="ALLOW_CONFIGURATION">1</Property> 
     37  <Property Id="MAIN_CONFIGURATION_FILE">nsclient.ini</Property> 
     38  <Property Id="CUSTOM_CONFIGURATION_FILE">nsclient.ini</Property> 
     39  <WixVariable Id="WixUIBannerBmp" Value="Bitmaps\bannrbmp.bmp" /> 
     40  <WixVariable Id="WixUIDialogBmp" Value="Bitmaps\dlgbmp.bmp" /> 
    2641 
    27 <Property Id='SHOW_START_ON_EXIT'>1</Property> 
    28 <Property Id='START_SERVICE_ON_EXIT'></Property> 
    29 <Property Id='SHOW_DONATE_ON_EXIT'>1</Property> 
    30 <Property Id='DONATE_ON_EXIT'></Property> 
    31 <Property Id='KEEP_WHICH_CONFIG'>NEW</Property> 
    32 <!--<Property Id='MAIN_CONFIGURATION_FILE'>NSC.ini</Property>--> 
    33 <!--<Property Id='ARPREADME'>path</Property>--> 
    34 <!--<Property Id='ARPSIZE'>app size in kilobytes</Property>--> 
     42  <!-- CONFIGURE THE PROGRAM --> 
     43  <Property Id="HELP_LINK">http://nsclient.org/nscp/</Property> 
     44  <Property Id="SERVICE_NAME">nscp</Property> 
    3545 
    3646</Include> 
  • helpers/settings_manager/settings_manager_impl.h

    rc760fc9 rb7d17f8  
    11#pragma once 
    22 
    3 #include "settings_logger_impl.hpp" 
    43#include <settings/settings_core.hpp> 
    5 #include <settings/settings_ini.hpp> 
    64#include <settings/client/settings_client.hpp> 
    7 #ifdef WIN32 
    8 #include <settings/settings_old.hpp> 
    9 #include <settings/settings_registry.hpp> 
    10 #endif 
     5#include <settings/settings_handler_impl.hpp> 
    116 
    127namespace settings_manager { 
     8 
     9  struct provider_interface { 
     10    virtual std::wstring expand_path(std::wstring file) = 0; 
     11    virtual void log_fatal_error(std::wstring error) = 0; 
     12    virtual settings::logger_interface* create_logger() = 0; 
     13  }; 
     14 
    1315  class NSCSettingsImpl : public settings::settings_handler_impl { 
    1416  private: 
    1517    boost::filesystem::wpath boot_; 
    1618    bool old_; 
     19    provider_interface *provider_; 
    1720  public: 
    18     NSCSettingsImpl() : old_(false) {} 
     21    NSCSettingsImpl(provider_interface *provider) : old_(false), provider_(provider) {} 
    1922    ////////////////////////////////////////////////////////////////////////// 
    2023    /// Get a string form the boot file. 
     
    3740#endif 
    3841    } 
     42    void set_boot_string(std::wstring section, std::wstring key, std::wstring val) { 
     43#ifdef WIN32 
     44      WritePrivateProfileString(section.c_str(), key.c_str(), val.c_str(), boot_.string().c_str()); 
     45#else 
     46#endif 
     47    } 
    3948 
    4049    void boot(std::wstring file = _T("boot.ini")); 
     
    4251    std::wstring expand_path(std::wstring file); 
    4352    settings::instance_raw_ptr create_instance(std::wstring key); 
     53    bool check_file(std::wstring file, std::wstring tag, std::wstring &key); 
     54    void change_context(std::wstring file); 
    4455  }; 
    4556 
    46   typedef Singleton<NSCSettingsImpl> SettingsHandler; 
     57  //typedef Singleton<NSCSettingsImpl> SettingsHandler; 
    4758 
    4859  // Alias to make handling "compatible" with old syntax 
     
    5263  nscapi::settings_helper::settings_impl_interface_ptr get_proxy(); 
    5364  void destroy_settings(); 
    54   bool init_settings(std::wstring context = _T("")); 
     65  bool init_settings(provider_interface *provider, std::wstring context = _T("")); 
     66  void change_context(std::wstring context); 
    5567} 
  • include/config.h.in

    rc391984 rb7d17f8  
    2121#pragma once 
    2222 
    23 #include "../AutoBuild.h" 
     23#include "../version.hpp" 
    2424/* 
    2525#include <tchar.h>  
     
    8282#define DEFAULT_CONF_LOCATION _T("ini") 
    8383#endif 
     84#define BOOT_CONF_LOCATION _T("${exe-path}/boot.ini") 
    8485#define DEFAULT_CONF_OLD_LOCATION _T("old://${exe-path}/nsc.ini") 
    8586#define DEFAULT_CONF_INI_LOCATION _T("ini://${shared-path}/nsclient.ini") 
    8687#define DEFAULT_CONF_REG_LOCATION _T("registry://HKEY_LOCAL_MACHINE/software/NSClient++") 
     88 
     89#define DEFAULT_CACHE_PATH _T("${shared-path}/cache") 
    8790 
    8891 
  • include/nsca/nsca_enrypt.hpp

    r47bcf6f rb7d17f8  
    105105        } 
    106106        ZeroMemory(key,keysize*sizeof(unsigned char)); 
    107         strncpy(reinterpret_cast<char*>(key),password.c_str(),min(keysize,password.length())); 
     107        strncpy(reinterpret_cast<char*>(key),password.c_str(),std::min(keysize,static_cast<unsigned int>(password.length()))); 
    108108 
    109109 
     
    317317      core_ = get_encryption_core(encryption_method); 
    318318      if (core_ == NULL) 
    319         throw encryption_exception(_T("Failed to get encryption core!")); 
     319        throw encryption_exception(_T("Failed to get encryption module for: ") + to_wstring(encryption_method)); 
    320320 
    321321      /* server generates IV used for encryption */ 
  • include/nsca/nsca_packet.hpp

    r40970de rb7d17f8  
    118118      boost::posix_time::time_duration diff = now - time_t_epoch; 
    119119      time = diff.total_seconds(); 
    120       std::cout << "Adding time: " << time_delta << std::endl; 
    121120    } 
    122121    packet() : payload_length_(nsca::length::data::get_payload_length()) 
     
    135134 
    136135    void get_buffer(std::string &buffer) const { 
     136      // FIXME: This is crap and needs rewriting. No std::string and beetter zero handling... 
    137137      if (service.length() >= nsca::length::desc_length) 
    138138        throw nsca::nsca_exception(_T("Description field to long")); 
     
    151151      data->crc32_value= swap_bytes::hton<u_int32_t>(0); 
    152152 
     153      ZeroMemory(data->get_host_ptr(), host.size()+1); 
    153154      host.copy(data->get_host_ptr(), host.size()); 
     155      ZeroMemory(data->get_desc_ptr(nsca::length::host_length), service.size()+1); 
    154156      service.copy(data->get_desc_ptr(nsca::length::host_length), service.size()); 
     157      ZeroMemory(data->get_result_ptr(nsca::length::host_length, nsca::length::desc_length), result.size()+1); 
    155158      result.copy(data->get_result_ptr(nsca::length::host_length, nsca::length::desc_length), result.size()); 
    156159 
  • include/nscapi/macros.hpp

    r7443b58 rb7d17f8  
    2828////////////////////////////////////////////////////////////////////////// 
    2929// Logging calls for the core wrapper  
    30 /* 
     30 
    3131#define NSC_LOG_ERROR_STD(msg) NSC_LOG_ERROR(((std::wstring)msg).c_str()) 
    3232#define NSC_LOG_ERROR(msg) NSC_ANY_MSG(msg,NSCAPI::error) 
     
    4242 
    4343#define NSC_ANY_MSG(msg, type) GET_CORE()->Message(type, __FILE__, __LINE__, msg) 
    44 */ 
     44/* 
    4545#define NSC_LOG_ERROR_STD(msg)  
    4646#define NSC_LOG_ERROR(msg)  
     
    5656 
    5757#define NSC_ANY_MSG(msg, type) 
    58  
     58*/ 
    5959 
    6060////////////////////////////////////////////////////////////////////////// 
  • include/nscapi/nscapi_plugin_wrapper.hpp

    rc391984 rb7d17f8  
    123123            args.push_back(to_wstring(payload.arguments(i))); 
    124124          } 
    125           std::wstring msg = to_wstring(payload.message()); 
    126           std::wstring perf = to_wstring(::nscapi::functions::build_performance_data(payload)); 
     125          std::wstring msg = utf8::cvt<std::wstring>(payload.message()); 
     126          std::wstring perf = utf8::cvt<std::wstring>(::nscapi::functions::build_performance_data(payload)); 
    127127          NSCAPI::nagiosReturn ret = handleSimpleNotification(channel, command, code, msg, perf); 
    128128        } catch (std::exception &e) { 
  • include/settings/settings_core.hpp

    r1ecd26f rb7d17f8  
    287287    /// 
    288288    /// @author mickem 
    289     virtual boost::filesystem::wpath get_base() = 0; 
     289    //virtual boost::filesystem::wpath get_base() = 0; 
    290290 
    291291    ////////////////////////////////////////////////////////////////////////// 
     
    305305 
    306306    virtual std::wstring to_string() = 0; 
     307 
     308    virtual std::wstring expand_path(std::wstring key) = 0; 
    307309 
    308310  }; 
  • include/settings/settings_handler_impl.hpp

    rc760fc9 rb7d17f8  
    5959      set_logger(NULL); 
    6060    } 
    61  
    62     virtual std::wstring expand_path(std::wstring key) = 0; 
    6361 
    6462    ////////////////////////////////////////////////////////////////////////// 
  • include/settings/settings_interface_impl.hpp

    rc760fc9 rb7d17f8  
    3232#include <strEx.h> 
    3333#include <settings/settings_core.hpp> 
    34  
     34#include <net/net.hpp> 
    3535 
    3636#define MUTEX_GUARD() \ 
     
    9393    key_cache_type key_cache_; 
    9494    std::wstring context_; 
    95     net::url url_; 
     95    net::wurl url_; 
    9696 
    9797    //SettingsInterfaceImpl() : core_(NULL) {} 
  • include/settings/settings_old.hpp

    r7443b58 rb7d17f8  
    11#pragma once 
    22 
     3#include <iostream> 
     4#include <fstream> 
    35#include <string> 
    46#include <map> 
    57#include <settings/settings_core.hpp> 
    68#include <simpleini/SimpleIni.h> 
    7 #include <settings/macros.h> 
    8 #include <iostream> 
    9 #include <fstream> 
     9//#include <settings/macros.h> 
     10 
     11#include <strEx.h> 
    1012 
    1113 
     
    1719  class OLDSettings : public settings::SettingsInterfaceImpl { 
    1820    std::wstring filename_; 
    19   public: 
    20     OLDSettings(settings::settings_core *core, std::wstring context) : settings::SettingsInterfaceImpl(core, context) { 
    21       std::wstring fname = core->find_file(_T("${exe-path}/old-settings.map"), _T("old-settings.map")); 
    22       read_map_file(fname); 
    23     } 
    24     void read_map_file(std::wstring file) { 
    25       get_logger()->debug(__FILE__, __LINE__, _T("Reading MAP file: ") + file); 
    26  
    27       std::ifstream in(strEx::wstring_to_string(file).c_str()); 
    28       if(!in) { 
    29         get_logger()->err(__FILE__, __LINE__, _T("Failed to read MAP file: ") + file); 
    30         return; 
    31       } 
    32       in.exceptions(std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit); 
    33  
    34       try{ 
    35         std::string tmp; 
    36         while(true) { 
    37           std::getline(in,tmp); 
    38           parse_line(to_wstring(tmp)); 
    39         } 
    40       } 
    41       catch(std::ifstream::failure e){ 
    42         if(!in.eof()) 
    43           cerr << e.what() <<'\n'; 
    44       } 
    45     } 
    46     void parse_line(std::wstring line) { 
    47       int pos = line.find('#'); 
    48       if (pos != -1) 
    49         line = line.substr(0, pos); 
    50       pos = line.find_first_not_of(_T(" \t")); 
    51       if (pos == -1) 
    52         return; 
    53       line = line.substr(pos); 
    54       pos = line.find('='); 
    55       if (pos == -1) { 
    56         get_logger()->err(__FILE__, __LINE__, _T("Invalid syntax: ") + line); 
    57         return; 
    58       } 
    59       std::pair<std::wstring,std::wstring> old_key = split_key(line.substr(0, pos)); 
    60       std::pair<std::wstring,std::wstring> new_key = split_key(line.substr(pos+1)); 
    61       if (old_key.second == _T("*") || old_key.second.empty()) { 
    62         add_mapping(line.substr(pos+1), old_key.first); 
    63       } else { 
    64         add_mapping(new_key.first, new_key.second, old_key.first, old_key.second); 
    65       } 
    66  
    67     } 
    68     std::pair<std::wstring,std::wstring> split_key(std::wstring key) { 
    69       std::pair<std::wstring,std::wstring> ret; 
    70       int pos = key.find_last_of('/'); 
    71       if (pos == -1) 
    72         return std::pair<std::wstring,std::wstring>(key, _T("")); 
    73       return std::pair<std::wstring,std::wstring>(key.substr(0, pos), key.substr(pos+1)); 
    74     } 
    75  
    76     typedef std::map<std::wstring,std::wstring> path_map; 
    77     typedef std::map<settings_core::key_path_type,settings_core::key_path_type> key_map; 
    7821    typedef std::pair<std::wstring,std::wstring> section_key_type; 
    79     typedef std::pair<settings_core::key_path_type,settings_core::key_path_type> keys_key_type; 
    80  
    81     path_map sections_; 
    82     key_map keys_; 
    83     void add_mapping(std::wstring path_new, std::wstring path_old) { 
    84       sections_[path_new] = path_old; 
    85     } 
    86     void add_mapping(std::wstring path_new, std::wstring key_new, std::wstring path_old, std::wstring key_old) { 
    87       settings_core::key_path_type new_key(path_new, key_new); 
    88       settings_core::key_path_type old_key(path_old, key_old); 
    89       keys_[new_key] = old_key; 
    90     } 
    91     std::wstring map_path(std::wstring path_new) { 
    92       path_map::iterator it = sections_.find(path_new); 
    93       if (it == sections_.end()) 
    94         return path_new; 
    95       return (*it).second; 
    96     } 
    97     settings_core::key_path_type map_key(settings_core::key_path_type new_key) { 
    98       key_map::iterator it1 = keys_.find(new_key); 
    99       if (it1 != keys_.end()) { 
    100         get_core()->get_logger()->quick_debug(new_key.first + _T(".") + new_key.second + _T(" not found in alias list")); 
    101         return (*it1).second; 
    102       } 
    103       path_map::iterator it2 = sections_.find(new_key.first); 
    104       if (it2 != sections_.end()) 
    105         return settings_core::key_path_type((*it2).second, new_key.second); 
    106       return new_key; 
     22 
     23    class settings_map : boost::noncopyable { 
     24    public: 
     25 
     26      typedef std::map<std::wstring,std::wstring> path_map; 
     27      typedef std::map<settings_core::key_path_type,settings_core::key_path_type> key_map; 
     28      typedef std::pair<std::wstring,std::wstring> section_key_type; 
     29      typedef std::pair<settings_core::key_path_type,settings_core::key_path_type> keys_key_type; 
     30 
     31      OLDSettings *parent; 
     32      path_map sections_; 
     33      key_map keys_; 
     34 
     35      settings_map(OLDSettings *parent) : parent(parent) {} 
     36 
     37      void read_map_file(std::wstring file) { 
     38        parent->get_logger()->debug(__FILE__, __LINE__, _T("Reading MAP file: ") + file); 
     39 
     40        std::ifstream in(strEx::wstring_to_string(file).c_str()); 
     41        if(!in) { 
     42          parent->get_logger()->err(__FILE__, __LINE__, _T("Failed to read MAP file: ") + file); 
     43          return; 
     44        } 
     45        in.exceptions(std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit); 
     46 
     47        try{ 
     48          std::string tmp; 
     49          while(true) { 
     50            std::getline(in,tmp); 
     51            parse_line(utf8::cvt<std::wstring>(tmp)); 
     52          } 
     53        } 
     54        catch(std::ifstream::failure e){ 
     55          if(!in.eof()) 
     56            std::cerr << e.what() <<'\n'; 
     57        } 
     58      } 
     59      void parse_line(std::wstring line) { 
     60        int pos = line.find('#'); 
     61        if (pos != -1) 
     62          line = line.substr(0, pos); 
     63        pos = line.find_first_not_of(_T(" \t")); 
     64        if (pos == -1) 
     65          return; 
     66        line = line.substr(pos); 
     67        pos = line.find('='); 
     68        if (pos == -1) { 
     69          parent->get_logger()->err(__FILE__, __LINE__, _T("Invalid syntax: ") + line); 
     70          return; 
     71        } 
     72        std::pair<std::wstring,std::wstring> old_key = split_key(line.substr(0, pos)); 
     73        std::pair<std::wstring,std::wstring> new_key = split_key(line.substr(pos+1)); 
     74        if (old_key.second == _T("*") || old_key.second.empty()) { 
     75          add(line.substr(pos+1), old_key.first); 
     76        } else { 
     77          add(new_key.first, new_key.second, old_key.first, old_key.second); 
     78        } 
     79 
     80      } 
     81      std::pair<std::wstring,std::wstring> split_key(std::wstring key) { 
     82        std::pair<std::wstring,std::wstring> ret; 
     83        int pos = key.find_last_of('/'); 
     84        if (pos == -1) 
     85          return std::pair<std::wstring,std::wstring>(key, _T("")); 
     86        return std::pair<std::wstring,std::wstring>(key.substr(0, pos), key.substr(pos+1)); 
     87      } 
     88 
     89      void add(std::wstring path_new, std::wstring path_old) { 
     90        sections_[path_new] = path_old; 
     91      } 
     92      void add(std::wstring path_new, std::wstring key_new, std::wstring path_old, std::wstring key_old) { 
     93        settings_core::key_path_type new_key(path_new, key_new); 
     94        settings_core::key_path_type old_key(path_old, key_old); 
     95        keys_[new_key] = old_key; 
     96      } 
     97      std::wstring path(std::wstring path_new) { 
     98        path_map::iterator it = sections_.find(path_new); 
     99        if (it == sections_.end()) 
     100          return path_new; 
     101        return (*it).second; 
     102      } 
     103      settings_core::key_path_type key(settings_core::key_path_type new_key) { 
     104        key_map::iterator it1 = keys_.find(new_key); 
     105        if (it1 != keys_.end()) { 
     106          parent->get_logger()->quick_debug(new_key.first + _T(".") + new_key.second + _T(" not found in alias list")); 
     107          return (*it1).second; 
     108        } 
     109        path_map::iterator it2 = sections_.find(new_key.first); 
     110        if (it2 != sections_.end()) 
     111          return settings_core::key_path_type((*it2).second, new_key.second); 
     112        return new_key; 
     113      } 
     114 
     115      void get_sections(std::wstring path, string_list &list) { 
     116        unsigned int path_length = path.length(); 
     117        BOOST_FOREACH(section_key_type key, sections_) { 
     118          if (path_length == 0 || path == _T("/")) { 
     119            std::wstring::size_type pos = key.first.find(L'/', 1); 
     120            list.push_back(pos == std::wstring::npos?key.first:key.first.substr(0,pos)); 
     121          } else if (key.first.length() > path_length && path == key.first.substr(0, path_length)) { 
     122            std::wstring::size_type pos = key.first.find(L'/', path_length+1); 
     123            list.push_back(pos == std::wstring::npos?key.first.substr(path_length+1):key.first.substr(path_length+1,pos-path_length-1)); 
     124          } 
     125        } 
     126        BOOST_FOREACH(keys_key_type key, keys_) { 
     127          if (path.empty() || path == _T("/")) { 
     128            std::wstring::size_type pos = key.first.first.find(L'/', 1); 
     129            if (pos != std::wstring::npos) 
     130              key.first.first = key.first.first.substr(0,pos); 
     131            list.push_back(key.first.first); 
     132          } else if (key.first.first.length() > path_length && path == key.first.first.substr(0, path_length)) { 
     133            std::wstring::size_type pos = key.first.first.find(L'/', path_length+1); 
     134            list.push_back(pos == std::wstring::npos?key.first.first.substr(path_length+1):key.first.first.substr(path_length+1,pos-path_length-1)); 
     135          } 
     136        } 
     137        list.unique(); 
     138      } 
     139 
     140 
     141    }; 
     142 
     143      settings_map map; 
     144      typedef std::map<std::wstring,std::set<std::wstring> > section_cache_type; 
     145      section_cache_type section_cache_; 
     146 
     147 
     148    public: 
     149 
     150 
     151    OLDSettings(settings::settings_core *core, std::wstring context) : settings::SettingsInterfaceImpl(core, context), map(this) { 
     152      get_logger()->debug(__FILE__, __LINE__, _T("Loading OLD: ") + context); 
     153      map.read_map_file(core->find_file(_T("${exe-path}/old-settings.map"), _T("old-settings.map"))); 
     154 
     155      string_list list = get_keys(_T("includes")); 
     156      BOOST_FOREACH(std::wstring key, list) { 
     157        add_child(key); 
     158      } 
    107159    } 
    108160    ////////////////////////////////////////////////////////////////////////// 
     
    125177    /// @author mickem 
    126178    virtual std::wstring get_real_string(settings_core::key_path_type key) { 
    127       key = map_key(key); 
     179      key = map.key(key); 
    128180      return internal_get_value(key.first, key.second); 
    129181    } 
     
    180232    /// @author mickem 
    181233    virtual bool has_real_key(settings_core::key_path_type key) { 
    182       settings_core::key_path_type old = map_key(key); 
     234      settings_core::key_path_type old = map.key(key); 
    183235      return has_key_int(old.first, old.second); 
    184236    } 
     
    209261    } 
    210262 
    211     typedef std::map<std::wstring,std::set<std::wstring> > section_cache_type; 
    212     section_cache_type section_cache_; 
    213263    bool has_key_int(std::wstring path, std::wstring key) { 
    214264      section_cache_type::const_iterator it = section_cache_.find(path); 
     
    230280    virtual void set_real_value(settings_core::key_path_type key, conainer value) { 
    231281      try { 
    232         key = map_key(key); 
     282        key = map.key(key); 
    233283        WritePrivateProfileString(key.first.c_str(), key.second.c_str(), value.get_string().c_str(), get_file_name().c_str()); 
    234284      } catch (settings_exception e) { 
     
    254304    virtual void get_real_sections(std::wstring path, string_list &list) { 
    255305      unsigned int path_length = path.length(); 
    256       //string_list lst = get_mapped_sections(path); 
    257       //list.insert(list.end(), lst.begin(), lst.end()); 
    258       BOOST_FOREACH(section_key_type key, sections_) { 
    259         if (path_length == 0 || path == _T("/")) { 
    260           std::wstring::size_type pos = key.first.find(L'/', 1); 
    261           list.push_back(pos == std::wstring::npos?key.first:key.first.substr(0,pos)); 
    262         } else if (key.first.length() > path_length && path == key.first.substr(0, path_length)) { 
    263           std::wstring::size_type pos = key.first.find(L'/', path_length+1); 
    264           list.push_back(pos == std::wstring::npos?key.first.substr(path_length+1):key.first.substr(path_length+1,pos-path_length-1)); 
    265         } 
    266       } 
    267       BOOST_FOREACH(keys_key_type key, keys_) { 
    268         if (path.empty() || path == _T("/")) { 
    269           std::wstring::size_type pos = key.first.first.find(L'/', 1); 
    270           if (pos != std::wstring::npos) 
    271             key.first.first = key.first.first.substr(0,pos); 
    272           list.push_back(key.first.first); 
    273         } else if (key.first.first.length() > path_length && path == key.first.first.substr(0, path_length)) { 
    274           std::wstring::size_type pos = key.first.first.find(L'/', path_length+1); 
    275           list.push_back(pos == std::wstring::npos?key.first.first.substr(path_length+1):key.first.first.substr(path_length+1,pos-path_length-1)); 
    276         } 
    277       } 
     306      map.get_sections(path, list); 
    278307      list.unique(); 
    279308    } 
     
    322351      } 
    323352      // @todo: this will NOT work for "nodes in paths" 
    324       BOOST_FOREACH(keys_key_type key, keys_) { 
     353      BOOST_FOREACH(settings_map::keys_key_type key, map.keys_) { 
    325354        if (path == key.first.first) { 
    326355          if (has_key_int(key.second.first, key.second.second)) 
     
    329358      } 
    330359 
    331       BOOST_FOREACH(section_key_type key, sections_) { 
     360      BOOST_FOREACH(settings_map::section_key_type key, map.sections_) { 
    332361        if (key.first == path) { 
    333362          section_cache_type::const_iterator it = section_cache_.find(key.second); 
  • include/strEx.h

    rc391984 rb7d17f8  
    8181} 
    8282 
    83 namespace net { 
    84  
    85   struct url { 
    86     std::wstring protocol; 
    87     std::wstring host; 
    88     std::wstring path; 
    89     std::wstring query; 
    90  
    91   }; 
    92   inline url parse(const std::wstring& url_s) { 
    93     url ret; 
    94     const std::wstring prot_end(_T("://")); 
    95     std::wstring::const_iterator prot_i = std::search(url_s.begin(), url_s.end(), prot_end.begin(), prot_end.end()); 
    96     ret.protocol.reserve(std::distance(url_s.begin(), prot_i)); 
    97     std::transform(url_s.begin(), prot_i, std::back_inserter(ret.protocol), std::ptr_fun<int,int>(std::tolower)); // protocol is icase 
    98     if( prot_i == url_s.end() ) 
    99       return ret; 
    100     std::advance(prot_i, prot_end.length()); 
    101     std::wstring::const_iterator path_i = std::find(prot_i, url_s.end(), L'/'); 
    102     ret.host.reserve(std::distance(prot_i, path_i)); 
    103     std::transform(prot_i, path_i, std::back_inserter(ret.host), std::ptr_fun<int,int>(std::tolower)); // host is icase 
    104     std::wstring::const_iterator query_i = std::find(path_i, url_s.end(), L'?'); 
    105     ret.path.assign(path_i, query_i); 
    106     if( query_i != url_s.end() ) 
    107       ++query_i; 
    108     ret.query.assign(query_i, url_s.end()); 
    109     return ret; 
    110   } 
    111  
    112  
    113 } 
    11483namespace strEx { 
    11584  class string_exception : public std::exception { 
     
    874843  inline std::string cvt(std::wstring const & str) { 
    875844    // figure out how many narrow characters we are going to get  
    876     int nChars = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), NULL, 0, NULL, NULL); 
     845    int nChars = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), static_cast<int>(str.length()), NULL, 0, NULL, NULL); 
    877846    if (nChars == 0) 
    878847      return ""; 
     
    882851    std::string buf; 
    883852    buf.resize(nChars); 
    884     WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.length(), const_cast<char*>(buf.c_str()), nChars, NULL, NULL); 
     853    WideCharToMultiByte(CP_UTF8, 0, str.c_str(), static_cast<int>(str.length()), const_cast<char*>(buf.c_str()), nChars, NULL, NULL); 
    885854    return buf ;  
    886855  } 
     
    889858  inline std::wstring cvt(std::string const & str) { 
    890859    // figure out how many wide characters we are going to get  
    891     int nChars = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), NULL, 0); 
     860    int nChars = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), static_cast<int>(str.length()), NULL, 0); 
    892861    if (nChars == 0) 
    893862      return L""; 
     
    897866    std::wstring buf; 
    898867    buf.resize(nChars); 
    899     MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), const_cast<wchar_t*>(buf.c_str()), nChars); 
     868    MultiByteToWideChar(CP_UTF8, 0, str.c_str(), static_cast<int>(str.length()), const_cast<wchar_t*>(buf.c_str()), nChars); 
    900869    return buf; 
    901870  } 
  • modules/CheckDisk/filter.cpp

    r1f24a1c rb7d17f8  
    3535      (_T("accessed"), (type_date)) 
    3636      (_T("written"), (type_date)) 
    37       (_T("generated"), (type_date)); 
     37      (_T("created"), (type_date)); 
    3838  } 
    3939 
     
    7777  else if (key == _T("line_count")) 
    7878    ret = &object_type::get_line_count; 
    79   else if (key == _T("access")) 
     79  else if (key == _T("accessed")) 
    8080    ret = &object_type::get_access; 
    81   else if (key == _T("creation")) 
     81  else if (key == _T("created")) 
    8282    ret = &object_type::get_creation; 
    8383  else if (key == _T("written")) 
  • modules/NSCAAgent/NSCAAgent.cpp

    rc760fc9 rb7d17f8  
    149149NSCAPI::nagiosReturn NSCAAgent::handleSimpleNotification(const std::wstring channel, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf) { 
    150150  try { 
    151     NSC_DEBUG_MSG_STD(_T("* * *NSCA * * * Handling command: ") + command); 
    152151    boost::asio::io_service io_service; 
    153     NSC_DEBUG_MSG_STD(_T("* * *NSCA * * * message: ") + msg); 
    154     NSC_DEBUG_MSG_STD(_T("* * *NSCA * * * performance: ") + perf); 
    155152    nsca::socket socket(io_service); 
    156153    socket.connect(nscahost_, nscaport_); 
    157154    nsca::packet packet(hostname_, payload_length_, time_delta_); 
    158155    packet.code = code; 
    159     packet.host = "hello"; 
    160     packet.result = to_string(msg) + "|" + to_string(perf); 
     156    packet.service = utf8::cvt<std::string>(command); 
     157    packet.result = utf8::cvt<std::string>(msg) + "|" + utf8::cvt<std::string>(perf); 
    161158    socket.recv_iv(password_, encryption_method_, boost::posix_time::seconds(timeout_)); 
    162159    socket.send_nsca(packet, boost::posix_time::seconds(timeout_)); 
    163160    return NSCAPI::isSuccess; 
     161  } catch (nsca::nsca_encrypt::encryption_exception &e) { 
     162    NSC_LOG_ERROR_STD(_T("Failed to encrypt data: ") + e.getMessage()); 
     163    return NSCAPI::hasFailed; 
     164     
    164165  } catch (std::exception &e) { 
    165166    NSC_LOG_ERROR_STD(_T("Failed to send data: ") + to_wstring(e.what())); 
  • modules/Scheduler/Scheduler.cpp

    rc760fc9 rb7d17f8  
    109109    _T("SCHEDULE COMMAND"), _T("Command to execute")) 
    110110 
     111    (_T("alias"), sh::wstring_key(&item.alias, def==NULL?_T(""):def->alias), 
     112    _T("SCHEDULE ALIAS"), _T("The alias (service name) to report to server")) 
     113 
    111114    (_T("report"), sh::wstring_key(&report, def==NULL?_T("all"):nscapi::report::to_string(def->report)), 
    112115    _T("REPORT MODE"), _T("What to report to the server (any of the following: all, critical, warning, unknown, ok)")) 
     
    130133  scheduler::target item = read_schedule(path + _T("/") + alias, alias, &def); 
    131134  strEx::parse_command(item.command, item.command, item.arguments); 
     135  NSC_DEBUG_MSG_STD(_T("Adding scheduled task: ") + alias); 
    132136  scheduler_.add_task(item); 
    133137} 
  • service/CMakeLists.txt

    r7443b58 rb7d17f8  
    2424  NSCPlugin.cpp 
    2525  core_api.cpp 
    26   settings_manager_impl.cpp 
    2726  settings_logger_impl.cpp 
    2827 
     
    3433  ${NSCP_INCLUDEDIR}/arrayBuffer.cpp 
    3534 
     35  ../resources/nsclient.ico 
    3636) 
    3737 
     
    4545    NSCPlugin.h 
    4646    core_api.h 
    47     settings_manager_impl.h 
    48     settings_logger_impl.hpp 
    4947    simple_client.hpp 
    5048    settings_client.hpp 
     
    5452    channels.hpp 
    5553    logger.hpp 
     54    service_manager.hpp 
    5655    settings_logger_impl.hpp 
    57     service_manager.hpp 
    58      
    59     ${NSCP_INCLUDEDIR}/settings/Settings.h 
     56 
    6057    ${NSCP_INCLUDEDIR}/charEx.h 
    6158    ${NSCP_INCLUDEDIR}/config.h 
    6259    ${NSCP_INCLUDEDIR}/msvc_wrappers.h 
    63     ${NSCP_INCLUDEDIR}/settings/macros.h 
    64     ${NSCP_INCLUDEDIR}/settings/settings_ini.hpp 
    65     ${NSCP_INCLUDEDIR}/settings/settings_old.hpp 
    66     ${NSCP_INCLUDEDIR}/settings/settings_registry.hpp 
    67     ${NSCP_INCLUDEDIR}/settings/settings_core.hpp 
    68     ${NSCP_INCLUDEDIR}/settings/settings_core_impl.hpp 
    69     ${NSCP_INCLUDEDIR}/settings/settings_handler_impl.hpp 
    70     ${NSCP_INCLUDEDIR}/settings/settings_interface_impl.hpp 
    71     ${NSCP_INCLUDEDIR}/settings/client/settings_client.hpp 
    7260    ${NSCP_INCLUDEDIR}/com_helpers.hpp 
    7361    ${NSCP_INCLUDEDIR}/dll/dll.hpp 
     
    10997ENDIF(BREAKPAD_FOUND) 
    11098 
    111 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../files/old-settings.map ${CMAKE_CURRENT_BINARY_DIR}/old-settings.map COPYONLY) 
    112 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../files/counters.defs ${CMAKE_CURRENT_BINARY_DIR}/counters.defs COPYONLY) 
    113 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../files/license.txt ${CMAKE_CURRENT_BINARY_DIR}/license.txt COPYONLY) 
    114      
    11599add_executable (${TARGET} ${service_SRCS}) 
    116100add_dependencies(${TARGET} ${TARGET}_VERSION) 
     
    122106  ${NSCP_DEF_PLUGIN_LIB} 
    123107  ${EXTRA_LIBS} 
     108  settings_manager 
    124109) 
    125110SET_TARGET_PROPERTIES(${TARGET} PROPERTIES FOLDER "core") 
  • service/NSClient++.cpp

    rc391984 rb7d17f8  
    3333//#include <remote_processes.hpp> 
    3434#include "core_api.h" 
    35 #include "settings_manager_impl.h" 
     35#include "../helpers/settings_manager/settings_manager_impl.h" 
    3636#include <settings/macros.h> 
    3737#include "simple_client.hpp" 
    3838#include "settings_client.hpp" 
    3939#include "service_manager.hpp" 
     40#include "settings_logger_impl.hpp" 
    4041#include <nscapi/nscapi_helper.hpp> 
    4142#include <nscapi/functions.hpp> 
     
    237238} 
    238239#endif 
     240 
    239241int nscp_main(int argc, wchar_t* argv[]) 
    240242{ 
     
    243245  return parser.parse(argc, argv); 
    244246 
    245   int nRetCode = 0; 
    246   if ( (argc > 1) && ((*argv[1] == '-') || (*argv[1] == '/')) ) { 
    247     if (false) { 
    248     } else if ( wcscasecmp( _T("encrypt"), argv[1]+1 ) == 0 ) { 
    249       std::wstring password; 
    250       if (!settings_manager::init_settings()) { 
    251         std::wcout << _T("Could not find settings") << std::endl;; 
    252         return 1; 
    253       } 
    254       std::wcout << _T("Enter password to encrypt (has to be a single word): "); 
    255       std::wcin >> password; 
    256       std::wstring xor_pwd = Encrypt(password); 
    257       std::wcout << _T("obfuscated_password=") << xor_pwd << std::endl; 
    258       std::wstring outPasswd = Decrypt(xor_pwd); 
    259       if (password != outPasswd)  
    260         std::wcout << _T("ERROR: Password did not match: ") << outPasswd<< std::endl; 
    261       settings_manager::destroy_settings(); 
    262       return 0; 
    263     } else if ( wcscasecmp( _T("about"), argv[1]+1 ) == 0 ) { 
    264       try { 
    265         unsigned int next_plugin_id = 0; 
    266         LOG_INFO_CORE(APPLICATION_NAME _T(" (C) Michael Medin - michael<at>medin<dot>name")); 
    267         LOG_INFO_CORE(_T("Version: ") CURRENT_SERVICE_VERSION); 
    268         LOG_INFO_CORE(_T("Architecture: ") SZARCH); 
    269  
    270         boost::filesystem::wpath pluginPath = (boost::filesystem::wpath)mainClient.getBasePath() / _T("modules"); 
    271         LOG_INFO_CORE_STD(_T("Looking at plugins in: ") + pluginPath.string()); 
    272  
    273         boost::filesystem::wdirectory_iterator end_itr; // default construction yields past-the-end 
    274         for ( boost::filesystem::wdirectory_iterator itr( pluginPath ); itr != end_itr; ++itr ) { 
    275           if ( !is_directory(itr->status()) ) { 
    276             std::wstring file= itr->leaf(); 
    277             LOG_INFO_CORE_STD(_T("Found: ") + file); 
    278             if (is_module(pluginPath / file)) { 
    279               NSCPlugin *plugin = new NSCPlugin(next_plugin_id++, pluginPath / file, _T("")); 
    280               std::wstring name = _T("<unknown>"); 
    281               std::wstring description = _T("<unknown>"); 
    282               try { 
    283                 plugin->load_dll(); 
    284                 name = plugin->getName(); 
    285                 description = plugin->getDescription(); 
    286               } catch(NSPluginException& e) { 
    287                 LOG_ERROR_CORE_STD(_T("Exception raised: ") + e.error_ + _T(" in module: ") + e.file_); 
    288               } catch (std::exception e) { 
    289                 LOG_ERROR_CORE_STD(_T("exception loading plugin: ") + strEx::string_to_wstring(e.what())); 
    290               } catch (...) { 
    291                 LOG_ERROR_CORE_STD(_T("Unknown exception loading plugin")); 
    292               } 
    293               LOG_INFO_CORE_STD(_T("* ") + name + _T(" (") + file + _T(")")); 
    294               std::list<std::wstring> list = strEx::splitEx(description, _T("\n")); 
    295               for (std::list<std::wstring>::const_iterator cit = list.begin(); cit != list.end(); ++cit) { 
    296                 LOG_INFO_CORE_STD(_T("    ") + *cit); 
    297               } 
    298             } 
    299           } 
    300         } 
    301         LOG_INFO_CORE_STD(_T("Done listing plugins from: ") + pluginPath.string()); 
    302         return true; 
    303       } catch (std::exception &e) { 
    304         LOG_ERROR_CORE_STD(_T("Exception: ") + to_wstring(e.what())); 
    305       } catch (...) { 
    306         LOG_ERROR_CORE_STD(_T("Unknown Exception: ")); 
    307       } 
    308       return false; 
    309     } else if ( wcscasecmp( _T("version"), argv[1]+1 ) == 0 ) { 
    310       LOG_INFO_CORE(APPLICATION_NAME _T(", Version: ") CURRENT_SERVICE_VERSION _T(", Platform: ") SZARCH); 
    311     } else if ( wcscasecmp( _T("d"), argv[1]+1 ) == 0 ) { 
    312       // Run command from command line (like NRPE) but with debug enabled 
    313     } else if ( wcscasecmp( _T("noboot"), argv[1]+1 ) == 0 ) { 
    314       mainClient.enableDebug(false); 
    315       mainClient.initCore(false); 
    316       if (argc>=3) 
    317         nRetCode = mainClient.commandLineExec(argv[2], argc-3, &argv[3]); 
    318       else 
    319         nRetCode = mainClient.commandLineExec(argv[2], 0, NULL); 
    320       mainClient.exitCore(true); 
    321       return nRetCode; 
    322     } else if ( wcscasecmp( _T("c"), argv[1]+1 ) == 0 ) { 
    323       // Run command from command line (like NRPE) 
    324       mainClient.enableDebug(false); 
    325       mainClient.initCore(true); 
    326       std::wstring command, args, msg, perf; 
    327       if (argc > 2) 
    328         command = argv[2]; 
    329       for (int i=3;i<argc;i++) { 
    330         if (i!=3) args += _T(" "); 
    331         args += argv[i]; 
    332       } 
    333       nRetCode = mainClient.inject(command, args, msg, perf); 
    334       std::wcout << msg << _T("|") << perf << std::endl; 
    335       mainClient.exitCore(true); 
    336       return nRetCode; 
    337     } else { 
    338       std::wcerr << _T("Usage: -version, -about, -install, -uninstall, -start, -stop, -encrypt -settings") << std::endl; 
    339       std::wcerr << _T("Usage: [-noboot] <ModuleName> <commnd> [arguments]") << std::endl; 
    340       return -1; 
    341     } 
    342     return nRetCode; 
    343   } else if (argc > 2) { 
    344     std::wcout << _T(" * * * * * * * ") << std::endl; 
    345     mainClient.initCore(true); 
    346     if (argc>=3) 
    347       nRetCode = mainClient.commandLineExec(argv[1], argc-2, &argv[2]); 
    348     else 
    349       nRetCode = mainClient.commandLineExec(argv[1], 0, NULL); 
    350     mainClient.exitCore(true); 
    351     return nRetCode; 
    352   } 
    353   return nRetCode; 
     247// int nRetCode = 0; 
     248// if ( (argc > 1) && ((*argv[1] == '-') || (*argv[1] == '/')) ) { 
     249//    if (false) { 
     250//    } else if ( wcscasecmp( _T("encrypt"), argv[1]+1 ) == 0 ) { 
     251//      std::wstring password; 
     252//      if (!settings_manager::init_settings()) { 
     253//        std::wcout << _T("Could not find settings") << std::endl;; 
     254//        return 1; 
     255//      } 
     256//      std::wcout << _T("Enter password to encrypt (has to be a single word): "); 
     257//      std::wcin >> password; 
     258//      std::wstring xor_pwd = Encrypt(password); 
     259//      std::wcout << _T("obfuscated_password=") << xor_pwd << std::endl; 
     260//      std::wstring outPasswd = Decrypt(xor_pwd); 
     261//      if (password != outPasswd)  
     262//        std::wcout << _T("ERROR: Password did not match: ") << outPasswd<< std::endl; 
     263//      settings_manager::destroy_settings(); 
     264//      return 0; 
     265//    } else if ( wcscasecmp( _T("about"), argv[1]+1 ) == 0 ) { 
     266//      try { 
     267//        unsigned int next_plugin_id = 0; 
     268//        LOG_INFO_CORE(APPLICATION_NAME _T(" (C) Michael Medin - michael<at>medin<dot>name")); 
     269//        LOG_INFO_CORE(_T("Version: ") CURRENT_SERVICE_VERSION); 
     270//        LOG_INFO_CORE(_T("Architecture: ") SZARCH); 
     271//  
     272//        boost::filesystem::wpath pluginPath = (boost::filesystem::wpath)mainClient.getBasePath() / _T("modules"); 
     273//        LOG_INFO_CORE_STD(_T("Looking at plugins in: ") + pluginPath.string()); 
     274//  
     275//        boost::filesystem::wdirectory_iterator end_itr; // default construction yields past-the-end 
     276//        for ( boost::filesystem::wdirectory_iterator itr( pluginPath ); itr != end_itr; ++itr ) { 
     277//          if ( !is_directory(itr->status()) ) { 
     278//            std::wstring file= itr->leaf(); 
     279//            LOG_INFO_CORE_STD(_T("Found: ") + file); 
     280//            if (is_module(pluginPath / file)) { 
     281//              NSCPlugin *plugin = new NSCPlugin(next_plugin_id++, pluginPath / file, _T("")); 
     282//              std::wstring name = _T("<unknown>"); 
     283//              std::wstring description = _T("<unknown>"); 
     284//              try { 
     285//                plugin->load_dll(); 
     286//                name = plugin->getName(); 
     287//                description = plugin->getDescription(); 
     288//              } catch(NSPluginException& e) { 
     289//                LOG_ERROR_CORE_STD(_T("Exception raised: ") + e.error_ + _T(" in module: ") + e.file_); 
     290//              } catch (std::exception e) { 
     291//                LOG_ERROR_CORE_STD(_T("exception loading plugin: ") + strEx::string_to_wstring(e.what())); 
     292//              } catch (...) { 
     293//                LOG_ERROR_CORE_STD(_T("Unknown exception loading plugin")); 
     294//              } 
     295//              LOG_INFO_CORE_STD(_T("* ") + name + _T(" (") + file + _T(")")); 
     296//              std::list<std::wstring> list = strEx::splitEx(description, _T("\n")); 
     297//              for (std::list<std::wstring>::const_iterator cit = list.begin(); cit != list.end(); ++cit) { 
     298//                LOG_INFO_CORE_STD(_T("    ") + *cit); 
     299//              } 
     300//            } 
     301//          } 
     302//        } 
     303//        LOG_INFO_CORE_STD(_T("Done listing plugins from: ") + pluginPath.string()); 
     304//        return true; 
     305//      } catch (std::exception &e) { 
     306//        LOG_ERROR_CORE_STD(_T("Exception: ") + to_wstring(e.what())); 
     307//      } catch (...) { 
     308//        LOG_ERROR_CORE_STD(_T("Unknown Exception: ")); 
     309//      } 
     310//      return false; 
     311//    } else if ( wcscasecmp( _T("version"), argv[1]+1 ) == 0 ) { 
     312//      LOG_INFO_CORE(APPLICATION_NAME _T(", Version: ") CURRENT_SERVICE_VERSION _T(", Platform: ") SZARCH); 
     313//    } else if ( wcscasecmp( _T("d"), argv[1]+1 ) == 0 ) { 
     314//      // Run command from command line (like NRPE) but with debug enabled 
     315//    } else if ( wcscasecmp( _T("noboot"), argv[1]+1 ) == 0 ) { 
     316//      mainClient.enableDebug(false); 
     317//      mainClient.initCore(false); 
     318//      if (argc>=3) 
     319//        nRetCode = mainClient.commandLineExec(argv[2], argc-3, &argv[3]); 
     320//      else 
     321//        nRetCode = mainClient.commandLineExec(argv[2], 0, NULL); 
     322//      mainClient.exitCore(true); 
     323//      return nRetCode; 
     324//    } else if ( wcscasecmp( _T("c"), argv[1]+1 ) == 0 ) { 
     325//      // Run command from command line (like NRPE) 
     326//      mainClient.enableDebug(false); 
     327//      mainClient.initCore(true); 
     328//      std::wstring command, args, msg, perf; 
     329//      if (argc > 2) 
     330//        command = argv[2]; 
     331//      for (int i=3;i<argc;i++) { 
     332//        if (i!=3) args += _T(" "); 
     333//        args += argv[i]; 
     334//      } 
     335//      nRetCode = mainClient.inject(command, args, msg, perf); 
     336//      std::wcout << msg << _T("|") << perf << std::endl; 
     337//      mainClient.exitCore(true); 
     338//      return nRetCode; 
     339//    } else { 
     340//      std::wcerr << _T("Usage: -version, -about, -install, -uninstall, -start, -stop, -encrypt -settings") << std::endl; 
     341//      std::wcerr << _T("Usage: [-noboot] <ModuleName> <commnd> [arguments]") << std::endl; 
     342//      return -1; 
     343//    } 
     344//    return nRetCode; 
     345// } else if (argc > 2) { 
     346//    std::wcout << _T(" * * * * * * * ") << std::endl; 
     347//    mainClient.initCore(true); 
     348//    if (argc>=3) 
     349//      nRetCode = mainClient.commandLineExec(argv[1], argc-2, &argv[2]); 
     350//    else 
     351//      nRetCode = mainClient.commandLineExec(argv[1], 0, NULL); 
     352//    mainClient.exitCore(true); 
     353//    return nRetCode; 
     354// } 
     355// return nRetCode; 
    354356} 
    355357 
     
    495497// Service functions 
    496498 
     499 
     500struct nscp_settings_provider : public settings_manager::provider_interface { 
     501  virtual std::wstring expand_path(std::wstring file) { 
     502    return mainClient.expand_path(file); 
     503  } 
     504  virtual void log_fatal_error(std::wstring error) { 
     505    LOG_CRITICAL_CORE_STD(error); 
     506  } 
     507  virtual settings::logger_interface* create_logger() { 
     508    return new settings_logger(); 
     509  } 
     510}; 
     511 
     512 
     513nscp_settings_provider provider; 
     514 
    497515namespace sh = nscapi::settings_helper; 
    498516 
     
    507525  LOG_INFO_CORE(_T("Attempting to start")); 
    508526 
    509   if (!settings_manager::init_settings(context_)) { 
     527  if (!settings_manager::init_settings(&provider, context_)) { 
    510528    return false; 
    511529  } 
  • service/core_api.cpp

    r2d69ab6 rb7d17f8  
    2121#include <arrayBuffer.h> 
    2222#include <settings/settings_core.hpp> 
    23 #include "settings_manager_impl.h" 
     23#include "../helpers/settings_manager/settings_manager_impl.h" 
    2424#include <b64/b64.h> 
    2525#include <nscapi/nscapi_helper.hpp> 
  • service/settings_logger_impl.hpp

    r1ecd26f rb7d17f8  
    11#pragma once 
    22 
    3 #include "core_api.h" 
    4 #include "logger.hpp" 
    53#include <settings/settings_core.hpp> 
    64 
Note: See TracChangeset for help on using the changeset viewer.