(file) Return to cimserver.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Server

Diff for /pegasus/src/Server/cimserver.cpp between version 1.188 and 1.199

version 1.188, 2006/08/09 21:13:10 version 1.199, 2007/05/25 18:35:21
Line 29 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Mike Brasher (mbrasher@bmc.com)  
 //  
 // Modified By: Mike Day (mdday@us.ibm.com)  
 //              Karl Schopmeyer (k.schopmeyer@opengroup.org)  
 //              Nag Boranna (nagaraja_boranna@hp.com)  
 //              Jenny Yu (jenny_yu@hp.com)  
 //              Sushma Fernandes (sushma_fernandes@hp.com)  
 //              Carol Ann Krug Graves, Hewlett-Packard Company  
 //                  (carolann_graves@hp.com)  
 //              Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)  
 //              Dave Rosckes (rosckes@us.ibm.com)  
 //              Humberto Rivero (hurivero@us.ibm.com)  
 //              Steve Hills (steve.hills@ncr.com)  
 //              Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)  
 //              Amit K Arora, IBM (amitarora@in.ibm.com) - pep 167  
 //              Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) - Bug#2555  
 //              Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) - Bug#2032  
 //              Heather Sterling, IBM (hsterl@us.ibm.com) - PEP#222  
 //              Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) - Bug#3452  
 //              David Dillard, VERITAS Software Corp.  
 //                  (david.dillard@veritas.com)  
 //              Aruran, IBM (aruran.shanmug@in.ibm.com) for Bug# 4183, 4937  
 //              Thilo Boehm, IBM (tboehm@de.ibm.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
  
Line 100 
Line 76 
 // Alternatively, you can use the windows service manager. Pegasus shows up // Alternatively, you can use the windows service manager. Pegasus shows up
 // in the service database as "Pegasus CIM Object Manager" // in the service database as "Pegasus CIM Object Manager"
 // //
 // Mike Day, mdday@us.ibm.com  
 //  
 ////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
  
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/Constants.h> #include <Pegasus/Common/Constants.h>
 #include <Pegasus/Common/PegasusAssert.h> #include <Pegasus/Common/PegasusAssert.h>
 #include <cstdlib>  
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/Monitor.h> #include <Pegasus/Common/Monitor.h>
 #include <Pegasus/Common/PegasusVersion.h> #include <Pegasus/Common/PegasusVersion.h>
Line 118 
Line 91 
 #include <Pegasus/Common/LanguageParser.h> #include <Pegasus/Common/LanguageParser.h>
 #include <Pegasus/Config/ConfigManager.h> #include <Pegasus/Config/ConfigManager.h>
 #include <Pegasus/Client/CIMClient.h> #include <Pegasus/Client/CIMClient.h>
 #include <Pegasus/Server/ShutdownService.h>  
 #include <Pegasus/Server/CIMServer.h> #include <Pegasus/Server/CIMServer.h>
 #include <Service/ServerProcess.h> #include <Service/ServerProcess.h>
   #include <Service/ServerShutdownClient.h>
   #include <Service/ServerRunStatus.h>
  
 #if defined(PEGASUS_OS_OS400) #if defined(PEGASUS_OS_OS400)
 #  include "vfyptrs.cinc" #  include "vfyptrs.cinc"
Line 147 
Line 121 
 # include <fcntl.h> # include <fcntl.h>
 #endif #endif
  
   #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
   # define PEGASUS_PROCESS_NAME "cimservermain"
   #else
   # define PEGASUS_PROCESS_NAME "cimserver"
   #endif
   
   #include <Pegasus/Common/Executor.h>
   
 PEGASUS_USING_PEGASUS; PEGASUS_USING_PEGASUS;
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 #define PEGASUS_PROCESS_NAME "cimserver";  
   
 //Windows service variables are not defined elsewhere in the product //Windows service variables are not defined elsewhere in the product
 //enable ability to override these //enable ability to override these
 #ifndef PEGASUS_SERVICE_NAME #ifndef PEGASUS_SERVICE_NAME
Line 225 
Line 205 
     void cimserver_stop(void);     void cimserver_stop(void);
 }; };
  
   ServerRunStatus _serverRunStatus(
       PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess()); AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
 static CIMServer* _cimServer = 0; static CIMServer* _cimServer = 0;
 static Monitor* _monitor = 0; static Monitor* _monitor = 0;
