(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.193.2.3 and 1.194

version 1.193.2.3, 2007/04/26 02:31:20 version 1.194, 2007/03/30 18:03:01
Line 123 
Line 123 
 # 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 593 
Line 587 
         exit(1);         exit(1);
 #endif #endif
     }     }
     catch(Exception& e)      catch(Exception&)
     {     {
         //         //
         // This may mean that the CIM Server has terminated, causing this         // This may mean that the CIM Server has terminated, causing this
Line 619 
Line 613 
     return;     return;
 } }
  
 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION  
   
 static int _extractExecutorSockOpt(int& argc, char**& argv)  
 {  
     // 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.  
   
     int sock = -1;  
     const char OPT[] = "--executor-socket";  
   
     for (int i = 1; i < argc; i++)  
     {  
         if (strcmp(argv[i], OPT) == 0)  
         {  
             // Check for missing option argument.  
   
             if (i + 1 == argc)  
             {  
                 MessageLoaderParms parms(  
                     "src.Server.cimserver.MISSING_OPTION_ARGUMENT",  
                     "Missing argument for $0 option.",  
                     OPT);  
                 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<  
                     endl;  
                 exit(1);  
             }  
   
             // Convert argument to positive integer.  
   
             char* end;  
             unsigned long x = strtoul(argv[i+1], &end, 10);  
   
             // Check whether option argument will fit in a signed integer.  
   
             if (*end != '\0' || x > 2147483647)  
             {  
                 MessageLoaderParms parms(  
                     "src.Server.cimserver.BAD_OPTION_ARGUMENT",  
                     "Bad $0 option argument: $1.",  
                     OPT,  
                     argv[i+1]);  
                 cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<  
                     endl;  
                 exit(1);  
             }  
   
             sock = int(x);  
   
             // Remove "-x <sock>" from argv-argc.  
   
             memmove(argv + i, argv + i + 2, sizeof(char*) * (argc - i - 1));  
             argc -= 2;  
             break;  
         }  
     }  
   
     if (sock == -1)  
     {  
         MessageLoaderParms parms(  
             "src.Server.cimserver.MISSING_OPTION",  
             "Missing $0 option.",  
             OPT);  
         cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;  
         exit(1);  
     }  
   
     return sock;  
 }  
   
 #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  = String::EMPTY;
Line 771 
Line 692 
   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 1275 
Line 1178 
     // Get the parent's PID before forking     // Get the parent's PID before forking
     _cimServerProcess->set_parent_pid(System::getPID());     _cimServerProcess->set_parent_pid(System::getPID());
  
 // Do not fork when using privilege separation (executor will daemonize itself      // do we need to run as a daemon ?
 // 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 1453 
Line 1362 
 # 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 defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)  
     if (daemonOption)  
         Executor::daemonizeExecutor();  
 #else  
     if (daemonOption)     if (daemonOption)
         _cimServerProcess->notify_parent(0);         _cimServerProcess->notify_parent(0);
 #endif  
  
     time_t last = 0;     time_t last = 0;
  
Line 1558 
Line 1446 
  
 #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 1598 
Line 1488 
     }     }
     catch(Exception& e)     catch(Exception& 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());
     Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,  
             "src.Server.cimserver.ERROR",  
             "Error: $0", e.getMessage());  
   
 #ifndef PEGASUS_OS_OS400  
     //l10n  
     //PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);  
     MessageLoaderParms parms("src.Server.cimserver.ERROR",  
                              "Error: $0", e.getMessage());  
     PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);  
  
           cerr << MessageLoader::getMessage(parms) << endl;
 #endif #endif
  
     //     //
Line 1628 
Line 1512 
     deleteCIMServer();     deleteCIMServer();
     return 0;     return 0;
 } }
   
   
   
   


Legend:
Removed from v.1.193.2.3  
changed lines
  Added in v.1.194

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2