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

   1 karl  1.179 //%2006////////////////////////////////////////////////////////////////////////
   2 mike  1.32  //
   3 karl  1.141 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl  1.121 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.141 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl  1.149 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 karl  1.179 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12             // EMC Corporation; Symantec Corporation; The Open Group.
  13 mike  1.32  //
  14             // Permission is hereby granted, free of charge, to any person obtaining a copy
  15 kumpf 1.58  // of this software and associated documentation files (the "Software"), to
  16             // deal in the Software without restriction, including without limitation the
  17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18 mike  1.32  // sell copies of the Software, and to permit persons to whom the Software is
  19             // furnished to do so, subject to the following conditions:
  20 karl  1.179 // 
  21 kumpf 1.58  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22 mike  1.32  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24 kumpf 1.58  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27 mike  1.32  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29             //
  30             //==============================================================================
  31             //
  32             //%/////////////////////////////////////////////////////////////////////////////
  33             
  34             
  35             //////////////////////////////////////////////////////////////////////
  36             //
  37 carolann.graves 1.171 // Notes on daemon operation (Unix) and service operation (Win 32):
  38 mike            1.32  //
  39 david.dillard   1.165 // To run pegasus as a daemon on Unix platforms:
  40 mike            1.32  //
  41 kumpf           1.60  // cimserver
  42 mike            1.32  //
  43 kumpf           1.60  // To NOT run pegasus as a daemon on Unix platforms, set the daemon config
  44                       // property to false:
  45                       //
  46                       // cimserver daemon=false
  47                       //
  48 david.dillard   1.165 // The daemon config property has no effect on windows operation.
  49 mike            1.32  //
  50 mike            1.35  // To shutdown pegasus, use the -s option:
  51 david.dillard   1.165 //
  52                       // cimserver -s
  53 mike            1.35  //
  54 mike            1.32  // To run pegasus as an NT service, there are FOUR  different possibilities:
  55                       //
  56 david.dillard   1.165 // To INSTALL the Pegasus service,
  57 mike            1.32  //
  58                       // cimserver -install
  59                       //
  60 david.dillard   1.165 // To REMOVE the Pegasus service,
  61 mike            1.32  //
  62                       // cimserver -remove
  63                       //
  64 david.dillard   1.165 // To START the Pegasus service,
  65 mike            1.32  //
  66                       // net start cimserver
  67 s.hills         1.117 // or
  68                       // cimserver -start
  69 mike            1.32  //
  70 david.dillard   1.165 // To STOP the Pegasus service,
  71 mike            1.32  //
  72                       // net stop cimserver
  73 s.hills         1.117 // or
  74                       // cimserver -stop
  75 mike            1.32  //
  76 david.dillard   1.165 // Alternatively, you can use the windows service manager. Pegasus shows up
  77 mike            1.32  // in the service database as "Pegasus CIM Object Manager"
  78                       //
  79                       //////////////////////////////////////////////////////////////////////
  80                       
  81                       
  82 mike            1.35  #include <Pegasus/Common/Config.h>
  83 kumpf           1.59  #include <Pegasus/Common/Constants.h>
  84 jim.wunderlich  1.172 #include <Pegasus/Common/PegasusAssert.h>
  85 mike            1.32  #include <Pegasus/Common/FileSystem.h>
  86 mike            1.35  #include <Pegasus/Common/Monitor.h>
  87 mike            1.32  #include <Pegasus/Common/PegasusVersion.h>
  88                       #include <Pegasus/Common/Logger.h>
  89                       #include <Pegasus/Common/System.h>
  90 mike            1.35  #include <Pegasus/Common/Tracer.h>
  91 kumpf           1.174 #include <Pegasus/Common/LanguageParser.h>
  92 mike            1.35  #include <Pegasus/Config/ConfigManager.h>
  93                       #include <Pegasus/Client/CIMClient.h>
  94 h.sterling      1.153 #include <Pegasus/Server/CIMServer.h>
  95                       #include <Service/ServerProcess.h>
  96 kumpf           1.198 #include <Service/ServerShutdownClient.h>
  97                       #include <Service/ServerRunStatus.h>
  98 mike            1.32  
  99 thilo.boehm     1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) 
 100                       #include <Service/ARM_zOS.h>
 101 marek           1.186 # ifdef PEGASUS_ZOS_SECURITY
 102                       // This include file will not be provided in the OpenGroup CVS for now.
 103                       // Do NOT try to include it in your compile
 104                       #  include <Pegasus/Common/safCheckzOS_inline.h>
 105                       # endif
 106 thilo.boehm     1.185 #endif
 107                       
 108 kumpf           1.178 #if defined(PEGASUS_OS_TYPE_UNIX)
 109 ouyang.jian     1.200 # include <unistd.h>
 110 kumpf           1.178 # include <sys/types.h>
 111                       # include <sys/stat.h>
 112                       # include <fcntl.h>
 113 mateus.baur     1.175 #endif
 114                       
 115 kumpf           1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 116                       # define PEGASUS_PROCESS_NAME "cimservermain"
 117                       #else
 118                       # define PEGASUS_PROCESS_NAME "cimserver"
 119                       #endif
 120                       
 121                       #include <Pegasus/Common/Executor.h>
 122                       
 123 kumpf           1.119 PEGASUS_USING_PEGASUS;
 124                       PEGASUS_USING_STD;
 125                       
 126 h.sterling      1.153 //Windows service variables are not defined elsewhere in the product
 127                       //enable ability to override these
 128                       #ifndef PEGASUS_SERVICE_NAME
 129                       #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
 130 chuck           1.66  #endif
 131 h.sterling      1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
 132                       #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
 133 mike            1.32  #endif
 134                       
 135 h.sterling      1.153 class CIMServerProcess : public ServerProcess
 136                       {
 137                       public:
 138                       
 139                           CIMServerProcess(void)
 140                           {
 141                               cimserver_set_process(this);
 142                           }
 143                       
 144                           virtual ~CIMServerProcess(void)
 145                           {
 146                           }
 147                       
 148                           //defined in PegasusVersion.h
 149                           virtual const char* getProductName() const
 150                           {
 151                               return PEGASUS_PRODUCT_NAME;
 152                           }
 153                       
 154                           virtual const char* getExtendedName() const
 155                           {
 156 h.sterling      1.153         return PEGASUS_SERVICE_NAME;
 157                           }
 158                       
 159                           virtual const char* getDescription() const
 160                           {
 161                               return PEGASUS_SERVICE_DESCRIPTION;
 162                           }
 163 david.dillard   1.165 
 164 h.sterling      1.153     //defined in PegasusVersion.h
 165 jim.wunderlich  1.180     virtual const char* getCompleteVersion() const
 166                           {
 167 jim.wunderlich  1.181       if (*PEGASUS_PRODUCT_STATUS == '\0' )
 168 kumpf           1.199         return PEGASUS_PRODUCT_VERSION;
 169 jim.wunderlich  1.180       else
 170 kumpf           1.199         return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;      
 171 jim.wunderlich  1.180     }
 172                       
 173                           //defined in PegasusVersion.h
 174 h.sterling      1.153     virtual const char* getVersion() const
 175                           {
 176                               return PEGASUS_PRODUCT_VERSION;
 177                           }
 178                       
 179                           virtual const char* getProcessName() const
 180                           {
 181                               return PEGASUS_PROCESS_NAME;
 182                           }
 183                       
 184 kumpf           1.184     //defined in Constants.h
 185 h.sterling      1.153     virtual const char* getPIDFileName() const
 186                           {
 187 kumpf           1.184         return PEGASUS_CIMSERVER_START_FILE;
 188 h.sterling      1.153     }
 189                       
 190 kumpf           1.178     int cimserver_run(
 191                               int argc,
 192                               char** argv,
 193                               Boolean shutdownOption,
 194                               Boolean debugOutputOption);
 195 h.sterling      1.153 
 196                           void cimserver_stop(void);
 197                       };
 198                       
 199 kumpf           1.198 ServerRunStatus _serverRunStatus(
 200                           PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
 201 h.sterling      1.153 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
 202                       static CIMServer* _cimServer = 0;
 203 konrad.r        1.163 static Monitor* _monitor = 0;
 204 konrad.r        1.166 static Thread* dummyInitialThread = 0;
 205 mike            1.35  //
 206                       //  The command name.
 207                       //
 208                       static const char COMMAND_NAME []    = "cimserver";
 209                       
 210                       //
 211                       //  The constant defining usage string.
 212                       //
 213                       static const char USAGE []           = "Usage: ";
 214                       
 215                       /**
 216                       Constants representing the command line options.
 217                       */
 218                       static const char OPTION_VERSION     = 'v';
 219                       
 220                       static const char OPTION_HELP        = 'h';
 221                       
 222                       static const char OPTION_HOME        = 'D';
 223                       
 224                       static const char OPTION_SHUTDOWN    = 's';
 225                       
 226 a.arora         1.142 static const char   LONG_HELP []  = "help";
 227                       
 228                       static const char   LONG_VERSION []  = "version";
 229                       
 230 kumpf           1.178 static const char OPTION_DEBUGOUTPUT = 'X';
 231 kumpf           1.48  
 232 kumpf           1.54  static const String PROPERTY_TIMEOUT = "shutdownTimeout";
 233 mike            1.35  
 234                       ConfigManager*    configManager;
 235                       
 236 mike            1.32  /** GetOptions function - This function defines the Options Table
 237 mike            1.35      and sets up the options from that table using the config manager.
 238 kumpf           1.198 
 239                           Some possible exceptions:  NoSuchFile, FileNotReadable, CannotRenameFile,
 240                           ConfigFileSyntaxError, UnrecognizedConfigProperty, InvalidPropertyValue,
 241                           CannotOpenFile.
 242 mike            1.32  */
 243                       void GetOptions(
 244 mike            1.35      ConfigManager* cm,
 245 mike            1.32      int& argc,
 246 mateus.baur     1.193     char** argv,
 247 kumpf           1.198     Boolean shutdownOption)
 248 mike            1.32  {
 249 kumpf           1.198     if (shutdownOption)
 250                           {
 251                               cm->loadConfigFiles();
 252                           }
 253                           else
 254 mike            1.32      {
 255 kumpf           1.198         cm->mergeConfigFiles();
 256                           }
 257 mateus.baur     1.193 
 258 kumpf           1.198     // Temporarily disable updates to the current configuration
 259                           // file if shutdownOption is true
 260                           cm->useConfigFiles = (shutdownOption==false);
 261 mike            1.33  
 262 kumpf           1.198     cm->mergeCommandLine(argc, argv);
 263 mateus.baur     1.193 
 264 kumpf           1.198     // Enable updates again
 265                           cm->useConfigFiles = true;
 266 mike            1.32  }
 267                       
 268                       /* PrintHelp - This is temporary until we expand the options manager to allow
 269                          options help to be defined with the OptionRow entries and presented from
 270                          those entries.
 271                       */
 272                       void PrintHelp(const char* arg0)
 273                       {
 274 mike            1.35      String usage = String (USAGE);
 275                           usage.append (COMMAND_NAME);
 276                           usage.append (" [ [ options ] | [ configProperty=value, ... ] ]\n");
 277                           usage.append ("  options\n");
 278 a.arora         1.142     usage.append ("    -v, --version   - displays CIM Server version number\n");
 279                           usage.append ("    -h, --help      - prints this help message\n");
 280 humberto        1.97      usage.append ("    -s              - shuts down CIM Server\n");
 281 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 282                           usage.append ("    -D [home]       - sets pegasus home directory\n");
 283 humberto        1.97  #endif
 284                       #if defined(PEGASUS_OS_TYPE_WINDOWS)
 285 joyce.j         1.148     usage.append ("    -install [name] - installs pegasus as a Windows Service\n");
 286 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 287                           usage.append ("                      default CIM Server Service Name\n");
 288 aruran.ms       1.183     usage.append ("                      by appending [name]\n");
 289 joyce.j         1.148     usage.append ("    -remove [name]  - removes pegasus as a Windows Service\n");
 290 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 291                           usage.append ("                      default CIM Server Service Name\n");
 292 aruran.ms       1.183     usage.append ("                      by appending [name]\n");
 293 joyce.j         1.148     usage.append ("    -start [name]   - starts pegasus as a Windows Service\n");
 294 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 295                           usage.append ("                      default CIM Server Service Name\n");
 296 aruran.ms       1.183     usage.append ("                      by appending [name]\n");
 297 joyce.j         1.148     usage.append ("    -stop [name]    - stops pegasus as a Windows Service\n");
 298 humberto        1.97      usage.append ("                      [name] is optional and overrides the\n");
 299 aruran.ms       1.183     usage.append ("                      default CIM Server Service Name\n");
 300                           usage.append ("                      by appending [name]\n\n");
 301 humberto        1.97  #endif
 302                           usage.append ("  configProperty=value\n");
 303                           usage.append ("                    - sets CIM Server configuration property\n");
 304                       
 305                           cout << endl;
 306 jim.wunderlich  1.180     cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
 307 humberto        1.97      cout << endl;
 308 david.dillard   1.165 
 309 humberto        1.97  #if defined(PEGASUS_OS_TYPE_WINDOWS)
 310 humberto        1.104     MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
 311 kumpf           1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
 312 kumpf           1.138     MessageLoaderParms parms("src.Server.cimserver.MENU.HPUXLINUXIA64GNU", usage);
 313 humberto        1.97  #else
 314 kumpf           1.138     MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
 315 humberto        1.97  #endif
 316                           cout << MessageLoader::getMessage(parms) << endl;
 317 mike            1.35  }
 318                       
 319 h.sterling      1.156 //This needs to be called at various points in the code depending on the platform and error conditions.
 320                       //We need to delete the _cimServer reference on exit in order for the destructors to get called.
 321                       void deleteCIMServer()
 322                       {
 323                           if (_cimServer)
 324                           {
 325                               delete _cimServer;
 326                               _cimServer = 0;
 327 carolann.graves 1.171 
 328                       #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
 329                       || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
 330                       || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
 331                               //
 332                               //  Remove the PID file to indicate CIMServer termination
 333                               //
 334                               FileSystem::removeFile(_cimServerProcess->getPIDFileName());
 335                       #endif
 336 h.sterling      1.156     }
 337 kumpf           1.182     delete _monitor;
 338 konrad.r        1.166    if (dummyInitialThread)
 339                          {
 340 kumpf           1.199         Thread::clearLanguages();
 341                               delete dummyInitialThread;
 342 konrad.r        1.166    }
 343 h.sterling      1.156 }
 344                       
 345 chuck           1.96  // l10n
 346                       //
 347                       // Dummy function for the Thread object associated with the initial thread.
 348                       // Since the initial thread is used to process CIM requests, this is
 349                       // needed to localize the exceptions thrown during CIM request processing.
 350 david.dillard   1.165 // Note: This function should never be called!
 351                       //
 352 mike            1.188 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void *parm)
 353 chuck           1.96  {
 354 mike            1.188    return((ThreadReturnType)0);
 355 chuck           1.96  }
 356                       
 357 kumpf           1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 358                       
 359                       static int _extractExecutorSockOpt(int& argc, char**& argv)
 360                       {
 361                           // Extract the "--executor-socket <sock>" option if any. This indicates
 362                           // that the e[x]ecutor is running. The option argument is the socket used
 363                           // to communicate with the executor. Remove the option from the
 364                           // argv list and decrease argc by two.
 365                       
 366                           int sock = -1;
 367                           const char OPT[] = "--executor-socket";
 368                       
 369                           for (int i = 1; i < argc; i++)
 370                           {
 371                               if (strcmp(argv[i], OPT) == 0)
 372                               {
 373                                   // Check for missing option argument.
 374                       
 375                                   if (i + 1 == argc)
 376                                   {
 377                                       MessageLoaderParms parms(
 378 kumpf           1.199                     "src.Server.cimserver.MISSING_OPTION_ARGUMENT",
 379                                           "Missing argument for $0 option.",
 380                                           OPT);
 381                                       cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
 382                                           endl;
 383                                       exit(1);
 384                                   }
 385                       
 386                                   // Convert argument to positive integer.
 387                       
 388                                   char* end;
 389                                   unsigned long x = strtoul(argv[i+1], &end, 10);
 390                       
 391                                   // Check whether option argument will fit in a signed integer.
 392                       
 393                                   if (*end != '\0' || x > 2147483647)
 394                                   {
 395                                       MessageLoaderParms parms(
 396                                           "src.Server.cimserver.BAD_OPTION_ARGUMENT",
 397                                           "Bad $0 option argument: $1.",
 398                                           OPT,
 399 kumpf           1.199                     argv[i+1]);
 400                                       cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
 401                                           endl;
 402                                       exit(1);
 403                                   }
 404                       
 405                                   sock = int(x);
 406                       
 407                                   // Remove "-x <sock>" from argv-argc.
 408                       
 409                                   memmove(argv + i, argv + i + 2, sizeof(char*) * (argc - i - 1));
 410                                   argc -= 2;
 411                                   break;
 412                               }
 413                           }
 414                       
 415                           if (sock == -1)
 416                           {
 417                               MessageLoaderParms parms(
 418                                   "src.Server.cimserver.MISSING_OPTION",
 419                                   "Missing $0 option.",
 420 kumpf           1.199             OPT);
 421                               cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
 422                               exit(1);
 423                           }
 424                       
 425                           return sock;
 426                       }
 427                       
 428                       #endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */
 429 mike            1.35  
 430 mike            1.33  /////////////////////////////////////////////////////////////////////////
 431 mike            1.32  //  MAIN
 432                       //////////////////////////////////////////////////////////////////////////
 433 kumpf           1.199 
 434 mike            1.32  int main(int argc, char** argv)
 435                       {
 436 kumpf           1.196     String pegasusHome;
 437 mike            1.35      Boolean shutdownOption = false;
 438 kumpf           1.178     Boolean debugOutputOption = false;
 439 mday            1.47  
 440 humberto        1.97  //l10n
 441                       // Set Message loading to process locale
 442 david.dillard   1.165 MessageLoader::_useProcessLocale = true;
 443 humberto        1.97  //l10n
 444                       
 445 kv.le           1.140 //l10n
 446                       #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
 447                       setlocale(LC_ALL, "");
 448                       #endif
 449                       
 450 tony            1.82  #ifndef PEGASUS_OS_TYPE_WINDOWS
 451 kumpf           1.38      //
 452                           // Get environment variables:
 453                           //
 454 kv.le           1.134   #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
 455                           pegasusHome = AIX_RELEASE_PEGASUS_HOME;
 456 marek           1.170   #elif !defined(PEGASUS_USE_RELEASE_DIRS) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
 457 kumpf           1.38      const char* tmp = getenv("PEGASUS_HOME");
 458                       
 459                           if (tmp)
 460                           {
 461                               pegasusHome = tmp;
 462                           }
 463 kv.le           1.134   #endif
 464 kumpf           1.38  
 465                           FileSystem::translateSlashes(pegasusHome);
 466 tony            1.82  #else
 467 kumpf           1.38  
 468 tony            1.82    // windows only
 469 h.sterling      1.153   //setHome(pegasusHome);
 470                         pegasusHome = _cimServerProcess->getHome();
 471 tony            1.82  #endif
 472 mike            1.32  
 473 kumpf           1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 474                       
 475                           // If invoked with "--executor-socket <socket>" option, then use executor.
 476                       
 477                           Executor::setSock(_extractExecutorSockOpt(argc, argv));
 478                       
 479                           // Ping executor to verify the specified socket is valid.
 480                       
 481                           if (Executor::ping() != 0)
 482                           {
 483                               MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
 484                                   "Failed to ping the executor on the specified socket.");
 485                               cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
 486                               exit(1);
 487                           }
 488                       
 489                       #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
 490                       
 491 kumpf           1.60          // Get help, version, and shutdown options
 492 mike            1.35  
 493                               for (int i = 1; i < argc; )
 494                               {
 495                                   const char* arg = argv[i];
 496 a.arora         1.142             if(String::equal(arg,"--help"))
 497                                   {
 498                                           PrintHelp(argv[0]);
 499                                           exit(0);
 500                                   }
 501                                   else if(String::equal(arg,"--version"))
 502                                   {
 503 jim.wunderlich  1.180                 cout << _cimServerProcess->getCompleteVersion() << endl;
 504 a.arora         1.142                 exit(0);
 505                                   }
 506 mike            1.35              // Check for -option
 507 a.arora         1.142             else if (*arg == '-')
 508 mike            1.35              {
 509                                       // Get the option
 510                                       const char* option = arg + 1;
 511                       
 512                                       //
 513                                       // Check to see if user asked for the version (-v option):
 514                                       //
 515 tony            1.83                  if (*option == OPTION_VERSION &&
 516                                           strlen(option) == 1)
 517 mike            1.35                  {
 518 jim.wunderlich  1.180                     cout << _cimServerProcess->getCompleteVersion() << endl;
 519 mike            1.35                      exit(0);
 520                                       }
 521                                       //
 522                                       // Check to see if user asked for help (-h option):
 523                                       //
 524 tony            1.83                  else if (*option == OPTION_HELP &&
 525                                               (strlen(option) == 1))
 526 mike            1.35                  {
 527                                           PrintHelp(argv[0]);
 528                                           exit(0);
 529                                       }
 530 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 531 tony            1.83                  else if (*option == OPTION_HOME &&
 532                                               (strlen(option) == 1))
 533 mike            1.35                  {
 534 kumpf           1.60                      if (i + 1 < argc)
 535 mike            1.35                      {
 536                                               pegasusHome.assign(argv[i + 1]);
 537                                           }
 538                                           else
 539                                           {
 540 humberto        1.97                          //l10n
 541                                               //cout << "Missing argument for option -" << option << endl;
 542 humberto        1.99                          String opt(option);
 543 humberto        1.97                          MessageLoaderParms parms("src.Server.cimserver.MISSING_ARGUMENT",
 544 h.sterling      1.153                                          "Missing argument for option -$0",
 545                                                                opt);
 546                                               cout << MessageLoader::getMessage(parms) << endl;
 547 mike            1.35                          exit(0);
 548                                           }
 549                       
 550                                           memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
 551                                           argc -= 2;
 552                                       }
 553 kumpf           1.63  #endif
 554 kumpf           1.48                  //
 555 kumpf           1.178                 // Check to see if user asked for debug output (-X option):
 556 kumpf           1.48                  //
 557 kumpf           1.178                 else if (*option == OPTION_DEBUGOUTPUT &&
 558 tony            1.83                          (strlen(option) == 1))
 559 kumpf           1.48                  {
 560 kumpf           1.178                     MessageLoaderParms parms(
 561                                               "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
 562                                               "Unsupported debug output option is enabled.");
 563 h.sterling      1.153                     cout << MessageLoader::getMessage(parms) << endl;
 564 kumpf           1.178 
 565                                           debugOutputOption = true;
 566                       
 567                       #if defined(PEGASUS_OS_HPUX)
 568                                           System::bindVerbose = true;
 569                       #endif
 570                       
 571 kumpf           1.48                      // remove the option from the command line
 572                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 573 david.dillard   1.165                     argc--;
 574 kumpf           1.48                  }
 575 mike            1.35                  //
 576                                       // Check to see if user asked for shutdown (-s option):
 577                                       //
 578 tony            1.82                  else if (*option == OPTION_SHUTDOWN &&
 579                                               (strlen(option) == 1))
 580 mike            1.35                  {
 581                                           //
 582 kumpf           1.52                      // Check to see if shutdown has already been specified:
 583 mike            1.35                      //
 584 kumpf           1.52                      if (shutdownOption)
 585 mike            1.35                      {
 586 humberto        1.97                          //l10n
 587                                               //cout << "Duplicate shutdown option specified." << endl;
 588                                               MessageLoaderParms parms("src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
 589 h.sterling      1.153                                                  "Duplicate shutdown option specified.");
 590 david.dillard   1.165 
 591 humberto        1.97                          cout << MessageLoader::getMessage(parms) << endl;
 592 mike            1.35                          exit(0);
 593                                           }
 594                       
 595 kumpf           1.52                      shutdownOption = true;
 596 david.dillard   1.165 
 597 mike            1.35                      // remove the option from the command line
 598                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 599 david.dillard   1.165                     argc--;
 600 mike            1.35                  }
 601                                       else
 602                                           i++;
 603                                   }
 604                                   else
 605                                       i++;
 606 mike            1.32          }
 607 mike            1.35  
 608 kumpf           1.38      //
 609                           // Set the value for pegasusHome property
 610                           //
 611                           ConfigManager::setPegasusHome(pegasusHome);
 612 mike            1.32  
 613 mike            1.35      //
 614 carolann.graves 1.171     // Do the platform specific run
 615 s.hills         1.117     //
 616                       
 617 kumpf           1.178     return _cimServerProcess->platform_run(
 618                               argc, argv, shutdownOption, debugOutputOption);
 619 s.hills         1.117 }
 620                       
 621 h.sterling      1.153 void CIMServerProcess::cimserver_stop()
 622                       {
 623                           _cimServer->shutdownSignal();
 624                       }
 625 s.hills         1.117 
 626                       //
 627                       // The main, common, running code
 628                       //
 629 david.dillard   1.165 // NOTE: Do NOT call exit().  Use return(), otherwise some platforms
 630 s.hills         1.117 // will fail to shutdown properly/cleanly.
 631                       //
 632 david.dillard   1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
 633 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
 634 david.dillard   1.165 // daemon stuff into platform specific platform_run(), etc.
 635                       // Note: make sure to not put error handling stuff that platform
 636 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
 637 s.hills         1.117 //
 638                       
 639 kumpf           1.178 int CIMServerProcess::cimserver_run(
 640                           int argc,
 641                           char** argv,
 642                           Boolean shutdownOption,
 643                           Boolean debugOutputOption)
 644 s.hills         1.117 {
 645 kumpf           1.196     String logsDirectory;
 646 s.hills         1.117     Boolean daemonOption = false;
 647                       
 648                           //
 649 mike            1.35      // Get an instance of the Config Manager.
 650                           //
 651                           configManager = ConfigManager::getInstance();
 652 kumpf           1.136     configManager->useConfigFiles = true;
 653 mike            1.35  
 654                           //
 655 mike            1.32      // Get options (from command line and from configuration file); this
 656 mike            1.35      // removes corresponding options and their arguments from the command
 657 mike            1.32      // line.
 658 mike            1.35      //
 659 mike            1.32      try
 660                           {
 661 mateus.baur     1.193         // If current process is "cimserver -s" (shutdown option = true) the contents
 662                               // of current config should not be overwriten by planned config
 663                               GetOptions(configManager, argc, argv, shutdownOption);
 664 mike            1.32      }
 665                           catch (Exception& e)
 666                           {
 667 kumpf           1.127         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 668                                   "src.Server.cimserver.SERVER_NOT_STARTED",
 669                                   "cimserver not started:  $0", e.getMessage());
 670                       
 671                               MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 672                                   "cimserver not started: $0", e.getMessage());
 673                       
 674                               PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
 675                                   << PEGASUS_STD(endl);
 676                       
 677 s.hills         1.117         return(1);
 678 mike            1.32      }
 679                       
 680 chuck           1.94  // l10n
 681 h.sterling      1.153     // Set the home directory, msg sub-dir, into the MessageLoader.
 682 david.dillard   1.165     // This will be the default directory where the resource bundles
 683                           // are found.
 684 h.sterling      1.153     MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
 685 david.dillard   1.165         ConfigManager::getInstance()->getCurrentValue("messageDir")));
 686 chuck           1.94  
 687 kumpf           1.187     Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 688                               configManager->getCurrentValue("enableHttpConnection"));
 689                           Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 690                               configManager->getCurrentValue("enableHttpsConnection"));
 691 kumpf           1.86  
 692                           // Make sure at least one connection is enabled
 693 h.sterling      1.159 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 694 kumpf           1.86      if (!enableHttpConnection && !enableHttpsConnection)
 695                           {
 696 humberto        1.97          //l10n
 697                               //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 698                                   //"Neither HTTP nor HTTPS connection is enabled.  "
 699                                   //"CIMServer will not be started.");
 700                               Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 701 h.sterling      1.153             "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 702 humberto        1.97              "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");
 703                               //cerr << "Neither HTTP nor HTTPS connection is enabled.  "
 704                                   //"CIMServer will not be started." << endl;
 705                               MessageLoaderParms parms("src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 706 h.sterling      1.153                                  "Neither HTTP nor HTTPS connection is enabled.  CIMServer will not be started.");
 707 humberto        1.97          cerr << MessageLoader::getMessage(parms) << endl;
 708 s.hills         1.117         return(1);
 709 kumpf           1.86      }
 710                       #endif
 711                       
 712 mike            1.35      try
 713 mike            1.32      {
 714 mike            1.35          //
 715 kumpf           1.187         // Check to see if we should start Pegasus as a daemon
 716 mike            1.35          //
 717                       
 718 kumpf           1.187         daemonOption = ConfigManager::parseBooleanValue(
 719                                   configManager->getCurrentValue("daemon"));
 720 david.dillard   1.165 
 721 konrad.r        1.161 #if !defined(PEGASUS_USE_SYSLOGS)
 722 david.dillard   1.165         logsDirectory =
 723 h.sterling      1.153         ConfigManager::getHomedPath(configManager->getCurrentValue("logdir"));
 724 konrad.r        1.161 #endif
 725 kumpf           1.36  
 726                               // Set up the Logger. This does not open the logs
 727                               // Might be more logical to clean before set.
 728                               // ATTN: Need tool to completely disable logging.
 729                       
 730 david           1.85  #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \
 731 ouyang.jian     1.200 !defined(PEGASUS_USE_SYSLOGS)
 732 kumpf           1.36          Logger::setHomeDirectory(logsDirectory);
 733 kumpf           1.57  #endif
 734 kumpf           1.36  
 735                               //
 736 david.dillard   1.165         // Check to see if we need to shutdown CIMOM
 737 mike            1.35          //
 738                               if (shutdownOption)
 739                               {
 740 david.dillard   1.165             String configTimeout =
 741 kumpf           1.60                  configManager->getCurrentValue("shutdownTimeout");
 742 s.hills         1.117             Uint32 timeoutValue = strtol(configTimeout.getCString(), (char **)0, 10);
 743 dave.sudlik     1.191 // To deregister Pegasus with SLP
 744                       #ifdef PEGASUS_SLP_REG_TIMEOUT
 745                                   unregisterPegasusFromSLP();
 746                       #endif
 747 david.dillard   1.165 
 748 kumpf           1.198             ServerShutdownClient serverShutdownClient(&_serverRunStatus);
 749                                   serverShutdownClient.shutdown(timeoutValue);
 750 kumpf           1.45  
 751 kumpf           1.198             MessageLoaderParms parms(
 752                                       "src.Server.cimserver.SERVER_STOPPED",
 753                                       "CIM Server stopped.");
 754 humberto        1.106 
 755 humberto        1.97              cout << MessageLoader::getMessage(parms) << endl;
 756 s.hills         1.117             return(0);
 757 mike            1.35          }
 758 mike            1.32  
 759 kumpf           1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
 760 kumpf           1.36          // Leave this in until people get familiar with the logs.
 761 humberto        1.97          MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
 762 h.sterling      1.153                                  "Logs Directory = ");
 763 humberto        1.97          cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
 764 kumpf           1.57  #endif
 765 mike            1.32      }
 766 kumpf           1.122     catch (UnrecognizedConfigProperty& e)
 767 mike            1.32      {
 768 marek           1.186         // UnrecognizedConfigProperty is already translated
 769                               // thus, just output the message
 770                               Logger::put(Logger::ERROR_LOG,
 771                                           System::CIMSERVER,
 772                                           Logger::SEVERE,
 773                                           e.getMessage());
 774                               cout << e.getMessage() << endl;
 775                           }
 776                           catch (Exception& ex)
 777                           {
 778                               Logger::put(Logger::ERROR_LOG,
 779                                             System::CIMSERVER,
 780                                             Logger::SEVERE,
 781                                             ex.getMessage());
 782                               cout << ex.getMessage() << endl;
 783                               exit(1);
 784                           }
 785 david           1.85  
 786 marek           1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
 787                           startupCheckBPXServer(true);
 788                           startupCheckProfileCIMSERVclassWBEM();
 789                           startupEnableMSC();
 790 david           1.85  #endif
 791 mike            1.32  
 792 h.sterling      1.158     // Bug 2148 - Here is the order of operations for determining the server HTTP and HTTPS ports.
 793                           // 1) If the user explicitly specified a port, use it.
 794                           // 2) If the user did not specify a port, get the port from the services file.
 795                           // 3) If no value is specified in the services file, use the IANA WBEM default port.
 796                           // Note that 2 and 3 are done within the System::lookupPort method
 797                           // An empty string from the ConfigManager implies that the user did not specify a port.
 798                       
 799 w.otsuka        1.147     Uint32 portNumberHttps=0;
 800                           Uint32 portNumberHttp=0;
 801                           Uint32 portNumberExportHttps=0;
 802 kumpf           1.53  
 803 kumpf           1.86      if (enableHttpsConnection)
 804 kumpf           1.53      {
 805 kumpf           1.86          String httpsPort = configManager->getCurrentValue("httpsPort");
 806 h.sterling      1.158         if (httpsPort == String::EMPTY)
 807 joyce.j         1.144         {
 808 h.sterling      1.158             //
 809                                   // Look up the WBEM-HTTPS port number
 810                                   //
 811                                   portNumberHttps = System::lookupPort(WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
 812                       
 813                               } else
 814 david.dillard   1.165         {
 815 h.sterling      1.158             //
 816                                   // user-specified
 817                                   //
 818                                   CString portString = httpsPort.getCString();
 819                                   char* end = 0;
 820                                   portNumberHttps = strtol(portString, &end, 10);
 821                                   if(!(end != 0 && *end == '\0'))
 822                                   {
 823 joyce.j         1.160                 InvalidPropertyValue e("httpsPort", httpsPort);
 824 aruran.ms       1.173                 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 825                                                     "src.Server.cimserver.SERVER_NOT_STARTED",
 826                                                     "cimserver not started:  $0", e.getMessage());
 827                                       MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 828                                                                "cimserver not started: $0", e.getMessage());
 829                                       PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
 830                                                         << PEGASUS_STD(endl);
 831 h.sterling      1.158                 exit(1);
 832                                   }
 833 joyce.j         1.144         }
 834 kumpf           1.53      }
 835 kumpf           1.86  
 836                           if (enableHttpConnection)
 837 kumpf           1.53      {
 838 kumpf           1.86          String httpPort = configManager->getCurrentValue("httpPort");
 839 h.sterling      1.158         if (httpPort == String::EMPTY)
 840 joyce.j         1.144         {
 841 h.sterling      1.158             //
 842                                   // Look up the WBEM-HTTP port number
 843                                   //
 844                                   portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
 845                       
 846                               } else
 847                               {
 848                                   //
 849                                   // user-specified
 850                                   //
 851                                   CString portString = httpPort.getCString();
 852                                   char* end = 0;
 853                                   portNumberHttp = strtol(portString, &end, 10);
 854                                   if(!(end != 0 && *end == '\0'))
 855                                   {
 856 joyce.j         1.160                 InvalidPropertyValue e("httpPort", httpPort);
 857 aruran.ms       1.173                 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 858                                                     "src.Server.cimserver.SERVER_NOT_STARTED",
 859                                                     "cimserver not started:  $0", e.getMessage());
 860                                       MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 861                                                                    "cimserver not started: $0", e.getMessage());
 862                                       PEGASUS_STD(cerr) << argv[0] << ": " << MessageLoader::getMessage(parms)
 863                                                         << PEGASUS_STD(endl);
 864 h.sterling      1.158                 exit(1);
 865                                   }
 866 joyce.j         1.144         }
 867 kumpf           1.53      }
 868 kumpf           1.139 #if defined(PEGASUS_DEBUG)
 869 mike            1.32      // Put out startup up message.
 870 jim.wunderlich  1.180     cout << _cimServerProcess->getProductName() << " " << _cimServerProcess->getCompleteVersion() << endl;
 871 humberto        1.97      //l10n
 872                           //cout << "Built " << __DATE__ << " " << __TIME__ << endl;
 873                           //cout <<"Starting..."
 874                           MessageLoaderParms parms("src.Server.cimserver.STARTUP_MESSAGE",
 875 h.sterling      1.153                              "Built $0 $1\nStarting...",
 876                                                    __DATE__,
 877                                                    __TIME__);
 878 humberto        1.97  #endif
 879                       
 880                       //l10n
 881                       // reset message loading to NON-process locale
 882 david.dillard   1.165 MessageLoader::_useProcessLocale = false;
 883 humberto        1.97  //l10n
 884 mike            1.32  
 885 kumpf           1.137     // Get the parent's PID before forking
 886 kumpf           1.198     _serverRunStatus.setParentPid(System::getPID());
 887 david.dillard   1.165 
 888 kumpf           1.199 // Do not fork when using privilege separation (executor will daemonize itself
 889                       // later).
 890 kumpf           1.63      if (daemonOption)
 891                           {
 892 h.sterling      1.153         if(-1 == _cimServerProcess->cimserver_fork())
 893 david           1.85              return(-1);
 894 kumpf           1.63      }
 895 chuck           1.66  
 896 chuck           1.96  // l10n
 897                           // Now we are after the fork...
 898                           // Create a dummy Thread object that can be used to store the
 899 kumpf           1.176     // AcceptLanguageList object for CIM requests that are serviced
 900 chuck           1.96      // by this thread (initial thread of server).  Need to do this
 901                           // because this thread is not in a ThreadPool, but is used
 902                           // to service CIM requests.
 903                           // The run function for the dummy Thread should never be called,
 904 konrad.r        1.166     dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
 905 david.dillard   1.165     Thread::setCurrent(dummyInitialThread);
 906 kumpf           1.176     AcceptLanguageList default_al;
 907 humberto        1.108     try{
 908 kumpf           1.174          default_al = LanguageParser::getDefaultAcceptLanguages();
 909 kumpf           1.176          Thread::setLanguages(new AcceptLanguageList(default_al));
 910 kumpf           1.122     }catch(InvalidAcceptLanguageHeader& e){
 911 h.sterling      1.153           Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 912                                         "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
 913 david.dillard   1.165                   "Could not convert the system process locale into a valid AcceptLanguage format.");
 914 h.sterling      1.153           Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 915 david.dillard   1.165                              e.getMessage());
 916 humberto        1.108     }
 917 david.dillard   1.165 
 918 kumpf           1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
 919                           umask(S_IRWXG|S_IRWXO);
 920                       #endif
 921 mday            1.62  
 922 mateus.baur     1.175 
 923                       #if defined(PEGASUS_OS_TYPE_UNIX)
 924                         //    
 925                         // CRITICAL SECTION BEGIN
 926                         //
 927                         // This is the beginning of the critical section regarding the
 928                         // access to pidfile (file to indicate that the cimserver has started).
 929                         // Sometimes, when 2 or more cimserver processes are started at the same 
 930                         // time, they can't detect the concurrent process execution because the 
 931                         // logic fails when pidfile is accessed concurrently.
 932                       
 933                         FILE *startupLockFile;
 934                       
 935 denise.eckstein 1.177   if ((startupLockFile = fopen(ConfigManager::getHomedPath(
 936                                 CIMSERVER_LOCK_FILE).getCString(), "w")) != 0)
 937 mateus.baur     1.175   {
 938                             lockf(fileno(startupLockFile), F_LOCK, 0);
 939                         }
 940                       #endif
 941                       
 942 gs.keenan       1.150 #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) \
 943                       || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
 944 jim.wunderlich  1.169 || defined(PEGASUS_OS_SOLARIS) || defined (PEGASUS_OS_VMS)
 945 kumpf           1.79  
 946                           //
 947                           // check if CIMServer is already running
 948 david.dillard   1.165     // if CIMServer is already running, print message and
 949 kumpf           1.79      // notify parent process (if there is a parent process) to terminate
 950                           //
 951 kumpf           1.198     if (_serverRunStatus.isServerRunning())
 952 kumpf           1.79      {
 953 kumpf           1.198         MessageLoaderParms parms(
 954                                   "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
 955                                   "Unable to start CIMServer. CIMServer is already running.");
 956                               PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) <<
 957                                   PEGASUS_STD(endl);
 958 thilo.boehm     1.192         Logger::put(Logger::ERROR_LOG,System::CIMSERVER,Logger::INFORMATION,
 959 kumpf           1.198             MessageLoader::getMessage(parms));
 960 kumpf           1.79  
 961 kumpf           1.198         //
 962 kumpf           1.79          // notify parent process (if there is a parent process) to terminate
 963                               //
 964                               if (daemonOption)
 965 kumpf           1.198         {
 966                                   _cimServerProcess->notify_parent(1);
 967                               }
 968 kumpf           1.79  
 969 kumpf           1.198         return 1;
 970 kumpf           1.79      }
 971 david.dillard   1.165 
 972 kumpf           1.63  #endif
 973 kumpf           1.51  
 974 mike            1.32      // try loop to bind the address, and run the server
 975                           try
 976                           {
 977 kumpf           1.198         _monitor = new Monitor();
 978                               _cimServer = new CIMServer(_monitor);
 979 kumpf           1.41  
 980 kumpf           1.86          if (enableHttpConnection)
 981                               {
 982 venkat.puvvada  1.201.2.1 #ifndef PEGASUS_DISABLE_IPV6
 983                                       _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
 984                                           portNumberHttp, false);
 985                           #endif
 986                           
 987                           #if !defined(PEGASUS_DISABLE_IPV6) && defined(PEGASUS_OS_TYPE_WINDOWS) \
 988                                   || defined (PEGASUS_DISABLE_IPV6)
 989                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
 990                                           portNumberHttp, false);
 991                           #endif
 992 kumpf           1.198     
 993                                       Logger::put_l(
 994                                           Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 995                                           "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
 996                                           "Listening on HTTP port $0.", portNumberHttp);
 997 kumpf           1.86              }
 998 kumpf           1.198     
 999 kumpf           1.86              if (enableHttpsConnection)