Line 262 
Line 244 
  
 /** GetOptions function - This function defines the Options Table /** GetOptions function - This function defines the Options Table
     and sets up the options from that table using the config manager.     and sets up the options from that table using the config manager.
   
       Some possible exceptions:  NoSuchFile, FileNotReadable, CannotRenameFile,
       ConfigFileSyntaxError, UnrecognizedConfigProperty, InvalidPropertyValue,
       CannotOpenFile.
 */ */
 void GetOptions( void GetOptions(
     ConfigManager* cm,     ConfigManager* cm,
     int& argc,     int& argc,
     char** argv)      char** argv,
 {      Boolean shutdownOption)
     try  
     {  
         cm->mergeConfigFiles();  
   
         cm->mergeCommandLine(argc, argv);  
     }  
     catch (NoSuchFile&)  
     {  
         throw;  
     }  
     catch (FileNotReadable&)  
     {  
         throw;  
     }  
     catch (CannotRenameFile&)  
     {  
         throw;  
     }  
     catch (ConfigFileSyntaxError&)  
     {  
         throw;  
     }  
     catch(UnrecognizedConfigProperty&)  
     {     {
         throw;      if (shutdownOption)
     }  
     catch(InvalidPropertyValue&)  
     {     {
         throw;          cm->loadConfigFiles();
     }     }
     catch (CannotOpenFile&)      else
     {     {
         throw;          cm->mergeConfigFiles();
     }     }
   
       // Temporarily disable updates to the current configuration
       // file if shutdownOption is true
       cm->useConfigFiles = (shutdownOption==false);
   
       cm->mergeCommandLine(argc, argv);
   
       // Enable updates again
       cm->useConfigFiles = true;
 } }
  
 /* PrintHelp - This is temporary until we expand the options manager to allow /* PrintHelp - This is temporary until we expand the options manager to allow
Line 393 
Line 363 
    return((ThreadReturnType)0);    return((ThreadReturnType)0);
 } }
  
 //  #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 //  Waits until either the CIM Server has terminated, or the shutdown timeout  
 //  has expired.  If the shutdown timeout has expired, and the CIM Server is  
 //  still running, kills the cimserver process.  
 //  
 void _waitForTerminationOrTimeout (Uint32 maxWaitTime)  
 {  
     //  
     //  If the CIM Server is still running, and the shutdown timeout has not  
     //  expired, loop and wait one second until either the CIM Server has  
     //  terminated, or the shutdown timeout has expired  
     //  
     Boolean running = _cimServerProcess->isCIMServerRunning ();  
     while (running && (maxWaitTime > 0))  
     {  
         System::sleep (1);  
         running = _cimServerProcess->isCIMServerRunning ();  
         maxWaitTime--;  
     }  
  
     //  static int _extractExecutorSockOpt(int& argc, char**& argv)
     //  If the shutdown timeout has expired, and the CIM Server is still  
     //  running, kill the cimserver process  
     //  
     if (running)  
     {     {
         int kill_rc = _cimServerProcess->cimserver_kill (0);      // Extract the "--executor-socket <sock>" option if any. This indicates
       // that the e[x]ecutor is running. The option argument is the socket used
       // to communicate with the executor. Remove the option from the
       // argv list and decrease argc by two.
  
 #ifdef PEGASUS_OS_OS400      int sock = -1;
         if (kill_rc == -1)      const char OPT[] = "--executor-socket";
   
       for (int i = 1; i < argc; i++)
         {         {
             _cimServerProcess->cimserver_exitRC (2);          if (strcmp(argv[i], OPT) == 0)
         }          {
         _cimServerProcess->cimserver_exitRC (1);              // Check for missing option argument.
 #endif  
  
 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \              if (i + 1 == argc)
 || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_SOLARIS) \  
 || defined (PEGASUS_OS_VMS)  
         if (kill_rc != -1)  
         {         {
             //l10n - TODO                  MessageLoaderParms parms(
             Logger::put_l (Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,                      "src.Server.cimserver.MISSING_OPTION_ARGUMENT",
                 "src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",                      "Missing argument for $0 option.",
                 "Shutdown timeout expired.  Forced shutdown initiated.");                      OPT);
             MessageLoaderParms parms                  cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
                 ("src.Server.cimserver.TIMEOUT_EXPIRED_SERVER_KILLED",                      endl;
                 "Shutdown timeout expired.  Forced shutdown initiated.");                  exit(1);
             cout << MessageLoader::getMessage(parms) << endl;  
             exit (0);  
         }  
 #endif  
     }  
 } }
  
 void shutdownCIMOM(Uint32 timeoutValue)              // Convert argument to positive integer.
 {  
     //  
     // Create CIMClient object  
     //  
     CIMClient client;  
  
     //              char* end;
     // Get local host name              unsigned long x = strtoul(argv[i+1], &end, 10);
     //  
     String hostStr = System::getHostName();  
  
     //              // Check whether option argument will fit in a signed integer.
     // open connection to CIMOM  
     //  
     try  
     {  
         client.connectLocal();  
  
         //              if (*end != '\0' || x > 2147483647)
         // set client timeout to 2 seconds  
         //  
         client.setTimeout(2000);  
     }  
     catch(Exception&)  
     {     {
 #ifdef PEGASUS_OS_OS400                  MessageLoaderParms parms(
     //l10n                      "src.Server.cimserver.BAD_OPTION_ARGUMENT",
     //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,                      "Bad $0 option argument: $1.",
             //"Unable to connect to CIM Server.  CIM Server may not be running." );                      OPT,
     Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,                      argv[i+1]);
             "src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",                  cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
             "Unable to connect to CIM Server.  CIM Server may not be running." );                      endl;
     // The server job may still be active but not responding.  
     // Kill the job if it exists.  
     if(_cimServerProcess->cimserver_kill(0) == -1)  
        _cimServerProcess->cimserver_exitRC(2);  
     _cimServerProcess->cimserver_exitRC(1);  
 #else  
         //l10n  
         //PEGASUS_STD(cerr) << "Unable to connect to CIM Server." << PEGASUS_STD(endl);  
         //PEGASUS_STD(cerr) << "CIM Server may not be running." << PEGASUS_STD(endl);  
         MessageLoaderParms parms("src.Server.cimserver.UNABLE_CONNECT_SERVER_MAY_NOT_BE_RUNNING",  
                                                          "Unable to connect to CIM Server.\nCIM Server may not be running.\n");  
         PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);  
         exit(1);         exit(1);
 #endif  
     }     }
  
     try              sock = int(x);
     {  
         //  
         // construct CIMObjectPath  
         //  
         String referenceStr = "//";  
         referenceStr.append(hostStr);  
         referenceStr.append("/");  
         referenceStr.append(PEGASUS_NAMESPACENAME_SHUTDOWN.getString());  
         referenceStr.append(":");  
         referenceStr.append(PEGASUS_CLASSNAME_SHUTDOWN.getString());  
         CIMObjectPath reference(referenceStr);  
   
         //  
         // issue the invokeMethod request on the shutdown method  
         //  
         Array<CIMParamValue> inParams;  
         Array<CIMParamValue> outParams;  
  
         // set force option to true for now              // Remove "-x <sock>" from argv-argc.
         inParams.append(CIMParamValue("force",  
             CIMValue(Boolean(true))));  
  
         inParams.append(CIMParamValue("timeout",              memmove(argv + i, argv + i + 2, sizeof(char*) * (argc - i - 1));
             CIMValue(Uint32(timeoutValue))));              argc -= 2;
               break;
         CIMValue retValue = client.invokeMethod(  
             PEGASUS_NAMESPACENAME_SHUTDOWN,  
             reference,  
             "shutdown",  
             inParams,  
             outParams);  
     }  
     catch(CIMException& e)  
     {  
 #ifdef PEGASUS_OS_OS400  
   
     if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)  
     {  
         //l10n  
         //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,  
             //"Failed to shutdown server: $0", "The repository may be empty.");  
         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,  
             "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",  
             "Error in server shutdown: The repository may be empty.");  
     }  
     else  
     {  
         //l10n  
         //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,  
             //"Failed to shutdown server: $0", e.getMessage());  
         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,  
             "src.Server.cimserver.SHUTDOWN_FAILED",  
             "Error in server shutdown: $0", e.getMessage());  
     }     }
     // Kill the server job.  
     if(_cimServerProcess->cimserver_kill(0) == -1)  
        _cimServerProcess->cimserver_exitRC(2);  
 #else  
         //l10n - TODO  
         MessageLoaderParms parms("src.Server.cimserver.SHUTDOWN_FAILED",  
                                  "Error in server shutdown: ");  
         PEGASUS_STD(cerr) << MessageLoader::getMessage(parms);  
         if (e.getCode() == CIM_ERR_INVALID_NAMESPACE)  
         {  
             //  
             // Repository may be empty.  
             //  
             //l10n - TODO  
             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,  
                 "src.Server.cimserver.SHUTDOWN_FAILED_REPOSITORY_EMPTY",  
                 "Error in server shutdown: The repository may be empty.");  
             MessageLoaderParms parms("src.Server.cimserver.REPOSITORY_EMPTY",  
                                      "The repository may be empty.");  
             PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);  
         }  
         else  
         {  
             //l10n - TODO  
             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,  
                 "src.Server.cimserver.SHUTDOWN_FAILED",  
                 "Error in server shutdown: $0", e.getMessage());  
             PEGASUS_STD(cerr) << e.getMessage() << PEGASUS_STD(endl);  
         }         }
  
     // Kill the cimserver process      if (sock == -1)
     if (_cimServerProcess->cimserver_kill(0) == 0)  
         {         {
             //l10n - TODO          MessageLoaderParms parms(
             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,              "src.Server.cimserver.MISSING_OPTION",
                 "src.Server.cimserver.SERVER_FORCED_SHUTDOWN",              "Missing $0 option.",
             "Forced shutdown initiated.");              OPT);
             MessageLoaderParms parms("src.Server.cimserver.SERVER_FORCED_SHUTDOWN",          cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
                                      "Forced shutdown initiated.");  
             PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);  
         }  
         exit(1);         exit(1);
 #endif  
     }  
     catch(Exception&)  
     {  
         //  
         // This may mean that the CIM Server has terminated, causing this  
         // client to get a "Empty HTTP response message" exception.  It may  
         // also mean that the CIM Server is taking longer than 2 seconds  
         // (client timeout value) to terminate, causing this client to  
         // timeout with a "connection timeout" exception.  
         //  
         //  Wait until either the CIM Server has terminated, or the shutdown  
         //  timeout has expired.  If the timeout has expired and the CIM Server  
         //  is still running, kill the cimserver process.  
         //  
         _waitForTerminationOrTimeout (timeoutValue - 2);  
     }     }
  
     //      return sock;
     //  InvokeMethod succeeded.  
     //  Wait until either the CIM Server has terminated, or the shutdown  
     //  timeout has expired.  If the timeout has expired and the CIM Server  
     //  is still running, kill the cimserver process.  
     //  
     _waitForTerminationOrTimeout (timeoutValue);  
     return;  
 } }
  
   #endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */
  
 ///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
 //  MAIN //  MAIN
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
   
 int main(int argc, char** argv) int main(int argc, char** argv)
 { {
     String pegasusHome  = String::EMPTY;      String pegasusHome;
     Boolean shutdownOption = false;     Boolean shutdownOption = false;
     Boolean debugOutputOption = false;     Boolean debugOutputOption = false;
  
Line 701 
Line 515 
   pegasusHome = _cimServerProcess->getHome();   pegasusHome = _cimServerProcess->getHome();
 #endif #endif
  
   #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
   
       // If invoked with "--executor-socket <socket>" option, then use executor.
   
       Executor::setSock(_extractExecutorSockOpt(argc, argv));
   
       // Ping executor to verify the specified socket is valid.
   
       if (Executor::ping() != 0)
       {
           MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
               "Failed to ping the executor on the specified socket.");
           cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
           exit(1);
       }
   
   #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
   
         // Get help, version, and shutdown options         // Get help, version, and shutdown options
  
         for (int i = 1; i < argc; )         for (int i = 1; i < argc; )
Line 855 
Line 687 
     Boolean shutdownOption,     Boolean shutdownOption,
     Boolean debugOutputOption)     Boolean debugOutputOption)
 { {
     String logsDirectory = String::EMPTY;      String logsDirectory;
     Boolean daemonOption = false;     Boolean daemonOption = false;
  
     //     //
Line 903 
Line 735 
 #ifdef PEGASUS_OS_OS400 #ifdef PEGASUS_OS_OS400
     if (os400StartupOption == false)     if (os400StartupOption == false)
 #endif #endif
         GetOptions(configManager, argc, argv);          // If current process is "cimserver -s" (shutdown option = true) the contents
           // of current config should not be overwriten by planned config
           GetOptions(configManager, argc, argv, shutdownOption);
     }     }
     catch (Exception& e)     catch (Exception& e)
     {     {
Line 939 
Line 773 
     // one of the variables is true.     // one of the variables is true.
     Boolean enableHttpConnection = false;     Boolean enableHttpConnection = false;
     Boolean enableHttpsConnection = false;     Boolean enableHttpsConnection = false;
     Boolean enableSSLExportClientVerification = false;  
  
     if (os400StartupOption == false)     if (os400StartupOption == false)
     {     {
Line 947 
Line 780 
           configManager->getCurrentValue("enableHttpConnection"));           configManager->getCurrentValue("enableHttpConnection"));
       enableHttpsConnection = ConfigManager::parseBooleanValue(       enableHttpsConnection = ConfigManager::parseBooleanValue(
           configManager->getCurrentValue("enableHttpsConnection"));           configManager->getCurrentValue("enableHttpsConnection"));
       enableSSLExportClientVerification = ConfigManager::parseBooleanValue(  
           configManager->getCurrentValue("enableSSLExportClientVerification"));  
     }     }
 #else #else
     Boolean enableHttpConnection = ConfigManager::parseBooleanValue(     Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
         configManager->getCurrentValue("enableHttpConnection"));         configManager->getCurrentValue("enableHttpConnection"));
     Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(     Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
         configManager->getCurrentValue("enableHttpsConnection"));         configManager->getCurrentValue("enableHttpsConnection"));
     Boolean enableSSLExportClientVerification =  
         ConfigManager::parseBooleanValue(configManager->getCurrentValue(  
             "enableSSLExportClientVerification"));  
 #endif #endif
  
     // Make sure at least one connection is enabled     // Make sure at least one connection is enabled
