(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.198 and 1.198.2.1

version 1.198, 2007/05/08 18:30:53 version 1.198.2.1, 2007/05/08 19:55:13
Line 121 
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 357 
Line 363 
    return((ThreadReturnType)0);    return((ThreadReturnType)0);
 } }
  
   #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 pegasusHome;
Line 436 
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 909 
Line 1006 
     // Get the parent's PID before forking     // Get the parent's PID before forking
     _serverRunStatus.setParentPid(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 1084 
Line 1175 
 #endif #endif
  
         _cimServer->bind();         _cimServer->bind();
   
         // 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
         }         }
  
 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \ #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \
Line 1156 
Line 1252 
  
 #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 1241 
Line 1335 
     deleteCIMServer();     deleteCIMServer();
     return 0;     return 0;
 } }
   


Legend:
Removed from v.1.198  
changed lines
  Added in v.1.198.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2