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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2