Line 993 
Line 821 
     if (os400StartupOption == false)     if (os400StartupOption == false)
     {     {
 #endif #endif
         // Get the log file directory definition.  
         // We put String into Cstring because  
         // Directory functions only handle Cstring.  
         // ATTN-KS: create String based directory functions.  
 #if !defined(PEGASUS_USE_SYSLOGS) #if !defined(PEGASUS_USE_SYSLOGS)
                 // When using syslog facility. No files anymore.  
         logsDirectory = configManager->getCurrentValue("logdir");  
         logsDirectory =         logsDirectory =
         ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));         ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));
 #endif #endif
Line 1024 
Line 846 
             String configTimeout =             String configTimeout =
                 configManager->getCurrentValue("shutdownTimeout");                 configManager->getCurrentValue("shutdownTimeout");
             Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);             Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
   // To deregister Pegasus with SLP
   #ifdef PEGASUS_SLP_REG_TIMEOUT
               unregisterPegasusFromSLP();
   #endif
  
             shutdownCIMOM(timeoutValue);              ServerShutdownClient serverShutdownClient(&_serverRunStatus);
               serverShutdownClient.shutdown(timeoutValue);
  
 #ifdef PEGASUS_OS_OS400 #ifdef PEGASUS_OS_OS400
         //l10n  
         //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,  
             //"CIM Server stopped.");  
         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
             "src.Server.cimserver.SERVER_STOPPED",             "src.Server.cimserver.SERVER_STOPPED",
             "CIM Server stopped.");             "CIM Server stopped.");
             cimserver_exitRC(0);             cimserver_exitRC(0);
 #else #else
             //l10n              MessageLoaderParms parms(
             //cout << "CIM Server stopped." << endl;                  "src.Server.cimserver.SERVER_STOPPED",
             MessageLoaderParms parms("src.Server.cimserver.SERVER_STOPPED",  
                                      "CIM Server stopped.");                                      "CIM Server stopped.");
  
             cout << MessageLoader::getMessage(parms) << endl;             cout << MessageLoader::getMessage(parms) << endl;