1000                                   {
1001 venkat.puvvada  1.201.2.1 #ifndef PEGASUS_DISABLE_IPV6
1002                                       _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1003                                           portNumberHttps, true);
1004                           #endif
1005 kumpf           1.198     
1006 venkat.puvvada  1.201.2.1 #if !defined(PEGASUS_DISABLE_IPV6) && defined(PEGASUS_OS_TYPE_WINDOWS) \
1007                                   || defined (PEGASUS_DISABLE_IPV6)
1008                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1009                                           portNumberHttps, true);
1010                           #endif
1011 kumpf           1.198                 Logger::put_l(
1012                                           Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1013                                           "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1014                                           "Listening on HTTPS port $0.", portNumberHttps);
1015 kumpf           1.86              }
1016 kumpf           1.135     
1017 h.sterling      1.159     #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1018 venkat.puvvada  1.201.2.1         _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
1019 kumpf           1.198     
1020                                   Logger::put_l(
1021                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1022                                       "src.Server.cimserver.LISTENING_ON_LOCAL",
1023                                       "Listening on local connection socket.");
1024 kumpf           1.41      #endif
1025 kumpf           1.86      
1026 kumpf           1.139     #if defined(PEGASUS_DEBUG)
1027 kumpf           1.86              if (enableHttpConnection)
1028                                   {
1029 kumpf           1.198                 MessageLoaderParms parms(
1030                                           "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1031                                           "Listening on HTTP port $0.", portNumberHttp);
1032 h.sterling      1.153                 cout << MessageLoader::getMessage(parms) << endl;
1033 kumpf           1.86              }
1034                                   if (enableHttpsConnection)
1035                                   {
1036 kumpf           1.198                 MessageLoaderParms parms(
1037                                           "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1038                                           "Listening on HTTPS port $0.", portNumberHttps);
1039 h.sterling      1.153                 cout << MessageLoader::getMessage(parms) << endl;
1040 kumpf           1.86              }
1041 kumpf           1.135     
1042 h.sterling      1.159     # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1043 kumpf           1.198             MessageLoaderParms parms(
1044                                       "src.Server.cimserver.LISTENING_ON_LOCAL",
1045                                       "Listening on local connection socket.");
1046 humberto        1.97              cout << MessageLoader::getMessage(parms) << endl;
1047 kumpf           1.86      # endif
1048 david           1.85      #endif
1049 mike            1.35      
1050 kumpf           1.198             _cimServer->bind();
1051 kumpf           1.199     
1052 kumpf           1.198             // notify parent process (if there is a parent process) to terminate
1053 konrad.r        1.95              // so user knows that there is cimserver ready to serve CIM requests.
1054 kumpf           1.198             if (daemonOption)
1055                                   {
1056 kumpf           1.199     #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
1057                                       Executor::daemonizeExecutor();
1058                           #else
1059 kumpf           1.198                 _cimServerProcess->notify_parent(0);
1060 kumpf           1.199     #endif
1061 kumpf           1.198             }
1062 mike            1.35      
1063 kumpf           1.198     #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || \
1064                               defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) || \
1065                               defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
1066 kumpf           1.45              //
1067 kumpf           1.56              // create a file to indicate that the cimserver has started and
1068                                   // save the process id of the cimserver process in the file
1069 kumpf           1.45              //
1070 kumpf           1.198             _serverRunStatus.setServerRunning();
1071 kumpf           1.45      #endif
1072 kumpf           1.91      
1073 kumpf           1.139     #if defined(PEGASUS_DEBUG)
1074 h.sterling      1.153         cout << "Started. " << endl;
1075 kumpf           1.63      #endif
1076 david.dillard   1.165     
1077 mateus.baur     1.175     #if defined(PEGASUS_OS_TYPE_UNIX)    
1078                               //
1079                               // CRITICAL SECTION END
1080                               // 
1081                               // Here is the unlock of file 'lock_file'. It closes the
1082                               // the critical section that guarantees the non concurrent access to
1083                               // pid file (file to indicate that the cimserver has started).
1084                               //
1085                           
1086                               if (startupLockFile)
1087                               {
1088                                  lockf(fileno(startupLockFile), F_ULOCK, 0);
1089                                  fclose(startupLockFile);
1090                               }
1091                           #endif
1092                           
1093                           
1094 kumpf           1.54              // Put server started message to the logger
1095 kumpf           1.143             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1096                                       Logger::INFORMATION,
1097                                       "src.Server.cimserver.STARTED_VERSION",
1098                                       "Started $0 version $1.",
1099 kumpf           1.199                 _cimServerProcess->getProductName(),
1100                                       _cimServerProcess->getCompleteVersion());
1101 kumpf           1.45      
1102 marek           1.190     #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
1103 kumpf           1.178             if (daemonOption && !debugOutputOption)
1104                                   { 
1105                                       // Direct standard input, output, and error to /dev/null,
1106                                       // since we are running as a daemon.
1107                                       close(0);
1108                                       open("/dev/null", O_RDONLY);
1109                                       close(1);
1110                                       open("/dev/null", O_RDWR);
1111                                       close(2);
1112                                       open("/dev/null", O_RDWR);
1113                                   }
1114                           #endif
1115                           
1116 thilo.boehm     1.185     #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1117                           
1118                                   // ARM is a z/OS internal restart facility. 
1119                                   // This is a z/OS specific change. 
1120                           
1121                                   // Instatiating the automatic restart manager for zOS
1122                                   ARM_zOS automaticRestartManager;
1123                           
1124                                   // register to zOS ARM
1125                                   automaticRestartManager.Register();
1126                           
1127                           #endif
1128                           
1129 mike            1.35              //
1130                                   // Loop to call CIMServer's runForever() method until CIMServer
1131                                   // has been shutdown
1132                                   //
1133 h.sterling      1.153         while( !_cimServer->terminated() )
1134                               {
1135 mday            1.116     
1136 h.sterling      1.153           _cimServer->runForever();
1137 mday            1.112     
1138 h.sterling      1.153         }
1139 carson.hovey    1.157     
1140 kumpf           1.45              //
1141                                   // normal termination
1142 carson.hovey    1.157             //
1143 thilo.boehm     1.185     #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1144                           
1145                                   // ARM is a z/OS internal restart facility. 
1146                                   // This is a z/OS specific change. 
1147                           
1148                                   // register to zOS ARM
1149                                   automaticRestartManager.DeRegister();
1150                           
1151                           #endif
1152 kumpf           1.143     
1153 kumpf           1.54              // Put server shutdown message to the logger
1154 kumpf           1.143             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1155                                       Logger::INFORMATION, "src.Server.cimserver.STOPPED",
1156 h.sterling      1.153                 "$0 stopped.", _cimServerProcess->getProductName());
1157 kumpf           1.45      
1158 carolann.graves 1.171     #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) \
1159 gs.keenan       1.150     || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_AIX) \
1160 jim.wunderlich  1.169     || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_VMS)
1161 kumpf           1.45              //
1162 carolann.graves 1.171             //  Note: do not remove the PID file created at startup time, since
1163                                   //  shutdown is not complete until the CIMServer destructor completes.
1164 kumpf           1.45              //
1165                           #endif
1166 mike            1.32          }
1167 marek           1.195         catch(BindFailedException& e)
1168 mike            1.32          {
1169 marek           1.194             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1170                                       "src.Server.cimserver.SERVER_NOT_STARTED",
1171                                       "cimserver not started:  $0", e.getMessage());
1172                                   MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1173                                       "cimserver not started: $0", e.getMessage());
1174 david           1.100     
1175 marek           1.194             cerr << MessageLoader::getMessage(parms) << endl;
1176 kumpf           1.77      
1177 h.sterling      1.153         //
1178 kumpf           1.77              // notify parent process (if there is a parent process) to terminate
1179                                   //
1180                                   if (daemonOption)
1181 h.sterling      1.153                     _cimServerProcess->notify_parent(1);
1182 kumpf           1.77      
1183 h.sterling      1.156             deleteCIMServer();
1184 kumpf           1.54              return 1;
1185 mike            1.32          }
1186 marek           1.195         catch(Exception& e)
1187                               {
1188                               Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1189                                       "src.Server.cimserver.ERROR",
1190                                       "Error: $0", e.getMessage());
1191                               MessageLoaderParms parms("src.Server.cimserver.ERROR",
1192                                                        "Error: $0", e.getMessage());
1193                               PEGASUS_STD(cerr) << MessageLoader::getMessage(parms) << PEGASUS_STD(endl);
1194                                   //
1195                                   // notify parent process (if there is a parent process) to terminate
1196                                   //
1197                                   if (daemonOption)
1198                                           _cimServerProcess->notify_parent(1);
1199                           
1200                                   deleteCIMServer();
1201                                   return 1;
1202                               }
1203 mike            1.32      
1204 h.sterling      1.156         deleteCIMServer();
1205 mike            1.32          return 0;
1206                           }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2