Changeset 5044c09 in nscp


Ignore:
Timestamp:
11/19/07 23:30:41 (6 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
df0ab60
Parents:
23c63eb
Message:

2007-11-19 MickeM

  • Fixed a minor issue in reading registry keys + Added -noboot option to startup used for running command line utilities without booting the client "nsclient++ -noboot RemoteConfigruation? ini2reg" for instance + Added fallback to try <module> and <module>.dll if the module was not loaded (when running command lines)
  • Migrated 2008 project files to new name and backported to 2005 project files.
Files:
26 added
5 edited

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    r23c63eb r5044c09  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,2,7,83 
    6 #define PRODUCTVER     0,2,7,181 
    7 #define STRFILEVER     "0.2.7.83" 
    8 #define STRPRODUCTVER  "0.2.7.181" 
    9 #define STRPRODUCTDATE  "2007-11-16" 
     5#define FILEVER        0,2,7,84 
     6#define PRODUCTVER     0,2,7,182 
     7#define STRFILEVER     "0.2.7.84" 
     8#define STRPRODUCTVER  "0.2.7.182" 
     9#define STRPRODUCTDATE  "2007-11-18" 
    1010#endif // AUTOBUILD_H 
  • NSClient++.cpp

    rb0ae738 r5044c09  
    104104      g_bConsoleLog = true; 
    105105      LOG_MESSAGE(SZAPPNAME " Version: " SZVERSION); 
     106    } else if ( _stricmp( "noboot", argv[1]+1 ) == 0 ) { 
     107      g_bConsoleLog = true; 
     108      int nRetCode = -1; 
     109      if (argc>=4) 
     110        nRetCode = mainClient.commandLineExec(argv[2], argv[3], argc-4, &argv[4]); 
     111      else if (argc>=3) 
     112        nRetCode = mainClient.commandLineExec(argv[2], argv[3], 0, NULL); 
     113      return nRetCode; 
    106114    } else if ( _stricmp( "test", argv[1]+1 ) == 0 ) { 
    107115#ifdef _DEBUG 
     
    144152    } else { 
    145153      LOG_MESSAGE("Usage: -version, -about, -install, -uninstall, -start, -stop, -encrypt"); 
    146       LOG_MESSAGE("Usage: <ModuleName> <commnd> [arguments]"); 
     154      LOG_MESSAGE("Usage: [-noboot] <ModuleName> <commnd> [arguments]"); 
    147155    } 
    148156    return nRetCode; 
     
    151159    mainClient.InitiateService(); 
    152160    if (argc>=3) 
    153       mainClient.commandLineExec(argv[1], argv[2], argc-3, &argv[3]); 
     161      nRetCode = mainClient.commandLineExec(argv[1], argv[2], argc-3, &argv[3]); 
    154162    else 
    155       mainClient.commandLineExec(argv[1], argv[2], 0, NULL); 
     163      nRetCode = mainClient.commandLineExec(argv[1], argv[2], 0, NULL); 
    156164    mainClient.TerminateService(); 
    157165    return nRetCode; 
     
    253261int NSClientT::commandLineExec(const char* module, const char* command, const unsigned int argLen, char** args) { 
    254262  std::string sModule = module; 
    255   ReadLock readLock(&m_mutexRW, true, 10000); 
    256   if (!readLock.IsLocked()) { 
    257     LOG_ERROR("FATAL ERROR: Could not get read-mutex."); 
    258     return -1; 
    259   } 
    260263  std::string moduleList = ""; 
    261   for (pluginList::size_type i=0;i<plugins_.size();++i) { 
    262     NSCPlugin *p = plugins_[i]; 
    263     if (!moduleList.empty()) 
    264       moduleList += ", "; 
    265     moduleList += p->getModule(); 
    266     if (p->getModule() == sModule) { 
    267       LOG_DEBUG_STD("Found module: " + p->getName() + "..."); 
    268       try { 
    269         return p->commandLineExec(command, argLen, args); 
    270       } catch (NSPluginException e) { 
    271         LOG_ERROR_STD("Could not execute command: " + e.error_ + " in " + e.file_); 
    272         return -1; 
    273       } 
    274     } 
     264  { 
     265    ReadLock readLock(&m_mutexRW, true, 10000); 
     266    if (!readLock.IsLocked()) { 
     267      LOG_ERROR("FATAL ERROR: Could not get read-mutex."); 
     268      return -1; 
     269    } 
     270    for (pluginList::size_type i=0;i<plugins_.size();++i) { 
     271      NSCPlugin *p = plugins_[i]; 
     272      if (!moduleList.empty()) 
     273        moduleList += ", "; 
     274      moduleList += p->getModule(); 
     275      if (p->getModule() == sModule) { 
     276        LOG_DEBUG_STD("Found module: " + p->getName() + "..."); 
     277        try { 
     278          return p->commandLineExec(command, argLen, args); 
     279        } catch (NSPluginException e) { 
     280          LOG_ERROR_STD("Could not execute command: " + e.error_ + " in " + e.file_); 
     281          return -1; 
     282        } 
     283      } 
     284    } 
     285  } 
     286  LOG_MESSAGE_STD("Module was not loaded, attempt to load it"); 
     287  try { 
     288    plugin_type plugin = loadPlugin(getBasePath() + "modules\\" + module); 
     289    LOG_DEBUG_STD("Loading plugin: " + plugin->getName() + "..."); 
     290    plugin->load_plugin(); 
     291    return plugin->commandLineExec(command, argLen, args); 
     292  } catch (NSPluginException e) { 
     293    LOG_MESSAGE_STD("Module (" + e.file_ + ") was not found: " + e.error_); 
     294  } 
     295  try { 
     296    plugin_type plugin = loadPlugin(getBasePath() + "modules\\" + module + ".dll"); 
     297    LOG_DEBUG_STD("Loading plugin: " + plugin->getName() + "..."); 
     298    plugin->load_plugin(); 
     299    return plugin->commandLineExec(command, argLen, args); 
     300  } catch (NSPluginException e) { 
     301    LOG_MESSAGE_STD("Module (" + e.file_ + ") was not found: " + e.error_); 
    275302  } 
    276303  LOG_ERROR_STD("Module not found: " + module + " available modules are: " + moduleList); 
     
    348375 * @param file The DLL file 
    349376 */ 
    350 void NSClientT::loadPlugin(const std::string file) { 
    351   addPlugin(new NSCPlugin(file)); 
     377NSClientT::plugin_type NSClientT::loadPlugin(const std::string file) { 
     378  return addPlugin(new NSCPlugin(file)); 
    352379} 
    353380/** 
     
    355382 * @param *plugin The plug-ininstance to load. The pointer is managed by the  
    356383 */ 
    357 void NSClientT::addPlugin(plugin_type plugin) { 
     384NSClientT::plugin_type NSClientT::addPlugin(plugin_type plugin) { 
    358385  plugin->load_dll(); 
    359386  { 
     
    361388    if (!writeLock.IsLocked()) { 
    362389      LOG_ERROR("FATAL ERROR: Could not get read-mutex."); 
    363       return; 
     390      return plugin; 
    364391    } 
    365392    plugins_.insert(plugins_.end(), plugin); 
     
    369396      messageHandlers_.insert(messageHandlers_.end(), plugin); 
    370397  } 
    371  
     398  return plugin; 
    372399} 
    373400 
  • NSClient++.h

    rb749b8d r5044c09  
    9292 
    9393  void addPlugins(const std::list<std::string> plugins); 
    94   void loadPlugin(const std::string plugin); 
     94  plugin_type loadPlugin(const std::string plugin); 
    9595  void loadPlugins(void); 
    9696  void unloadPlugins(void); 
     
    9999 
    100100private: 
    101   void addPlugin(plugin_type plugin); 
     101  plugin_type addPlugin(plugin_type plugin); 
    102102 
    103103}; 
  • changelog

    r23c63eb r5044c09  
    55 * Add module for relaying events 
    66 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 
     7 
     82007-11-19 MickeM 
     9 * Fixed a minor issue in reading registry keys 
     10 + Added -noboot option to startup used for running command line utilities without booting the client 
     11   "nsclient++ -noboot RemoteConfigruation ini2reg" for instance 
     12 + Added fallback to try <module> and <module>.dll if the module was nhot loaded (when running command lines) 
     13 * Migrated 2008 project files to new name and backported to 2005 project files. 
    714 
    8152007-11-16 MickeM 
  • include/REGSettings.h

    r860f310 r5044c09  
    55#include <TSettings.h> 
    66#include <msvc_wrappers.h> 
     7#include <error.hpp> 
    78#define BUFF_LEN 4096 
    89 
     
    126127        std::cout << "getString_::Unsupported type: " << lpszPath << "." << lpszKey << ": " << type << std::endl; 
    127128      } 
     129    } else if (lRet == ERROR_FILE_NOT_FOUND) { 
     130      return def; 
    128131    } else { 
    129       std::cout << "getString_::Error: " << lpszPath << "." << lpszKey << ": " << lRet << std::endl; 
     132      std::cout << "getString_::Error: " << lpszPath << "." << lpszKey << ": " << error::format::from_system(lRet) << std::endl; 
    130133    } 
    131134    RegCloseKey(hTemp); 
Note: See TracChangeset for help on using the changeset viewer.