Line 1046 
Line 869 
 #endif #endif
         }         }
  
 #if defined(PEGASUS_DEBUG)  #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
         // Leave this in until people get familiar with the logs.         // Leave this in until people get familiar with the logs.
         //l10n  
         //cout << "Logs Directory = " << logsDirectory << endl;  
 #if !defined(PEGASUS_USE_SYSLOGS)  
         MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",         MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
                                  "Logs Directory = ");                                  "Logs Directory = ");
         cout << MessageLoader::getMessage(parms) << logsDirectory << endl;         cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
 #endif #endif
 #endif  
     }     }
     catch (UnrecognizedConfigProperty& e)     catch (UnrecognizedConfigProperty& e)
     {     {
Line 1167 
Line 986 
             }             }
         }         }
     }     }
   
   
     if (enableSSLExportClientVerification)  
     {  
         //  
         // No config property is looked up to get the default port number.  
         // Lookup the port defined in /etc/services for the service name  
         // wbem-exp-https and bind to that port. If the service is  not defined  
         // then log a warning message and do not start the cimserver.  
         //  
         Uint32 port = 0;  
   
         portNumberExportHttps = System::lookupPort(WBEM_EXPORT_HTTPS_SERVICE_NAME, port);  
   
         if (portNumberExportHttps == 0)  
         {  
             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,  
                 "src.Server.cimserver.EXPORT_HTTPS_PORT_NOT_DEFINED",  
                 "Port not defined for the service wbem-exp-https. CIMServer will not be started.");  
   
             MessageLoaderParms parms("src.Server.cimserver.EXPORT_HTTPS_PORT_NOT_DEFINED",  
                 "Port not defined for the service wbem-exp-https. CIMServer will not be started.");  
   
             cerr << MessageLoader::getMessage(parms) << endl;  
   
             return(1);  
         }  
     }  
 #if defined(PEGASUS_DEBUG) #if defined(PEGASUS_DEBUG)
     // Put out startup up message.     // Put out startup up message.
     cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;     cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
