(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 and 1.193.2.1

version 1.193, 2007/03/13 17:51:14 version 1.193.2.1, 2007/03/23 21:53:56
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 587 
Line 593 
         exit(1);         exit(1);
 #endif #endif
     }     }
     catch(Exception&)      catch(Exception& e)
     {     {
           cerr << "Shutdown failed: " << e.getMessage() << endl;
         //         //
         // This may mean that the CIM Server has terminated, causing this         // This may mean that the CIM Server has terminated, causing this
         // client to get a "Empty HTTP response message" exception.  It may         // client to get a "Empty HTTP response message" exception.  It may
Line 613 
Line 620 
     return;     return;
 } }
  
   #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
   
   static int _extractExecutorSockOpt(int& argc, char**& argv)
   {
       // Extract the "-x <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;
   
       for (int i = 1; i < argc; i++)
       {
           if (strcmp(argv[i], "-x") == 0)
           {
               // Check for missing option argument.
   
               if (i + 1 == argc)
               {
                   fprintf(stderr,
                       "%s: missing option argument for -x\n", argv[0]);
                   exit(1);
               }
   
               // Convert argument to integer.
   
               char* end;
               unsigned long x = strtoul(argv[i+1], &end, 10);
   
               // Check whether option argument will fit in integer.
   
               if (*end != '\0' || x > 2147483647)
               {
                   fprintf(stderr,
                       "%s: bad -x option argument: %s\n", argv[0], argv[i+1]);
                   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;
           }
       }
   
       return sock;
   }
   
   #endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */
  
 ///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
 //  MAIN //  MAIN
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
   
 int main(int argc, char** argv) int main(int argc, char** argv)
 { {
   #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
   
       // If invoked with "-x <socket>" option, then use executor.
   
       Executor::setSock(_extractExecutorSockOpt(argc, argv));
   
       // Ping executor to be sure the sock was valid.
   
       if (Executor::ping() != 0)
       {
           fprintf(stderr,
               "%s: failed to ping executor on socket given by -x option\n",
               argv[0]);
           exit(1);
       }
   
   #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
   
     String pegasusHome  = String::EMPTY;     String pegasusHome  = String::EMPTY;
     Boolean shutdownOption = false;     Boolean shutdownOption = false;
     Boolean debugOutputOption = false;     Boolean debugOutputOption = false;
Line 1178 
Line 1256 
     // 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 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 1381 
Line 1453 
         }         }
     // 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 1462 
Line 1539 
  
 #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 1534 
Line 1609 
     deleteCIMServer();     deleteCIMServer();
     return 0;     return 0;
 } }
   
   
   
   


Legend:
Removed from v.1.193  
changed lines
  Added in v.1.193.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2