(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 kumpf           1.215 // The daemon config property has no effect on windows operation or when
  49                       // privilege separation is enabled.
  50 mike            1.32  //
  51 mike            1.35  // To shutdown pegasus, use the -s option:
  52 david.dillard   1.165 //
  53                       // cimserver -s
  54 mike            1.35  //
  55 mike            1.32  // To run pegasus as an NT service, there are FOUR  different possibilities:
  56                       //
  57 david.dillard   1.165 // To INSTALL the Pegasus service,
  58 mike            1.32  //
  59                       // cimserver -install
  60                       //
  61 david.dillard   1.165 // To REMOVE the Pegasus service,
  62 mike            1.32  //
  63                       // cimserver -remove
  64                       //
  65 david.dillard   1.165 // To START the Pegasus service,
  66 mike            1.32  //
  67                       // net start cimserver
  68 s.hills         1.117 // or
  69                       // cimserver -start
  70 mike            1.32  //
  71 david.dillard   1.165 // To STOP the Pegasus service,
  72 mike            1.32  //
  73                       // net stop cimserver
  74 s.hills         1.117 // or
  75                       // cimserver -stop
  76 mike            1.32  //
  77 david.dillard   1.165 // Alternatively, you can use the windows service manager. Pegasus shows up
  78 mike            1.32  // in the service database as "Pegasus CIM Object Manager"
  79                       //
  80                       //////////////////////////////////////////////////////////////////////
  81                       
  82                       
  83 mike            1.35  #include <Pegasus/Common/Config.h>
  84 kumpf           1.59  #include <Pegasus/Common/Constants.h>
  85 jim.wunderlich  1.172 #include <Pegasus/Common/PegasusAssert.h>
  86 mike            1.32  #include <Pegasus/Common/FileSystem.h>
  87                       #include <Pegasus/Common/PegasusVersion.h>
  88                       #include <Pegasus/Common/Logger.h>
  89 denise.eckstein 1.218 #include <Pegasus/Common/StringConversion.h>
  90 mike            1.32  #include <Pegasus/Common/System.h>
  91 mike            1.35  #include <Pegasus/Common/Tracer.h>
  92 kumpf           1.174 #include <Pegasus/Common/LanguageParser.h>
  93 mike            1.35  #include <Pegasus/Config/ConfigManager.h>
  94                       #include <Pegasus/Client/CIMClient.h>
  95 h.sterling      1.153 #include <Pegasus/Server/CIMServer.h>
  96                       #include <Service/ServerProcess.h>
  97 kumpf           1.198 #include <Service/ServerShutdownClient.h>
  98                       #include <Service/ServerRunStatus.h>
  99 mike            1.32  
 100 kumpf           1.202 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
 101 thilo.boehm     1.211 #include <Pegasus/Common/SetFileDescriptorToEBCDICEncoding.h>
 102 thilo.boehm     1.185 #include <Service/ARM_zOS.h>
 103 marek           1.186 # ifdef PEGASUS_ZOS_SECURITY
 104                       // This include file will not be provided in the OpenGroup CVS for now.
 105                       // Do NOT try to include it in your compile
 106                       #  include <Pegasus/Common/safCheckzOS_inline.h>
 107                       # endif
 108 thilo.boehm     1.185 #endif
 109                       
 110 kumpf           1.178 #if defined(PEGASUS_OS_TYPE_UNIX)
 111 ouyang.jian     1.200 # include <unistd.h>
 112 kumpf           1.178 # include <sys/types.h>
 113                       # include <sys/stat.h>
 114                       # include <fcntl.h>
 115 mateus.baur     1.175 #endif
 116                       
 117 kumpf           1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 118                       # define PEGASUS_PROCESS_NAME "cimservermain"
 119                       #else
 120                       # define PEGASUS_PROCESS_NAME "cimserver"
 121                       #endif
 122                       
 123                       #include <Pegasus/Common/Executor.h>
 124                       
 125 ouyang.jian     1.206 #ifdef PEGASUS_OS_PASE
 126                       # include <ILEWrapper/ILEUtilities2.h>
 127                       # include <ILEWrapper/qumemultiutil.h>
 128                       #endif
 129                       
 130 kumpf           1.119 PEGASUS_USING_PEGASUS;
 131                       PEGASUS_USING_STD;
 132                       
 133 h.sterling      1.153 //Windows service variables are not defined elsewhere in the product
 134                       //enable ability to override these
 135                       #ifndef PEGASUS_SERVICE_NAME
 136                       #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
 137 chuck           1.66  #endif
 138 h.sterling      1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
 139                       #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
 140 mike            1.32  #endif
 141                       
 142 ouyang.jian     1.206 #ifdef PEGASUS_OS_PASE
 143                       #include <as400_protos.h> //for _SETCCSID
 144                       #endif
 145                       
 146 h.sterling      1.153 class CIMServerProcess : public ServerProcess
 147                       {
 148                       public:
 149                       
 150 kumpf           1.203     CIMServerProcess()
 151 h.sterling      1.153     {
 152                               cimserver_set_process(this);
 153                           }
 154                       
 155 kumpf           1.203     virtual ~CIMServerProcess()
 156 h.sterling      1.153     {
 157                           }
 158                       
 159                           //defined in PegasusVersion.h
 160                           virtual const char* getProductName() const
 161                           {
 162                               return PEGASUS_PRODUCT_NAME;
 163                           }
 164                       
 165                           virtual const char* getExtendedName() const
 166                           {
 167                               return PEGASUS_SERVICE_NAME;
 168                           }
 169                       
 170                           virtual const char* getDescription() const
 171                           {
 172                               return PEGASUS_SERVICE_DESCRIPTION;
 173                           }
 174 david.dillard   1.165 
 175 h.sterling      1.153     //defined in PegasusVersion.h
 176 jim.wunderlich  1.180     virtual const char* getCompleteVersion() const
 177                           {
 178 jim.wunderlich  1.181       if (*PEGASUS_PRODUCT_STATUS == '\0' )
 179 kumpf           1.199         return PEGASUS_PRODUCT_VERSION;
 180 jim.wunderlich  1.180       else
 181 kumpf           1.202         return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;
 182 jim.wunderlich  1.180     }
 183                       
 184                           //defined in PegasusVersion.h
 185 h.sterling      1.153     virtual const char* getVersion() const
 186                           {
 187                               return PEGASUS_PRODUCT_VERSION;
 188                           }
 189                       
 190                           virtual const char* getProcessName() const
 191                           {
 192                               return PEGASUS_PROCESS_NAME;
 193                           }
 194                       
 195 kumpf           1.178     int cimserver_run(
 196                               int argc,
 197                               char** argv,
 198                               Boolean shutdownOption,
 199                               Boolean debugOutputOption);
 200 h.sterling      1.153 
 201 kumpf           1.203     void cimserver_stop();
 202 h.sterling      1.153 };
 203                       
 204 kumpf           1.198 ServerRunStatus _serverRunStatus(
 205                           PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
 206 h.sterling      1.153 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
 207                       static CIMServer* _cimServer = 0;
 208 konrad.r        1.166 static Thread* dummyInitialThread = 0;
 209 kumpf           1.203 
 210 mike            1.35  //
 211                       //  The command name.
 212                       //
 213                       static const char COMMAND_NAME []    = "cimserver";
 214                       
 215                       //
 216                       //  The constant defining usage string.
 217                       //
 218                       static const char USAGE []           = "Usage: ";
 219                       
 220                       /**
 221                       Constants representing the command line options.
 222                       */
 223                       static const char OPTION_VERSION     = 'v';
 224                       
 225                       static const char OPTION_HELP        = 'h';
 226                       
 227                       static const char OPTION_HOME        = 'D';
 228                       
 229                       static const char OPTION_SHUTDOWN    = 's';
 230                       
 231 kumpf           1.203 static const char LONG_HELP[]        = "help";
 232 a.arora         1.142 
 233 kumpf           1.203 static const char LONG_VERSION[]     = "version";
 234 a.arora         1.142 
 235 kumpf           1.178 static const char OPTION_DEBUGOUTPUT = 'X';
 236 kumpf           1.48  
 237 mike            1.32  /** GetOptions function - This function defines the Options Table
 238 mike            1.35      and sets up the options from that table using the config manager.
 239 kumpf           1.198 
 240                           Some possible exceptions:  NoSuchFile, FileNotReadable, CannotRenameFile,
 241                           ConfigFileSyntaxError, UnrecognizedConfigProperty, InvalidPropertyValue,
 242                           CannotOpenFile.
 243 mike            1.32  */
 244                       void GetOptions(
 245 mike            1.35      ConfigManager* cm,
 246 mike            1.32      int& argc,
 247 mateus.baur     1.193     char** argv,
 248 kumpf           1.198     Boolean shutdownOption)
 249 mike            1.32  {
 250 kumpf           1.198     if (shutdownOption)
 251                           {
 252                               cm->loadConfigFiles();
 253                           }
 254                           else
 255 mike            1.32      {
 256 kumpf           1.198         cm->mergeConfigFiles();
 257                           }
 258 mateus.baur     1.193 
 259 kumpf           1.198     // Temporarily disable updates to the current configuration
 260                           // file if shutdownOption is true
 261                           cm->useConfigFiles = (shutdownOption==false);
 262 mike            1.33  
 263 kumpf           1.198     cm->mergeCommandLine(argc, argv);
 264 mateus.baur     1.193 
 265 kumpf           1.198     // Enable updates again
 266                           cm->useConfigFiles = true;
 267 mike            1.32  }
 268                       
 269                       /* PrintHelp - This is temporary until we expand the options manager to allow
 270                          options help to be defined with the OptionRow entries and presented from
 271                          those entries.
 272                       */
 273                       void PrintHelp(const char* arg0)
 274                       {
 275 mike            1.35      String usage = String (USAGE);
 276 kumpf           1.202     usage.append(COMMAND_NAME);
 277                           usage.append(" [ [ options ] | [ configProperty=value, ... ] ]\n");
 278                           usage.append("  options\n");
 279                           usage.append("    -v, --version   - displays CIM Server version number\n");
 280                           usage.append("    -h, --help      - prints this help message\n");
 281                           usage.append("    -s              - shuts down CIM Server\n");
 282 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 283 kumpf           1.202     usage.append("    -D [home]       - sets pegasus home directory\n");
 284 humberto        1.97  #endif
 285                       #if defined(PEGASUS_OS_TYPE_WINDOWS)
 286 kumpf           1.202     usage.append("    -install [name] - installs pegasus as a Windows "
 287                               "Service\n");
 288                           usage.append("                      [name] is optional and overrides "
 289                               "the\n");
 290                           usage.append("                      default CIM Server Service Name\n");
 291                           usage.append("                      by appending [name]\n");
 292                           usage.append("    -remove [name]  - removes pegasus as a Windows "
 293                               "Service\n");
 294                           usage.append("                      [name] is optional and overrides "
 295                               "the\n");
 296                           usage.append("                      default CIM Server Service Name\n");
 297                           usage.append("                      by appending [name]\n");
 298                           usage.append("    -start [name]   - starts pegasus as a Windows Service\n");
 299                           usage.append("                      [name] is optional and overrides "
 300                               "the\n");
 301                           usage.append("                      default CIM Server Service Name\n");
 302                           usage.append("                      by appending [name]\n");
 303                           usage.append("    -stop [name]    - stops pegasus as a Windows Service\n");
 304                           usage.append("                      [name] is optional and overrides "
 305                               "the\n");
 306                           usage.append("                      default CIM Server Service Name\n");
 307 kumpf           1.202     usage.append("                      by appending [name]\n\n");
 308                       #endif
 309                           usage.append("  configProperty=value\n");
 310                           usage.append("                    - sets CIM Server configuration "
 311                               "property\n");
 312 humberto        1.97  
 313                           cout << endl;
 314 kumpf           1.202     cout << _cimServerProcess->getProductName() << " " <<
 315                               _cimServerProcess->getCompleteVersion() << endl;
 316 humberto        1.97      cout << endl;
 317 david.dillard   1.165 
 318 humberto        1.97  #if defined(PEGASUS_OS_TYPE_WINDOWS)
 319 humberto        1.104     MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
 320 kumpf           1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
 321 kumpf           1.202     MessageLoaderParms parms(
 322                               "src.Server.cimserver.MENU.HPUXLINUXIA64GNU",
 323                               usage);
 324 humberto        1.97  #else
 325 kumpf           1.138     MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
 326 humberto        1.97  #endif
 327                           cout << MessageLoader::getMessage(parms) << endl;
 328 mike            1.35  }
 329                       
 330 kumpf           1.202 // This needs to be called at various points in the code depending on the
 331                       // platform and error conditions.
 332                       // We need to delete the _cimServer reference on exit in order for the
 333                       // destructors to get called.
 334 h.sterling      1.156 void deleteCIMServer()
 335                       {
 336 kumpf           1.203     delete _cimServer;
 337                           _cimServer = 0;
 338 kumpf           1.202 
 339                           if (dummyInitialThread)
 340                           {
 341 kumpf           1.199         Thread::clearLanguages();
 342                               delete dummyInitialThread;
 343 kumpf           1.202     }
 344 h.sterling      1.156 }
 345                       
 346 chuck           1.96  //
 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 kumpf           1.202 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void* parm)
 353 chuck           1.96  {
 354 kumpf           1.202     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 kumpf           1.202     // Set Message loading to process locale
 441                           MessageLoader::_useProcessLocale = true;
 442 humberto        1.97  
 443 thilo.boehm     1.211 #ifdef PEGASUS_OS_ZOS
 444                           // Direct standard input to /dev/null,
 445                           close(STDIN_FILENO);
 446                           open("/dev/null", O_RDONLY);
 447                       
 448                           if ( setEBCDICEncoding(STDOUT_FILENO)==-1 ||
 449                                setEBCDICEncoding(STDERR_FILENO)==-1 )
 450                           {
 451                              PEG_TRACE_CSTRING(TRC_SERVER,Tracer::LEVEL4,
 452                                  "Coud not set stdout or stderr to EBCDIC encoding.");
 453                           }
 454                           // Need to initialize timezone information in the
 455                           // initial processing thread (IPT)
 456                           tzset();
 457                       #endif
 458                       
 459 kv.le           1.140 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
 460 kumpf           1.202     setlocale(LC_ALL, "");
 461 kv.le           1.140 #endif
 462                       
 463 tony            1.82  #ifndef PEGASUS_OS_TYPE_WINDOWS
 464 kumpf           1.38      //
 465                           // Get environment variables:
 466                           //
 467 kumpf           1.202 # if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
 468 kv.le           1.134     pegasusHome = AIX_RELEASE_PEGASUS_HOME;
 469 ouyang.jian     1.210 # elif defined(PEGASUS_OS_PASE)
 470                           const char *tmp = getenv("PEGASUS_HOME");
 471                           pegasusHome = (tmp == 0) ? PASE_DEFAULT_PEGASUS_HOME : tmp;
 472 kumpf           1.202 # elif !defined(PEGASUS_USE_RELEASE_DIRS) || \
 473                           defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
 474 kumpf           1.38      const char* tmp = getenv("PEGASUS_HOME");
 475                       
 476                           if (tmp)
 477                           {
 478                               pegasusHome = tmp;
 479                           }
 480 kumpf           1.202 # endif
 481 kumpf           1.38  
 482                           FileSystem::translateSlashes(pegasusHome);
 483 tony            1.82  #else
 484 kumpf           1.38  
 485 kumpf           1.202     // windows only
 486                           //setHome(pegasusHome);
 487                           pegasusHome = _cimServerProcess->getHome();
 488 tony            1.82  #endif
 489 mike            1.32  
 490 kumpf           1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 491                       
 492                           // If invoked with "--executor-socket <socket>" option, then use executor.
 493                       
 494                           Executor::setSock(_extractExecutorSockOpt(argc, argv));
 495                       
 496                           // Ping executor to verify the specified socket is valid.
 497                       
 498                           if (Executor::ping() != 0)
 499                           {
 500                               MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
 501                                   "Failed to ping the executor on the specified socket.");
 502                               cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
 503                               exit(1);
 504                           }
 505                       
 506                       #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
 507                       
 508 kumpf           1.60          // Get help, version, and shutdown options
 509 mike            1.35  
 510                               for (int i = 1; i < argc; )
 511                               {
 512                                   const char* arg = argv[i];
 513 kumpf           1.216             if (strcmp(arg, "--help") == 0)
 514 a.arora         1.142             {
 515 kumpf           1.216                 PrintHelp(argv[0]);
 516                                       Executor::daemonizeExecutor();
 517                                       exit(0);
 518 a.arora         1.142             }
 519 kumpf           1.216             else if (strcmp(arg, "--version") == 0)
 520 a.arora         1.142             {
 521 jim.wunderlich  1.180                 cout << _cimServerProcess->getCompleteVersion() << endl;
 522 kumpf           1.216                 Executor::daemonizeExecutor();
 523 a.arora         1.142                 exit(0);
 524                                   }
 525 mike            1.35              // Check for -option
 526 a.arora         1.142             else if (*arg == '-')
 527 mike            1.35              {
 528                                       // Get the option
 529                                       const char* option = arg + 1;
 530                       
 531                                       //
 532                                       // Check to see if user asked for the version (-v option):
 533                                       //
 534 tony            1.83                  if (*option == OPTION_VERSION &&
 535                                           strlen(option) == 1)
 536 mike            1.35                  {
 537 jim.wunderlich  1.180                     cout << _cimServerProcess->getCompleteVersion() << endl;
 538 kumpf           1.216                     Executor::daemonizeExecutor();
 539 mike            1.35                      exit(0);
 540                                       }
 541                                       //
 542                                       // Check to see if user asked for help (-h option):
 543                                       //
 544 tony            1.83                  else if (*option == OPTION_HELP &&
 545                                               (strlen(option) == 1))
 546 mike            1.35                  {
 547                                           PrintHelp(argv[0]);
 548 kumpf           1.216                     Executor::daemonizeExecutor();
 549 mike            1.35                      exit(0);
 550                                       }
 551 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 552 tony            1.83                  else if (*option == OPTION_HOME &&
 553                                               (strlen(option) == 1))
 554 mike            1.35                  {
 555 kumpf           1.60                      if (i + 1 < argc)
 556 mike            1.35                      {
 557                                               pegasusHome.assign(argv[i + 1]);
 558                                           }
 559                                           else
 560                                           {
 561 humberto        1.99                          String opt(option);
 562 kumpf           1.202                         MessageLoaderParms parms(
 563                                                   "src.Server.cimserver.MISSING_ARGUMENT",
 564                                                   "Missing argument for option -$0",
 565                                                   opt);
 566 h.sterling      1.153                         cout << MessageLoader::getMessage(parms) << endl;
 567 kumpf           1.216                         exit(1);
 568 mike            1.35                      }
 569                       
 570                                           memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
 571                                           argc -= 2;
 572                                       }
 573 kumpf           1.63  #endif
 574 kumpf           1.48                  //
 575 kumpf           1.178                 // Check to see if user asked for debug output (-X option):
 576 kumpf           1.48                  //
 577 kumpf           1.178                 else if (*option == OPTION_DEBUGOUTPUT &&
 578 tony            1.83                          (strlen(option) == 1))
 579 kumpf           1.48                  {
 580 kumpf           1.178                     MessageLoaderParms parms(
 581                                               "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
 582                                               "Unsupported debug output option is enabled.");
 583 h.sterling      1.153                     cout << MessageLoader::getMessage(parms) << endl;
 584 kumpf           1.178 
 585                                           debugOutputOption = true;
 586                       
 587                       #if defined(PEGASUS_OS_HPUX)
 588                                           System::bindVerbose = true;
 589                       #endif
 590                       
 591 kumpf           1.48                      // remove the option from the command line
 592                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 593 david.dillard   1.165                     argc--;
 594 kumpf           1.48                  }
 595 mike            1.35                  //
 596                                       // Check to see if user asked for shutdown (-s option):
 597                                       //
 598 tony            1.82                  else if (*option == OPTION_SHUTDOWN &&
 599                                               (strlen(option) == 1))
 600 mike            1.35                  {
 601                                           //
 602 kumpf           1.52                      // Check to see if shutdown has already been specified:
 603 mike            1.35                      //
 604 kumpf           1.52                      if (shutdownOption)
 605 mike            1.35                      {
 606 kumpf           1.202                         MessageLoaderParms parms(
 607                                                   "src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
 608                                                   "Duplicate shutdown option specified.");
 609 david.dillard   1.165 
 610 humberto        1.97                          cout << MessageLoader::getMessage(parms) << endl;
 611 kumpf           1.216                         exit(1);
 612 mike            1.35                      }
 613                       
 614 kumpf           1.52                      shutdownOption = true;
 615 david.dillard   1.165 
 616 mike            1.35                      // remove the option from the command line
 617                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 618 david.dillard   1.165                     argc--;
 619 mike            1.35                  }
 620                                       else
 621                                           i++;
 622                                   }
 623                                   else
 624                                       i++;
 625 mike            1.32          }
 626 mike            1.35  
 627 kumpf           1.38      //
 628                           // Set the value for pegasusHome property
 629                           //
 630                           ConfigManager::setPegasusHome(pegasusHome);
 631 mike            1.32  
 632 mike            1.35      //
 633 carolann.graves 1.171     // Do the platform specific run
 634 s.hills         1.117     //
 635                       
 636 kumpf           1.178     return _cimServerProcess->platform_run(
 637                               argc, argv, shutdownOption, debugOutputOption);
 638 s.hills         1.117 }
 639                       
 640 h.sterling      1.153 void CIMServerProcess::cimserver_stop()
 641                       {
 642                           _cimServer->shutdownSignal();
 643                       }
 644 s.hills         1.117 
 645                       //
 646                       // The main, common, running code
 647                       //
 648 david.dillard   1.165 // NOTE: Do NOT call exit().  Use return(), otherwise some platforms
 649 s.hills         1.117 // will fail to shutdown properly/cleanly.
 650                       //
 651 david.dillard   1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
 652 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
 653 david.dillard   1.165 // daemon stuff into platform specific platform_run(), etc.
 654                       // Note: make sure to not put error handling stuff that platform
 655 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
 656 s.hills         1.117 //
 657                       
 658 kumpf           1.178 int CIMServerProcess::cimserver_run(
 659                           int argc,
 660                           char** argv,
 661                           Boolean shutdownOption,
 662                           Boolean debugOutputOption)
 663 s.hills         1.117 {
 664                           Boolean daemonOption = false;
 665                       
 666 ouyang.jian     1.206 #if defined (PEGASUS_OS_PASE) && !defined (PEGASUS_DEBUG)
 667                           // PASE have itself regular for checking privileged user
 668                           if (!System::isPrivilegedUser("*CURRENT  "))
 669                           {
 670                               MessageLoaderParms parms(
 671                                       "src.Server.cimserver.NO_AUTHORITY.PEGASUS_OS_PASE",
 672                                       "The caller should be a privileged user,"
 673                                       " or the server will not run.");
 674                               cerr << MessageLoader::getMessage(parms) << endl;
 675                               exit (1);
 676                           }
 677                           char jobName[11];
 678                           // this function only can be found in PASE environment
 679                           umeGetJobName(jobName, false);
 680                           if (strncmp("QUMECIMOM ", jobName, 10) != 0
 681                                   && strncmp("QUMEENDCIM", jobName, 10) != 0)
 682                           {
 683                               MessageLoaderParms parms(
 684                                       "src.Server.cimserver.NOT_OFFICIAL_START.PEGASUS_OS_PASE",
 685                                       "cimserver can not be started by user.\nServer will not run.");
 686                               cerr << MessageLoader::getMessage(parms) << endl;
 687 ouyang.jian     1.206         exit (1);
 688                           }
 689                       
 690                           // Direct standard input, output, and error to /dev/null, 
 691                           // PASE run this job in background, any output in not allowed
 692                           freopen("/dev/null", "r", stdin);
 693                           freopen("/dev/null", "w", stdout);
 694                           freopen("/dev/null", "w", stderr);
 695                       #endif
 696                       
 697 s.hills         1.117     //
 698 mike            1.35      // Get an instance of the Config Manager.
 699                           //
 700 kumpf           1.203     ConfigManager* configManager = ConfigManager::getInstance();
 701 kumpf           1.136     configManager->useConfigFiles = true;
 702 mike            1.35  
 703 mike            1.32      try
 704                           {
 705 kumpf           1.203         //
 706                               // Get options (from command line and from configuration file); this
 707                               // removes corresponding options and their arguments from the command
 708                               // line.  NOTE: If shutdownOption=true, the contents of current config
 709                               // file are not overwritten by the planned config file.
 710                               //
 711 mateus.baur     1.193         GetOptions(configManager, argc, argv, shutdownOption);
 712 kumpf           1.127 
 713 kumpf           1.203         //
 714                               // Initialize the message home directory in the MessageLoader.
 715                               // This is the default directory where the resource bundles are found.
 716                               //
 717                               MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
 718                                   ConfigManager::getInstance()->getCurrentValue("messageDir")));
 719 kumpf           1.86  
 720 ouyang.jian     1.206 #ifdef PEGASUS_OS_PASE
 721                           // set ccsid to unicode for entire job
 722                           // ccsid is globolization mechanism in PASE environment
 723                           if (_SETCCSID(1208) == -1)
 724                           {
 725                               MessageLoaderParms parms(
 726                                       "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
 727                                       "Failed to set CCSID, server will stop.");
 728                               cerr << MessageLoader::getMessage(parms) << endl;
 729                               Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
 730                                       "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
 731                                       "Failed to set CCSID, server will stop.\n");
 732                               exit (1);
 733                           }
 734                       
 735                           char fullJobName[29];
 736                           umeGetJobName(fullJobName, true);
 737                           Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 738                                   "src.Server.cimserver.SERVER_JOB_NAME.PEGASUS_OS_PASE",
 739                                   "CIM Server's Job Name is: $0", fullJobName);
 740                       #endif
 741 ouyang.jian     1.206 
 742                           Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 743                               configManager->getCurrentValue("enableHttpConnection"));
 744                           Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 745                               configManager->getCurrentValue("enableHttpsConnection"));
 746                       
 747                           // Make sure at least one connection is enabled
 748                       #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 749                           if (!enableHttpConnection && !enableHttpsConnection)
 750                           {
 751                               //l10n
 752                               //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 753                                   //"Neither HTTP nor HTTPS connection is enabled.  "
 754                                   //"CIMServer will not be started.");
 755                               Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 756                                   "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 757                                   "Neither HTTP nor HTTPS connection is enabled."
 758                                   "  CIMServer will not be started.");
 759                               //cerr << "Neither HTTP nor HTTPS connection is enabled.  "
 760                                   //"CIMServer will not be started." << endl;
 761                               MessageLoaderParms parms(
 762 ouyang.jian     1.206                 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 763                                       "Neither HTTP nor HTTPS connection is enabled."
 764                                       "  CIMServer will not be started.");
 765                               cerr << MessageLoader::getMessage(parms) << endl;
 766                               return(1);
 767                           }
 768                       #endif
 769 mike            1.35          //
 770 kumpf           1.187         // Check to see if we should start Pegasus as a daemon
 771 mike            1.35          //
 772 kumpf           1.187         daemonOption = ConfigManager::parseBooleanValue(
 773                                   configManager->getCurrentValue("daemon"));
 774 david.dillard   1.165 
 775 kumpf           1.215         if ((Executor::detectExecutor() == 0) && (daemonOption == false))
 776                               {
 777                                   MessageLoaderParms parms(
 778                                       "src.Server.cimserver.PRIVSEP_REQUIRES_DAEMON",
 779                                       "Warning: The configuration setting daemon=false is ignored "
 780                                           "with privilege separation enabled.");
 781                                   cerr << MessageLoader::getMessage(parms) << endl;
 782                                   daemonOption = true;
 783                               }
 784                       
 785 konrad.r        1.161 #if !defined(PEGASUS_USE_SYSLOGS)
 786 kumpf           1.203         String logsDirectory = ConfigManager::getHomedPath(
 787                                   configManager->getCurrentValue("logdir"));
 788 kumpf           1.36  
 789 kumpf           1.203         // Set up the Logger.  This does not open the logs.
 790 kumpf           1.36          // Might be more logical to clean before set.
 791                               Logger::setHomeDirectory(logsDirectory);
 792 ouyang.jian     1.206         
 793                       # ifdef PEGASUS_OS_PASE
 794                           /* write job log to tell where pegasus log is.*/
 795                           if(logsDirectory.size() > 0)
 796                               // this function only can be found in PASE environment
 797                               logPegasusDir2joblog(logsDirectory.getCString());
 798                           else
 799                               logPegasusDir2joblog(".");
 800                       # endif
 801 kumpf           1.57  #endif
 802 kumpf           1.36  
 803                               //
 804 david.dillard   1.165         // Check to see if we need to shutdown CIMOM
 805 mike            1.35          //
 806                               if (shutdownOption)
 807                               {
 808 david.dillard   1.165             String configTimeout =
 809 kumpf           1.60                  configManager->getCurrentValue("shutdownTimeout");
 810 kumpf           1.202             Uint32 timeoutValue =
 811                                       strtol(configTimeout.getCString(), (char **)0, 10);
 812 david.dillard   1.165 
 813 kumpf           1.198             ServerShutdownClient serverShutdownClient(&_serverRunStatus);
 814                                   serverShutdownClient.shutdown(timeoutValue);
 815 kumpf           1.45  
 816 kumpf           1.198             MessageLoaderParms parms(
 817                                       "src.Server.cimserver.SERVER_STOPPED",
 818                                       "CIM Server stopped.");
 819 humberto        1.106 
 820 humberto        1.97              cout << MessageLoader::getMessage(parms) << endl;
 821 kumpf           1.202             return 0;
 822 mike            1.35          }
 823 mike            1.32  
 824 kumpf           1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
 825 kumpf           1.36          // Leave this in until people get familiar with the logs.
 826 humberto        1.97          MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
 827 h.sterling      1.153                                  "Logs Directory = ");
 828 humberto        1.97          cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
 829 kumpf           1.57  #endif
 830 mike            1.32      }
 831 kumpf           1.203     catch (Exception& e)
 832 mike            1.32      {
 833 kumpf           1.203         MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 834                                   "cimserver not started: $0", e.getMessage());
 835                               Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 836                                   MessageLoader::getMessage(parms));
 837                               cerr << MessageLoader::getMessage(parms) << endl;
 838                       
 839                               return 1;
 840 marek           1.186     }
 841 david           1.85  
 842 marek           1.186 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
 843                           startupCheckBPXServer(true);
 844                           startupCheckProfileCIMSERVclassWBEM();
 845                           startupEnableMSC();
 846 david           1.85  #endif
 847 mike            1.32  
 848 kumpf           1.139 #if defined(PEGASUS_DEBUG)
 849 mike            1.32      // Put out startup up message.
 850 kumpf           1.202     cout << _cimServerProcess->getProductName() << " " <<
 851                               _cimServerProcess->getCompleteVersion() << endl;
 852 humberto        1.97  #endif
 853                       
 854 kumpf           1.202     // reset message loading to NON-process locale
 855                           MessageLoader::_useProcessLocale = false;
 856 mike            1.32  
 857 kumpf           1.137     // Get the parent's PID before forking
 858 kumpf           1.198     _serverRunStatus.setParentPid(System::getPID());
 859 david.dillard   1.165 
 860 kumpf           1.202     // Do not fork when using privilege separation (executor will daemonize
 861                           // itself later).
 862 kumpf           1.63      if (daemonOption)
 863                           {
 864 kumpf           1.202         if (-1 == _cimServerProcess->cimserver_fork())
 865                                   return -1;
 866 kumpf           1.63      }
 867 chuck           1.66  
 868 chuck           1.96      // Now we are after the fork...
 869                           // Create a dummy Thread object that can be used to store the
 870 kumpf           1.176     // AcceptLanguageList object for CIM requests that are serviced
 871 chuck           1.96      // by this thread (initial thread of server).  Need to do this
 872                           // because this thread is not in a ThreadPool, but is used
 873                           // to service CIM requests.
 874                           // The run function for the dummy Thread should never be called,
 875 konrad.r        1.166     dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
 876 david.dillard   1.165     Thread::setCurrent(dummyInitialThread);
 877 kumpf           1.202     try
 878                           {
 879 kumpf           1.214         Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages());
 880 kumpf           1.202     }
 881                           catch (InvalidAcceptLanguageHeader& e)
 882                           {
 883 kumpf           1.203         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 884                                   "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
 885                                   "Could not convert the system process locale into a valid "
 886                                       "AcceptLanguage format.");
 887                               Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 888                                   e.getMessage());
 889 humberto        1.108     }
 890 david.dillard   1.165 
 891 kumpf           1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
 892                           umask(S_IRWXG|S_IRWXO);
 893                       #endif
 894 mday            1.62  
 895 kumpf           1.203     // Start up the CIM Server
 896 mateus.baur     1.175 
 897 kumpf           1.203     try
 898                           {
 899 mateus.baur     1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
 900 kumpf           1.203         //
 901                               // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
 902                               // concurrent writes to this file by multiple cimserver processes
 903                               // starting at the same time.
 904                               //
 905                               CString startupLockFileName = ConfigManager::getHomedPath(
 906 kumpf           1.204             PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
 907 kumpf           1.203 
 908                               // Make sure the start-up lock file exists
 909                               FILE* startupLockFile;
 910                               if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
 911                               {
 912                                   fclose(startupLockFile);
 913                               }
 914 kumpf           1.202 
 915 kumpf           1.203         AutoFileLock fileLock(startupLockFileName);
 916                       #endif
 917 kumpf           1.202 
 918 kumpf           1.203 #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
 919                               //
 920                               // Check if a CIM Server is already running.  If so, print an error
 921                               // message and notify the parent process (if there is one) to terminate
 922                               //
 923                               if (_serverRunStatus.isServerRunning())
 924                               {
 925                                   MessageLoaderParms parms(
 926                                       "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
 927                                       "Unable to start CIMServer. CIMServer is already running.");
 928                                   Logger::put(
 929                                       Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 930                                       MessageLoader::getMessage(parms));
 931                                   cerr << MessageLoader::getMessage(parms) << endl;
 932 mateus.baur     1.175 
 933 kumpf           1.203             if (daemonOption)
 934                                   {
 935                                       _cimServerProcess->notify_parent(1);
 936                                   }
 937 kumpf           1.79  
 938 kumpf           1.203             return 1;
 939                               }
 940 kumpf           1.79  
 941 kumpf           1.198         //
 942 kumpf           1.203         // Declare ourselves as the running CIM Server process, and write our
 943                               // PID to the PID file.
 944 kumpf           1.79          //
 945 kumpf           1.203         _serverRunStatus.setServerRunning();
 946                       #endif
 947                       
 948                               // Create and initialize the CIMServer object
 949                       
 950                               _cimServer = new CIMServer();
 951                       
 952                               Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 953                                   configManager->getCurrentValue("enableHttpConnection"));
 954                               Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 955                                   configManager->getCurrentValue("enableHttpsConnection"));
 956                       
 957                       #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 958                               // Make sure at least one connection is enabled
 959                               if (!enableHttpConnection && !enableHttpsConnection)
 960 kumpf           1.198         {
 961 kumpf           1.203             MessageLoaderParms parms(
 962                                       "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 963                                       "Neither HTTP nor HTTPS connection is enabled.");
 964                                   throw Exception(parms);
 965 kumpf           1.198         }
 966 kumpf           1.63  #endif
 967 kumpf           1.51  
 968 venkat.puvvada  1.208         Boolean addIP6Acceptor = false;
 969                               Boolean addIP4Acceptor = false;
 970                       
 971                       #ifdef PEGASUS_OS_TYPE_WINDOWS
 972                               addIP4Acceptor = true;
 973                       #endif
 974                       
 975                       #ifdef PEGASUS_ENABLE_IPV6
 976                               // If IPv6 stack is disabled swicth to IPv4 stack.
 977                               if (System::isIPv6StackActive())
 978                               {
 979                                   addIP6Acceptor = true;
 980                               }
 981                               else
 982                               {
 983                                   MessageLoaderParms parms(
 984                                       "src.Server.cimserver.IPV6_STACK_NOT_ACTIVE",
 985                                       "IPv6 stack is not active, using IPv4 socket.");
 986                                   Logger::put(
 987                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 988                                       MessageLoader::getMessage(parms));
 989 venkat.puvvada  1.208 #if defined(PEGASUS_DEBUG)
 990                                   cout << MessageLoader::getMessage(parms) << endl;
 991                       #endif
 992                               }
 993                       #endif
 994                               if (!addIP6Acceptor)
 995                               {
 996                                   addIP4Acceptor = true;
 997                               }
 998                       
 999 kumpf           1.203         // The server HTTP and HTTPS ports are determined via this algorithm:
1000                               // 1) If the user explicitly specified a port, use it.
1001                               // 2) If the user did not specify a port, get the port from the
1002                               //    services file.
1003                               // 3) If no value is specified in the services file, use the IANA WBEM
1004                               //    default port.
1005                               // Note that 2 and 3 are done within the System::lookupPort method
1006                               // An empty string from the ConfigManager implies that the user did not
1007                               // specify a port.
1008 kumpf           1.41  
1009 kumpf           1.86          if (enableHttpConnection)
1010                               {
1011 kumpf           1.203             Uint32 portNumberHttp = 0;
1012                                   String httpPort = configManager->getCurrentValue("httpPort");
1013                                   if (httpPort == String::EMPTY)
1014                                   {
1015                                       //
1016                                       // Look up the WBEM-HTTP port number
1017                                       //
1018                                       portNumberHttp = System::lookupPort(
1019                                           WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1020                                   }
1021                                   else
1022                                   {
1023                                       //
1024                                       // user-specified
1025                                       //
1026                                       CString portString = httpPort.getCString();
1027                                       char* end = 0;
1028                                       portNumberHttp = strtol(portString, &end, 10);
1029                                       if (!(end != 0 && *end == '\0'))
1030                                       {
1031                                           throw InvalidPropertyValue("httpPort", httpPort);
1032 kumpf           1.203                 }
1033                                   }
1034                       
1035 venkat.puvvada  1.208             if (addIP6Acceptor)
1036                                   {
1037                                       _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1038                                           portNumberHttp, false);
1039                                   }
1040                                   if (addIP4Acceptor)
1041                                   {
1042                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1043                                           portNumberHttp, false);
1044                                   }
1045 kumpf           1.198 
1046 denise.eckstein 1.218             char scratchBuffer[22];
1047                                   Uint32 n;
1048                                   const char * portNumberHttpStr = Uint32ToString(
1049                                       scratchBuffer, portNumberHttp, n); 
1050 kumpf           1.203             MessageLoaderParms parms(
1051 kumpf           1.198                 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1052 denise.eckstein 1.218                 "Listening on HTTP port $0.", portNumberHttpStr);
1053 kumpf           1.203             Logger::put(
1054                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1055                                       MessageLoader::getMessage(parms));
1056                       #if defined(PEGASUS_DEBUG)
1057                                   cout << MessageLoader::getMessage(parms) << endl;
1058                       #endif
1059 kumpf           1.86          }
1060 kumpf           1.198 
1061 kumpf           1.86          if (enableHttpsConnection)
1062                               {
1063 kumpf           1.203             Uint32 portNumberHttps = 0;
1064                                   String httpsPort = configManager->getCurrentValue("httpsPort");
1065                                   if (httpsPort == String::EMPTY)
1066                                   {
1067                                       //
1068                                       // Look up the WBEM-HTTPS port number
1069                                       //
1070                                       portNumberHttps = System::lookupPort(
1071                                           WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1072                                   }
1073                                   else
1074                                   {
1075                                       //
1076                                       // user-specified
1077                                       //
1078                                       CString portString = httpsPort.getCString();
1079                                       char* end = 0;
1080                                       portNumberHttps = strtol(portString, &end, 10);
1081                                       if (!(end != 0 && *end == '\0'))
1082                                       {
1083                                           throw InvalidPropertyValue("httpsPort", httpsPort);
1084 kumpf           1.203                 }
1085                                   }
1086 venkat.puvvada  1.208             if (addIP6Acceptor)
1087                                   { 
1088                                       _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1089                                           portNumberHttps, true);
1090                                   }
1091                                   if (addIP4Acceptor)
1092                                   {
1093                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1094                                           portNumberHttps, true);
1095                                   }
1096 denise.eckstein 1.218             char scratchBuffer[22];
1097                                   Uint32 n;
1098                                   const char * portNumberHttpsStr = Uint32ToString(
1099                                       scratchBuffer, portNumberHttps, n); 
1100 kumpf           1.203             MessageLoaderParms parms(
1101 kumpf           1.198                 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1102 denise.eckstein 1.218                 "Listening on HTTPS port $0.", portNumberHttpsStr);
1103 kumpf           1.203             Logger::put(
1104                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1105                                       MessageLoader::getMessage(parms));
1106                       #if defined(PEGASUS_DEBUG)
1107                                   cout << MessageLoader::getMessage(parms) << endl;
1108                       #endif
1109 kumpf           1.86          }
1110 kumpf           1.135 
1111 h.sterling      1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1112 kumpf           1.203         {
1113 dave.sudlik     1.205             _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
1114 kumpf           1.86  
1115 kumpf           1.198             MessageLoaderParms parms(
1116 kumpf           1.203                 "src.Server.cimserver.LISTENING_ON_LOCAL",
1117                                       "Listening on local connection socket.");
1118                                   Logger::put(
1119                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1120                                       MessageLoader::getMessage(parms));
1121                       # if defined(PEGASUS_DEBUG)
1122 h.sterling      1.153             cout << MessageLoader::getMessage(parms) << endl;
1123 kumpf           1.203 # endif
1124 kumpf           1.86          }
1125 david           1.85  #endif
1126 mike            1.35  
1127 kumpf           1.198         _cimServer->bind();
1128 kumpf           1.199 
1129 kumpf           1.198         // notify parent process (if there is a parent process) to terminate
1130 konrad.r        1.95          // so user knows that there is cimserver ready to serve CIM requests.
1131 kumpf           1.198         if (daemonOption)
1132                               {
1133                                   _cimServerProcess->notify_parent(0);
1134                               }
1135 mike            1.35  
1136 kumpf           1.139 #if defined(PEGASUS_DEBUG)
1137 kumpf           1.202         cout << "Started. " << endl;
1138 kumpf           1.63  #endif
1139 david.dillard   1.165 
1140 kumpf           1.54          // Put server started message to the logger
1141 kumpf           1.143         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1142                                   Logger::INFORMATION,
1143                                   "src.Server.cimserver.STARTED_VERSION",
1144                                   "Started $0 version $1.",
1145 kumpf           1.199             _cimServerProcess->getProductName(),
1146                                   _cimServerProcess->getCompleteVersion());
1147 kumpf           1.45  
1148 marek           1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
1149 kumpf           1.178         if (daemonOption && !debugOutputOption)
1150 kumpf           1.202         {
1151 kumpf           1.178             // Direct standard input, output, and error to /dev/null,
1152                                   // since we are running as a daemon.
1153 thilo.boehm     1.211             close(STDIN_FILENO);
1154 kumpf           1.178             open("/dev/null", O_RDONLY);
1155 thilo.boehm     1.211             close(STDOUT_FILENO);
1156 kumpf           1.178             open("/dev/null", O_RDWR);
1157 thilo.boehm     1.211             close(STDERR_FILENO);
1158 kumpf           1.178             open("/dev/null", O_RDWR);
1159                               }
1160                       #endif
1161 kumpf           1.203     }
1162                           catch (Exception& e)
1163                           {
1164                               MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1165                                   "cimserver not started: $0", e.getMessage());
1166                               Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1167                                   MessageLoader::getMessage(parms));
1168                               cerr << MessageLoader::getMessage(parms) << endl;
1169 kumpf           1.178 
1170 kumpf           1.203         //
1171                               // notify parent process (if there is a parent process) to terminate
1172                               //
1173                               if (daemonOption)
1174                                   _cimServerProcess->notify_parent(1);
1175                       
1176                               deleteCIMServer();
1177                               return 1;
1178                           }
1179                       
1180                           // Run the main CIM Server loop
1181                       
1182                           try
1183                           {
1184 thilo.boehm     1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1185                       
1186 kumpf           1.202         // ARM is a z/OS internal restart facility.
1187                               // This is a z/OS specific change.
1188 thilo.boehm     1.185 
1189                               // Instatiating the automatic restart manager for zOS
1190                               ARM_zOS automaticRestartManager;
1191                       
1192                               // register to zOS ARM
1193                               automaticRestartManager.Register();
1194                       
1195                       #endif
1196                       
1197 marek           1.217 #ifdef PEGASUS_ENABLE_SLP
1198                               _cimServer->startSLPProvider();
1199                       #endif        
1200 mike            1.35          //
1201                               // Loop to call CIMServer's runForever() method until CIMServer
1202                               // has been shutdown
1203                               //
1204 kumpf           1.202         while (!_cimServer->terminated())
1205                               {
1206                                   _cimServer->runForever();
1207                               }
1208 carson.hovey    1.157 
1209 kumpf           1.45          //
1210                               // normal termination
1211 carson.hovey    1.157         //
1212 kumpf           1.203 
1213 thilo.boehm     1.185 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1214                       
1215 kumpf           1.202         // ARM is a z/OS internal restart facility.
1216                               // This is a z/OS specific change.
1217 thilo.boehm     1.185 
1218                               // register to zOS ARM
1219                               automaticRestartManager.DeRegister();
1220                       
1221                       #endif
1222 kumpf           1.143 
1223 kumpf           1.54          // Put server shutdown message to the logger
1224 kumpf           1.143         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1225                                   Logger::INFORMATION, "src.Server.cimserver.STOPPED",
1226 h.sterling      1.153             "$0 stopped.", _cimServerProcess->getProductName());
1227 mike            1.32      }
1228 kumpf           1.202     catch (Exception& e)
1229 marek           1.195     {
1230 kumpf           1.202         MessageLoaderParms parms(
1231 marek           1.195             "src.Server.cimserver.ERROR",
1232 kumpf           1.202             "Error: $0",
1233                                   e.getMessage());
1234 kumpf           1.203         Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1235                                   MessageLoader::getMessage(parms));
1236                               cerr << MessageLoader::getMessage(parms) << endl;
1237 marek           1.195 
1238                               deleteCIMServer();
1239                               return 1;
1240                           }
1241 mike            1.32  
1242 h.sterling      1.156     deleteCIMServer();
1243 mike            1.32      return 0;
1244                       }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2