Line 1213 
Line 1004 
 //l10n //l10n
  
     // Get the parent's PID before forking     // Get the parent's PID before forking
     _cimServerProcess->set_parent_pid(System::getPID());      _serverRunStatus.setParentPid(System::getPID());
  
     // do we need to run as a daemon ?  // Do not fork when using privilege separation (executor will daemonize itself
   // later).
     if (daemonOption)     if (daemonOption)
     {     {
         if(-1 == _cimServerProcess->cimserver_fork())         if(-1 == _cimServerProcess->cimserver_fork())
 #ifndef PEGASUS_OS_OS400 #ifndef PEGASUS_OS_OS400
     {  
         return(-1);         return(-1);
     }  
 #else #else
     {  
             return(-1);             return(-1);
     }  
     else     else
     {  
         return(0);         return(0);
     }  
 #endif #endif
   
     }     }
  
 // l10n // l10n
Line 1307 
Line 1092 
     // if CIMServer is already running, print message and     // if CIMServer is already running, print message and
     // notify parent process (if there is a parent process) to terminate     // notify parent process (if there is a parent process) to terminate
     //     //
     if(_cimServerProcess->isCIMServerRunning())      if (_serverRunStatus.isServerRunning())
     {     {
     //l10n          MessageLoaderParms parms(
         //cout << "Unable to start CIMServer." << endl;              "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
         //cout << "CIMServer is already running." << endl;              "Unable to start CIMServer. CIMServer is already running.");
         MessageLoaderParms parms("src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",          PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) <<
                      "Unable to start CIMServer.\nCIMServer is already running.");              PEGASUS_STD(endl);
     PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);          Logger::put(Logger::ERROR_LOG,System::CIMSERVER,Logger::INFORMATION,
               MessageLoader::getMessage(parms));
  
     //     //
         // notify parent process (if there is a parent process) to terminate         // notify parent process (if there is a parent process) to terminate
         //         //
         if (daemonOption)         if (daemonOption)
           {
                 _cimServerProcess->notify_parent(1);                 _cimServerProcess->notify_parent(1);
           }
  
         return(1);          return 1;
     }     }
  
 #endif #endif
Line 1330 
Line 1118 
     // try loop to bind the address, and run the server     // try loop to bind the address, and run the server
     try     try
     {     {
   
     _monitor  = new Monitor();     _monitor  = new Monitor();
     //PEP#222  
     //CIMServer server(&monitor);  
     //CimserverHolder cimserverHolder( &server );  
     _cimServer = new CIMServer(_monitor);     _cimServer = new CIMServer(_monitor);
  
   
         if (enableHttpConnection)         if (enableHttpConnection)
         {         {
             _cimServer->addAcceptor(false, portNumberHttp, false, false);              _cimServer->addAcceptor(false, portNumberHttp, false);
             //l10n  
             //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,  
                         //"Listening on HTTP port $0.", portNumberHttp);  
  
             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,              Logger::put_l(
                   Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                             "src.Server.cimserver.LISTENING_ON_HTTP_PORT",                             "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
                             "Listening on HTTP port $0.", portNumberHttp);                             "Listening on HTTP port $0.", portNumberHttp);
         }         }
   
         if (enableHttpsConnection)         if (enableHttpsConnection)
         {         {
             _cimServer->addAcceptor(false, portNumberHttps, true, false);              _cimServer->addAcceptor(false, portNumberHttps, true);
             //l10n  
             //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,              Logger::put_l(
                         //"Listening on HTTPS port $0.", portNumberHttps);                  Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,  
                             "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",                             "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
                             "Listening on HTTPS port $0.", portNumberHttps);                             "Listening on HTTPS port $0.", portNumberHttps);
         }         }
         if (enableSSLExportClientVerification)  
         {  
             _cimServer->addAcceptor(false, portNumberExportHttps, true, true);  
   
             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,  
                 "src.Server.cimserver.LISTENING_ON_EXPORT_HTTPS_PORT",  
                 "Listening on Export HTTPS port $0.", portNumberExportHttps);  
         }  
  
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
         _cimServer->addAcceptor(true, 0, false, false);          _cimServer->addAcceptor(true, 0, false);
         //l10n  
         //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,          Logger::put_l(
                     //"Listening on local connection socket.");              Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,  
               "src.Server.cimserver.LISTENING_ON_LOCAL",               "src.Server.cimserver.LISTENING_ON_LOCAL",
               "Listening on local connection socket.");               "Listening on local connection socket.");
 #endif #endif
Line 1381 
Line 1153 
 #if defined(PEGASUS_DEBUG) #if defined(PEGASUS_DEBUG)
         if (enableHttpConnection)         if (enableHttpConnection)
         {         {
             //l10n              MessageLoaderParms parms(
             //cout << "Listening on HTTP port " << portNumberHttp << endl;                  "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
       MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTP_PORT",  
                    "Listening on HTTP port $0.", portNumberHttp);                    "Listening on HTTP port $0.", portNumberHttp);
             cout << MessageLoader::getMessage(parms) << endl;             cout << MessageLoader::getMessage(parms) << endl;
         }         }
         if (enableHttpsConnection)         if (enableHttpsConnection)
         {         {
             //l10n              MessageLoaderParms parms(
             //cout << "Listening on HTTPS port " << portNumberHttps << endl;                  "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
             MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_HTTPS_PORT",  
                      "Listening on HTTPS port $0.", portNumberHttps);                      "Listening on HTTPS port $0.", portNumberHttps);
             cout << MessageLoader::getMessage(parms) << endl;             cout << MessageLoader::getMessage(parms) << endl;
         }         }
         if (enableSSLExportClientVerification)  
         {  
             MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_EXPORT_HTTPS_PORT",  
                 "Listening on Export HTTPS port $0.", portNumberExportHttps);  
   
             cout << MessageLoader::getMessage(parms) << endl;  
         }  
  
 # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
         //l10n          MessageLoaderParms parms(
         //cout << "Listening on local connection socket" << endl;              "src.Server.cimserver.LISTENING_ON_LOCAL",
         MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_LOCAL",  
                  "Listening on local connection socket.");                  "Listening on local connection socket.");
         cout << MessageLoader::getMessage(parms) << endl;         cout << MessageLoader::getMessage(parms) << endl;
 # endif # endif
 #endif #endif
  
         // bind throws an exception if the bind fails  
         try {  
            _cimServer->bind();            _cimServer->bind();
         } catch (const BindFailedException &e)  
         {  
 #ifdef PEGASUS_DEBUG  
         MessageLoaderParms parms("src.Server.cimserver.BIND_FAILED",  
                  "Could not bind: $0.", e.getMessage());  
         cout << MessageLoader::getMessage(parms) << endl;  
 #endif  
         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,  
             "src.Server.cimserver.BIND.FAILED",  
             "Could not bind:  $0", e.getMessage());  
  
            deleteCIMServer();  
            return 1;  
         }  
     // notify parent process (if there is a parent process) to terminate     // notify parent process (if there is a parent process) to terminate
         // so user knows that there is cimserver ready to serve CIM requests.         // so user knows that there is cimserver ready to serve CIM requests.
     if (daemonOption)     if (daemonOption)
           {
   #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
               Executor::daemonizeExecutor();
   #else
         _cimServerProcess->notify_parent(0);         _cimServerProcess->notify_parent(0);
   #endif
           }
  
     time_t last = 0;  #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \
       defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || \
 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) \      defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
     || defined(PEGASUS_OS_AIX) || defined(PEGASUS_OS_SOLARIS) \  
     || defined(PEGASUS_OS_VMS)  
         //         //
         // create a file to indicate that the cimserver has started and         // create a file to indicate that the cimserver has started and
         // save the process id of the cimserver process in the file         // save the process id of the cimserver process in the file
         //         //
         // remove the old file if it exists          _serverRunStatus.setServerRunning();
         System::removeFile(_cimServerProcess->getPIDFileName());  
   
         // open the file  
         FILE *pid_file = fopen(_cimServerProcess->getPIDFileName(), "w");  
   
         if (pid_file)  
         {  
             // save the pid in the file  
             fprintf(pid_file, "%ld\n", _cimServerProcess->get_server_pid());  
             fclose(pid_file);  
         }  
 #endif #endif
  
 #if defined(PEGASUS_DEBUG) #if defined(PEGASUS_DEBUG)
Line 1483 
Line 1223 
             Logger::INFORMATION,             Logger::INFORMATION,
             "src.Server.cimserver.STARTED_VERSION",             "src.Server.cimserver.STARTED_VERSION",
             "Started $0 version $1.",             "Started $0 version $1.",
                       _cimServerProcess->getProductName(), _cimServerProcess->getCompleteVersion());              _cimServerProcess->getProductName(),
               _cimServerProcess->getCompleteVersion());
  
 #if defined(PEGASUS_OS_TYPE_UNIX)  #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
         if (daemonOption && !debugOutputOption)         if (daemonOption && !debugOutputOption)
         {         {
             // Direct standard input, output, and error to /dev/null,             // Direct standard input, output, and error to /dev/null,
Line 1512 
Line 1253 
  
 #endif #endif
  
   
   
         //         //
         // Loop to call CIMServer's runForever() method until CIMServer         // Loop to call CIMServer's runForever() method until CIMServer
         // has been shutdown         // has been shutdown
Line 1552 
Line 1291 
         //         //
 #endif #endif
     }     }
     catch(Exception& e)      catch(BindFailedException& e)
     {     {
           Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
               "src.Server.cimserver.SERVER_NOT_STARTED",
               "cimserver not started:  $0", e.getMessage());
  
     //l10n  #if !defined(PEGASUS_OS_OS400)
     //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,          MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
             //"Error: $0", e.getMessage());              "cimserver not started: $0", e.getMessage());
   
           cerr << MessageLoader::getMessage(parms) << endl;
   #endif
   
       //
           // notify parent process (if there is a parent process) to terminate
           //
           if (daemonOption)
                   _cimServerProcess->notify_parent(1);
   
           deleteCIMServer();
           return 1;
       }
       catch(Exception& e)
       {
     Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,     Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
             "src.Server.cimserver.ERROR",             "src.Server.cimserver.ERROR",
             "Error: $0", e.getMessage());             "Error: $0", e.getMessage());
   
 #ifndef PEGASUS_OS_OS400 #ifndef PEGASUS_OS_OS400
     //l10n  
     //PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);  
     MessageLoaderParms parms("src.Server.cimserver.ERROR",     MessageLoaderParms parms("src.Server.cimserver.ERROR",
                              "Error: $0", e.getMessage());                              "Error: $0", e.getMessage());
     PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);     PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
   
 #endif #endif
   
     //     //
         // notify parent process (if there is a parent process) to terminate         // notify parent process (if there is a parent process) to terminate
         //         //
Line 1584 
Line 1336 
     deleteCIMServer();     deleteCIMServer();
     return 0;     return 0;
 } }
   
   
   
   


Legend:
Removed from v.1.188  
changed lines
  Added in v.1.199

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2