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

   1 martin 1.226 //%LICENSE////////////////////////////////////////////////////////////////
   2 martin 1.227 //
   3 martin 1.226 // Licensed to The Open Group (TOG) under one or more contributor license
   4              // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   5              // this work for additional information regarding copyright ownership.
   6              // Each contributor licenses this file to you under the OpenPegasus Open
   7              // Source License; you may not use this file except in compliance with the
   8              // License.
   9 martin 1.227 //
  10 martin 1.226 // Permission is hereby granted, free of charge, to any person obtaining a
  11              // copy of this software and associated documentation files (the "Software"),
  12              // to deal in the Software without restriction, including without limitation
  13              // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14              // and/or sell copies of the Software, and to permit persons to whom the
  15              // Software is furnished to do so, subject to the following conditions:
  16 martin 1.227 //
  17 martin 1.226 // The above copyright notice and this permission notice shall be included
  18              // in all copies or substantial portions of the Software.
  19 martin 1.227 //
  20 martin 1.226 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21 martin 1.227 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22 martin 1.226 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23              // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  24              // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25              // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26              // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27 martin 1.227 //
  28 martin 1.226 //////////////////////////////////////////////////////////////////////////
  29 mike   1.32  //
  30              //%/////////////////////////////////////////////////////////////////////////////
  31              
  32              
  33              //////////////////////////////////////////////////////////////////////
  34              //
  35 carolann.graves 1.171 // Notes on daemon operation (Unix) and service operation (Win 32):
  36 mike            1.32  //
  37 david.dillard   1.165 // To run pegasus as a daemon on Unix platforms:
  38 mike            1.32  //
  39 kumpf           1.60  // cimserver
  40 mike            1.32  //
  41 kumpf           1.60  // To NOT run pegasus as a daemon on Unix platforms, set the daemon config
  42                       // property to false:
  43                       //
  44                       // cimserver daemon=false
  45                       //
  46 kumpf           1.215 // The daemon config property has no effect on windows operation or when
  47                       // privilege separation is enabled.
  48 mike            1.32  //
  49 mike            1.35  // To shutdown pegasus, use the -s option:
  50 david.dillard   1.165 //
  51                       // cimserver -s
  52 mike            1.35  //
  53 mike            1.32  // To run pegasus as an NT service, there are FOUR  different possibilities:
  54                       //
  55 david.dillard   1.165 // To INSTALL the Pegasus service,
  56 mike            1.32  //
  57                       // cimserver -install
  58                       //
  59 david.dillard   1.165 // To REMOVE the Pegasus service,
  60 mike            1.32  //
  61                       // cimserver -remove
  62                       //
  63 david.dillard   1.165 // To START the Pegasus service,
  64 mike            1.32  //
  65                       // net start cimserver
  66 s.hills         1.117 // or
  67                       // cimserver -start
  68 mike            1.32  //
  69 david.dillard   1.165 // To STOP the Pegasus service,
  70 mike            1.32  //
  71                       // net stop cimserver
  72 s.hills         1.117 // or
  73                       // cimserver -stop
  74 mike            1.32  //
  75 david.dillard   1.165 // Alternatively, you can use the windows service manager. Pegasus shows up
  76 mike            1.32  // in the service database as "Pegasus CIM Object Manager"
  77                       //
  78                       //////////////////////////////////////////////////////////////////////
  79                       
  80                       
  81 mike            1.35  #include <Pegasus/Common/Config.h>
  82 kumpf           1.59  #include <Pegasus/Common/Constants.h>
  83 jim.wunderlich  1.172 #include <Pegasus/Common/PegasusAssert.h>
  84 mike            1.32  #include <Pegasus/Common/FileSystem.h>
  85                       #include <Pegasus/Common/PegasusVersion.h>
  86                       #include <Pegasus/Common/Logger.h>
  87 denise.eckstein 1.218 #include <Pegasus/Common/StringConversion.h>
  88 mike            1.32  #include <Pegasus/Common/System.h>
  89 mike            1.35  #include <Pegasus/Common/Tracer.h>
  90 kumpf           1.174 #include <Pegasus/Common/LanguageParser.h>
  91 mike            1.35  #include <Pegasus/Config/ConfigManager.h>
  92                       #include <Pegasus/Client/CIMClient.h>
  93 h.sterling      1.153 #include <Pegasus/Server/CIMServer.h>
  94                       #include <Service/ServerProcess.h>
  95 kumpf           1.198 #include <Service/ServerShutdownClient.h>
  96                       #include <Service/ServerRunStatus.h>
  97 mike            1.32  
  98 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS)
  99 thilo.boehm     1.235 #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>
 100 thilo.boehm     1.185 #include <Service/ARM_zOS.h>
 101 marek           1.236 #include <Service/TimeZone_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 denise.eckstein 1.229     usage.append("    --status        - displays the running status of"
 280                               " the CIM Server\n");
 281 kumpf           1.202     usage.append("    -h, --help      - prints this help message\n");
 282                           usage.append("    -s              - shuts down CIM Server\n");
 283 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 284 kumpf           1.202     usage.append("    -D [home]       - sets pegasus home directory\n");
 285 humberto        1.97  #endif
 286                       #if defined(PEGASUS_OS_TYPE_WINDOWS)
 287 kumpf           1.202     usage.append("    -install [name] - installs pegasus as a Windows "
 288                               "Service\n");
 289                           usage.append("                      [name] is optional and overrides "
 290                               "the\n");
 291                           usage.append("                      default CIM Server Service Name\n");
 292                           usage.append("                      by appending [name]\n");
 293                           usage.append("    -remove [name]  - removes pegasus as a Windows "
 294                               "Service\n");
 295                           usage.append("                      [name] is optional and overrides "
 296                               "the\n");
 297                           usage.append("                      default CIM Server Service Name\n");
 298                           usage.append("                      by appending [name]\n");
 299                           usage.append("    -start [name]   - starts pegasus as a Windows Service\n");
 300                           usage.append("                      [name] is optional and overrides "
 301                               "the\n");
 302                           usage.append("                      default CIM Server Service Name\n");
 303                           usage.append("                      by appending [name]\n");
 304                           usage.append("    -stop [name]    - stops pegasus as a Windows Service\n");
 305                           usage.append("                      [name] is optional and overrides "
 306                               "the\n");
 307                           usage.append("                      default CIM Server Service Name\n");
 308 kumpf           1.202     usage.append("                      by appending [name]\n\n");
 309                       #endif
 310                           usage.append("  configProperty=value\n");
 311                           usage.append("                    - sets CIM Server configuration "
 312                               "property\n");
 313 humberto        1.97  
 314                           cout << endl;
 315 kumpf           1.202     cout << _cimServerProcess->getProductName() << " " <<
 316                               _cimServerProcess->getCompleteVersion() << endl;
 317 humberto        1.97      cout << endl;
 318 david.dillard   1.165 
 319 humberto        1.97  #if defined(PEGASUS_OS_TYPE_WINDOWS)
 320 humberto        1.104     MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
 321 kumpf           1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
 322 kumpf           1.202     MessageLoaderParms parms(
 323                               "src.Server.cimserver.MENU.HPUXLINUXIA64GNU",
 324                               usage);
 325 humberto        1.97  #else
 326 kumpf           1.138     MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
 327 humberto        1.97  #endif
 328                           cout << MessageLoader::getMessage(parms) << endl;
 329 mike            1.35  }
 330                       
 331 kumpf           1.202 // This needs to be called at various points in the code depending on the
 332                       // platform and error conditions.
 333                       // We need to delete the _cimServer reference on exit in order for the
 334                       // destructors to get called.
 335 h.sterling      1.156 void deleteCIMServer()
 336                       {
 337 kumpf           1.203     delete _cimServer;
 338                           _cimServer = 0;
 339 kumpf           1.202 
 340                           if (dummyInitialThread)
 341                           {
 342 kumpf           1.199         Thread::clearLanguages();
 343                               delete dummyInitialThread;
 344 kumpf           1.202     }
 345 h.sterling      1.156 }
 346                       
 347 chuck           1.96  //
 348                       // Dummy function for the Thread object associated with the initial thread.
 349                       // Since the initial thread is used to process CIM requests, this is
 350                       // needed to localize the exceptions thrown during CIM request processing.
 351 david.dillard   1.165 // Note: This function should never be called!
 352                       //
 353 kumpf           1.202 ThreadReturnType PEGASUS_THREAD_CDECL dummyThreadFunc(void* parm)
 354 chuck           1.96  {
 355 kumpf           1.202     return (ThreadReturnType)0;
 356 chuck           1.96  }
 357                       
 358 kumpf           1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 359                       
 360                       static int _extractExecutorSockOpt(int& argc, char**& argv)
 361                       {
 362                           // Extract the "--executor-socket <sock>" option if any. This indicates
 363                           // that the e[x]ecutor is running. The option argument is the socket used
 364                           // to communicate with the executor. Remove the option from the
 365                           // argv list and decrease argc by two.
 366                       
 367                           int sock = -1;
 368                           const char OPT[] = "--executor-socket";
 369                       
 370                           for (int i = 1; i < argc; i++)
 371                           {
 372                               if (strcmp(argv[i], OPT) == 0)
 373                               {
 374                                   // Check for missing option argument.
 375                       
 376                                   if (i + 1 == argc)
 377                                   {
 378                                       MessageLoaderParms parms(
 379 kumpf           1.199                     "src.Server.cimserver.MISSING_OPTION_ARGUMENT",
 380                                           "Missing argument for $0 option.",
 381                                           OPT);
 382                                       cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
 383                                           endl;
 384                                       exit(1);
 385                                   }
 386                       
 387                                   // Convert argument to positive integer.
 388                       
 389                                   char* end;
 390                                   unsigned long x = strtoul(argv[i+1], &end, 10);
 391                       
 392                                   // Check whether option argument will fit in a signed integer.
 393                       
 394                                   if (*end != '\0' || x > 2147483647)
 395                                   {
 396                                       MessageLoaderParms parms(
 397                                           "src.Server.cimserver.BAD_OPTION_ARGUMENT",
 398                                           "Bad $0 option argument: $1.",
 399                                           OPT,
 400 kumpf           1.199                     argv[i+1]);
 401                                       cerr << argv[0] << ": " << MessageLoader::getMessage(parms) <<
 402                                           endl;
 403                                       exit(1);
 404                                   }
 405                       
 406                                   sock = int(x);
 407                       
 408                                   // Remove "-x <sock>" from argv-argc.
 409                       
 410                                   memmove(argv + i, argv + i + 2, sizeof(char*) * (argc - i - 1));
 411                                   argc -= 2;
 412                                   break;
 413                               }
 414                           }
 415                       
 416                           if (sock == -1)
 417                           {
 418                               MessageLoaderParms parms(
 419                                   "src.Server.cimserver.MISSING_OPTION",
 420                                   "Missing $0 option.",
 421 kumpf           1.199             OPT);
 422                               cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
 423                               exit(1);
 424                           }
 425                       
 426                           return sock;
 427                       }
 428                       
 429                       #endif /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION */
 430 mike            1.35  
 431 venkat.puvvada  1.231 static void _initConfigProperty(const String &propName, Uint32 value)
 432                       {
 433                           char strValue[22];
 434                           Uint32 n;
 435                           const char *startP = Uint32ToString(
 436                               strValue,
 437                               value,
 438                               n);
 439                           ConfigManager::getInstance()->initCurrentValue(propName, String(startP, n));
 440                       }
 441                       
 442 mike            1.33  /////////////////////////////////////////////////////////////////////////
 443 mike            1.32  //  MAIN
 444                       //////////////////////////////////////////////////////////////////////////
 445 kumpf           1.199 
 446 mike            1.32  int main(int argc, char** argv)
 447                       {
 448 kumpf           1.196     String pegasusHome;
 449 mike            1.35      Boolean shutdownOption = false;
 450 kumpf           1.178     Boolean debugOutputOption = false;
 451 mday            1.47  
 452 kumpf           1.202     // Set Message loading to process locale
 453                           MessageLoader::_useProcessLocale = true;
 454 humberto        1.97  
 455 thilo.boehm     1.211 #ifdef PEGASUS_OS_ZOS
 456                           // Direct standard input to /dev/null,
 457                           close(STDIN_FILENO);
 458                           open("/dev/null", O_RDONLY);
 459                       
 460                           if ( setEBCDICEncoding(STDOUT_FILENO)==-1 ||
 461                                setEBCDICEncoding(STDERR_FILENO)==-1 )
 462                           {
 463 marek           1.220        PEG_TRACE_CSTRING(TRC_SERVER,Tracer::LEVEL1,
 464 thilo.boehm     1.211            "Coud not set stdout or stderr to EBCDIC encoding.");
 465                           }
 466                           // Need to initialize timezone information in the
 467                           // initial processing thread (IPT)
 468 marek           1.236     initialize_zOS_timezone();
 469 thilo.boehm     1.211 #endif
 470                       
 471 kv.le           1.140 #if defined(PEGASUS_OS_AIX) && defined(PEGASUS_HAS_MESSAGES)
 472 kumpf           1.202     setlocale(LC_ALL, "");
 473 kv.le           1.140 #endif
 474                       
 475 tony            1.82  #ifndef PEGASUS_OS_TYPE_WINDOWS
 476 kumpf           1.38      //
 477                           // Get environment variables:
 478                           //
 479 kumpf           1.202 # if defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
 480 kv.le           1.134     pegasusHome = AIX_RELEASE_PEGASUS_HOME;
 481 ouyang.jian     1.210 # elif defined(PEGASUS_OS_PASE)
 482                           const char *tmp = getenv("PEGASUS_HOME");
 483                           pegasusHome = (tmp == 0) ? PASE_DEFAULT_PEGASUS_HOME : tmp;
 484 kumpf           1.202 # elif !defined(PEGASUS_USE_RELEASE_DIRS) || \
 485 r.kieninger     1.223     defined(PEGASUS_OS_ZOS)
 486 kumpf           1.38      const char* tmp = getenv("PEGASUS_HOME");
 487                       
 488                           if (tmp)
 489                           {
 490                               pegasusHome = tmp;
 491                           }
 492 kumpf           1.202 # endif
 493 kumpf           1.38  
 494                           FileSystem::translateSlashes(pegasusHome);
 495 tony            1.82  #else
 496 kumpf           1.38  
 497 kumpf           1.202     // windows only
 498                           //setHome(pegasusHome);
 499                           pegasusHome = _cimServerProcess->getHome();
 500 tony            1.82  #endif
 501 mike            1.32  
 502 kumpf           1.199 #ifdef PEGASUS_ENABLE_PRIVILEGE_SEPARATION
 503                       
 504                           // If invoked with "--executor-socket <socket>" option, then use executor.
 505                       
 506                           Executor::setSock(_extractExecutorSockOpt(argc, argv));
 507                       
 508                           // Ping executor to verify the specified socket is valid.
 509                       
 510                           if (Executor::ping() != 0)
 511                           {
 512                               MessageLoaderParms parms("src.Server.cimserver.EXECUTOR_PING_FAILED",
 513                                   "Failed to ping the executor on the specified socket.");
 514                               cerr << argv[0] << ": " << MessageLoader::getMessage(parms) << endl;
 515                               exit(1);
 516                           }
 517                       
 518                       #endif /* !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
 519                       
 520 denise.eckstein 1.229         // Get help, version, status and shutdown options
 521 mike            1.35  
 522                               for (int i = 1; i < argc; )
 523                               {
 524                                   const char* arg = argv[i];
 525 kumpf           1.216             if (strcmp(arg, "--help") == 0)
 526 a.arora         1.142             {
 527 kumpf           1.216                 PrintHelp(argv[0]);
 528                                       Executor::daemonizeExecutor();
 529                                       exit(0);
 530 a.arora         1.142             }
 531 denise.eckstein 1.229             if (strcmp(arg, "--status") == 0)
 532                                   {
 533                                       int retValue = 0;
 534                                       if (_serverRunStatus.isServerRunning())
 535                                       {
 536                                           MessageLoaderParms parms(
 537                                               "src.Server.cimserver.CIMSERVER_RUNNING",
 538                                               "The CIM Server is running.");
 539                                           cout << MessageLoader::getMessage(parms) << endl;
 540                                       }
 541                                       else
 542                                       {
 543                                           MessageLoaderParms parms(
 544                                               "src.Server.cimserver.CIMSERVER_NOT_RUNNING",
 545                                               "The CIM Server is not running.");
 546                                           cout << MessageLoader::getMessage(parms) << endl;
 547                                           retValue = 2;
 548                                       }
 549                                       Executor::daemonizeExecutor();
 550                                       exit(retValue);
 551                                   }
 552 kumpf           1.216             else if (strcmp(arg, "--version") == 0)
 553 a.arora         1.142             {
 554 jim.wunderlich  1.180                 cout << _cimServerProcess->getCompleteVersion() << endl;
 555 kumpf           1.216                 Executor::daemonizeExecutor();
 556 a.arora         1.142                 exit(0);
 557                                   }
 558 mike            1.35              // Check for -option
 559 a.arora         1.142             else if (*arg == '-')
 560 mike            1.35              {
 561                                       // Get the option
 562                                       const char* option = arg + 1;
 563                       
 564                                       //
 565                                       // Check to see if user asked for the version (-v option):
 566                                       //
 567 tony            1.83                  if (*option == OPTION_VERSION &&
 568                                           strlen(option) == 1)
 569 mike            1.35                  {
 570 jim.wunderlich  1.180                     cout << _cimServerProcess->getCompleteVersion() << endl;
 571 kumpf           1.216                     Executor::daemonizeExecutor();
 572 mike            1.35                      exit(0);
 573                                       }
 574                                       //
 575                                       // Check to see if user asked for help (-h option):
 576                                       //
 577 tony            1.83                  else if (*option == OPTION_HELP &&
 578                                               (strlen(option) == 1))
 579 mike            1.35                  {
 580                                           PrintHelp(argv[0]);
 581 kumpf           1.216                     Executor::daemonizeExecutor();
 582 mike            1.35                      exit(0);
 583                                       }
 584 kumpf           1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
 585 tony            1.83                  else if (*option == OPTION_HOME &&
 586                                               (strlen(option) == 1))
 587 mike            1.35                  {
 588 kumpf           1.60                      if (i + 1 < argc)
 589 mike            1.35                      {
 590                                               pegasusHome.assign(argv[i + 1]);
 591                                           }
 592                                           else
 593                                           {
 594 humberto        1.99                          String opt(option);
 595 kumpf           1.202                         MessageLoaderParms parms(
 596                                                   "src.Server.cimserver.MISSING_ARGUMENT",
 597                                                   "Missing argument for option -$0",
 598                                                   opt);
 599 h.sterling      1.153                         cout << MessageLoader::getMessage(parms) << endl;
 600 kumpf           1.216                         exit(1);
 601 mike            1.35                      }
 602                       
 603                                           memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
 604                                           argc -= 2;
 605                                       }
 606 kumpf           1.63  #endif
 607 kumpf           1.48                  //
 608 kumpf           1.178                 // Check to see if user asked for debug output (-X option):
 609 kumpf           1.48                  //
 610 kumpf           1.178                 else if (*option == OPTION_DEBUGOUTPUT &&
 611 tony            1.83                          (strlen(option) == 1))
 612 kumpf           1.48                  {
 613 kumpf           1.178                     MessageLoaderParms parms(
 614                                               "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
 615                                               "Unsupported debug output option is enabled.");
 616 h.sterling      1.153                     cout << MessageLoader::getMessage(parms) << endl;
 617 kumpf           1.178 
 618                                           debugOutputOption = true;
 619                       
 620                       #if defined(PEGASUS_OS_HPUX)
 621                                           System::bindVerbose = true;
 622                       #endif
 623                       
 624 kumpf           1.48                      // remove the option from the command line
 625                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 626 david.dillard   1.165                     argc--;
 627 kumpf           1.48                  }
 628 mike            1.35                  //
 629                                       // Check to see if user asked for shutdown (-s option):
 630                                       //
 631 tony            1.82                  else if (*option == OPTION_SHUTDOWN &&
 632                                               (strlen(option) == 1))
 633 mike            1.35                  {
 634                                           //
 635 kumpf           1.52                      // Check to see if shutdown has already been specified:
 636 mike            1.35                      //
 637 kumpf           1.52                      if (shutdownOption)
 638 mike            1.35                      {
 639 kumpf           1.202                         MessageLoaderParms parms(
 640                                                   "src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
 641                                                   "Duplicate shutdown option specified.");
 642 david.dillard   1.165 
 643 humberto        1.97                          cout << MessageLoader::getMessage(parms) << endl;
 644 kumpf           1.216                         exit(1);
 645 mike            1.35                      }
 646                       
 647 kumpf           1.52                      shutdownOption = true;
 648 david.dillard   1.165 
 649 mike            1.35                      // remove the option from the command line
 650                                           memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 651 david.dillard   1.165                     argc--;
 652 mike            1.35                  }
 653                                       else
 654                                           i++;
 655                                   }
 656                                   else
 657                                       i++;
 658 mike            1.32          }
 659 mike            1.35  
 660 kumpf           1.38      //
 661                           // Set the value for pegasusHome property
 662                           //
 663                           ConfigManager::setPegasusHome(pegasusHome);
 664 mike            1.32  
 665 mike            1.35      //
 666 carolann.graves 1.171     // Do the platform specific run
 667 s.hills         1.117     //
 668                       
 669 kumpf           1.178     return _cimServerProcess->platform_run(
 670                               argc, argv, shutdownOption, debugOutputOption);
 671 s.hills         1.117 }
 672                       
 673 h.sterling      1.153 void CIMServerProcess::cimserver_stop()
 674                       {
 675                           _cimServer->shutdownSignal();
 676                       }
 677 s.hills         1.117 
 678                       //
 679                       // The main, common, running code
 680                       //
 681 david.dillard   1.165 // NOTE: Do NOT call exit().  Use return(), otherwise some platforms
 682 s.hills         1.117 // will fail to shutdown properly/cleanly.
 683                       //
 684 david.dillard   1.165 // TODO: Current change minimal for platform "service" shutdown bug fixes.
 685 carolann.graves 1.171 // Perhaps further extract out common stuff and put into main(), put
 686 david.dillard   1.165 // daemon stuff into platform specific platform_run(), etc.
 687                       // Note: make sure to not put error handling stuff that platform
 688 carolann.graves 1.171 // specific runs may need to deal with better (instead of exit(), etc).
 689 s.hills         1.117 //
 690                       
 691 kumpf           1.178 int CIMServerProcess::cimserver_run(
 692                           int argc,
 693                           char** argv,
 694                           Boolean shutdownOption,
 695                           Boolean debugOutputOption)
 696 s.hills         1.117 {
 697                           Boolean daemonOption = false;
 698                       
 699 ouyang.jian     1.206 #if defined (PEGASUS_OS_PASE) && !defined (PEGASUS_DEBUG)
 700                           // PASE have itself regular for checking privileged user
 701                           if (!System::isPrivilegedUser("*CURRENT  "))
 702                           {
 703                               MessageLoaderParms parms(
 704                                       "src.Server.cimserver.NO_AUTHORITY.PEGASUS_OS_PASE",
 705                                       "The caller should be a privileged user,"
 706                                       " or the server will not run.");
 707                               cerr << MessageLoader::getMessage(parms) << endl;
 708                               exit (1);
 709                           }
 710                           char jobName[11];
 711                           // this function only can be found in PASE environment
 712                           umeGetJobName(jobName, false);
 713                           if (strncmp("QUMECIMOM ", jobName, 10) != 0
 714                                   && strncmp("QUMEENDCIM", jobName, 10) != 0)
 715                           {
 716                               MessageLoaderParms parms(
 717                                       "src.Server.cimserver.NOT_OFFICIAL_START.PEGASUS_OS_PASE",
 718                                       "cimserver can not be started by user.\nServer will not run.");
 719                               cerr << MessageLoader::getMessage(parms) << endl;
 720 ouyang.jian     1.206         exit (1);
 721                           }
 722                       
 723 kumpf           1.228     // Direct standard input, output, and error to /dev/null,
 724 ouyang.jian     1.206     // PASE run this job in background, any output in not allowed
 725                           freopen("/dev/null", "r", stdin);
 726                           freopen("/dev/null", "w", stdout);
 727                           freopen("/dev/null", "w", stderr);
 728                       #endif
 729                       
 730 s.hills         1.117     //
 731 mike            1.35      // Get an instance of the Config Manager.
 732                           //
 733 kumpf           1.203     ConfigManager* configManager = ConfigManager::getInstance();
 734 kumpf           1.136     configManager->useConfigFiles = true;
 735 mike            1.35  
 736 mike            1.32      try
 737                           {
 738 kumpf           1.203         //
 739                               // Get options (from command line and from configuration file); this
 740                               // removes corresponding options and their arguments from the command
 741                               // line.  NOTE: If shutdownOption=true, the contents of current config
 742                               // file are not overwritten by the planned config file.
 743                               //
 744 mateus.baur     1.193         GetOptions(configManager, argc, argv, shutdownOption);
 745 kumpf           1.127 
 746 kumpf           1.203         //
 747                               // Initialize the message home directory in the MessageLoader.
 748                               // This is the default directory where the resource bundles are found.
 749                               //
 750                               MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
 751                                   ConfigManager::getInstance()->getCurrentValue("messageDir")));
 752 kumpf           1.86  
 753 ouyang.jian     1.224 #if !defined(PEGASUS_USE_SYSLOGS)
 754                               String logsDirectory = ConfigManager::getHomedPath(
 755                                   configManager->getCurrentValue("logdir"));
 756                       
 757                               // Set up the Logger.  This does not open the logs.
 758                               // Might be more logical to clean before set.
 759                               Logger::setHomeDirectory(logsDirectory);
 760                       #endif
 761                       
 762                       
 763 ouyang.jian     1.206 #ifdef PEGASUS_OS_PASE
 764 ouyang.jian     1.224         /* write job log to tell where pegasus log is.*/
 765                               if(logsDirectory.size() > 0)
 766                                   // this function only can be found in PASE environment
 767                                   logPegasusDir2joblog(logsDirectory.getCString());
 768                               else
 769                                   logPegasusDir2joblog(".");
 770                       
 771                               // set ccsid to unicode for entire job
 772                               // ccsid is globolization mechanism in PASE environment
 773                               if (_SETCCSID(1208) == -1)
 774                               {
 775                                   MessageLoaderParms parms(
 776                                           "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
 777                                           "Failed to set CCSID, server will stop.");
 778                                   cerr << MessageLoader::getMessage(parms) << endl;
 779                                   Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
 780                                           parms);
 781                                   exit (1);
 782                               }
 783 ouyang.jian     1.206 
 784 ouyang.jian     1.224         char fullJobName[29];
 785                               umeGetJobName(fullJobName, true);
 786                               Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
 787                                       Logger::INFORMATION,
 788                                       MessageLoaderParms(
 789                                           "src.Server.cimserver.SERVER_JOB_NAME.PEGASUS_OS_PASE",
 790                                           "CIM Server's Job Name is: $0", fullJobName));
 791 ouyang.jian     1.206 #endif
 792                       
 793 kumpf           1.221 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 794                               // Make sure at least one connection is enabled
 795 ouyang.jian     1.206 
 796 kumpf           1.221         Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 797                                   configManager->getCurrentValue("enableHttpConnection"));
 798                               Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 799                                   configManager->getCurrentValue("enableHttpsConnection"));
 800                       
 801                               if (!enableHttpConnection && !enableHttpsConnection)
 802                               {
 803                                   MessageLoaderParms parms(
 804 ouyang.jian     1.206                 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 805                                       "Neither HTTP nor HTTPS connection is enabled."
 806 kumpf           1.221                     "  CIMServer will not be started.");
 807 kumpf           1.222             Logger::put_l(
 808                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 809                                       parms);
 810 kumpf           1.221             cerr << MessageLoader::getMessage(parms) << endl;
 811                                   return 1;
 812                               }
 813 ouyang.jian     1.206 #endif
 814 kumpf           1.221 
 815 mike            1.35          //
 816 kumpf           1.187         // Check to see if we should start Pegasus as a daemon
 817 mike            1.35          //
 818 kumpf           1.187         daemonOption = ConfigManager::parseBooleanValue(
 819                                   configManager->getCurrentValue("daemon"));
 820 david.dillard   1.165 
 821 kumpf           1.215         if ((Executor::detectExecutor() == 0) && (daemonOption == false))
 822                               {
 823                                   MessageLoaderParms parms(
 824                                       "src.Server.cimserver.PRIVSEP_REQUIRES_DAEMON",
 825                                       "Warning: The configuration setting daemon=false is ignored "
 826                                           "with privilege separation enabled.");
 827                                   cerr << MessageLoader::getMessage(parms) << endl;
 828                                   daemonOption = true;
 829                               }
 830                       
 831 kumpf           1.36          //
 832 david.dillard   1.165         // Check to see if we need to shutdown CIMOM
 833 mike            1.35          //
 834                               if (shutdownOption)
 835                               {
 836 david.dillard   1.165             String configTimeout =
 837 kumpf           1.60                  configManager->getCurrentValue("shutdownTimeout");
 838 kumpf           1.202             Uint32 timeoutValue =
 839                                       strtol(configTimeout.getCString(), (char **)0, 10);
 840 david.dillard   1.165 
 841 kumpf           1.198             ServerShutdownClient serverShutdownClient(&_serverRunStatus);
 842                                   serverShutdownClient.shutdown(timeoutValue);
 843 kumpf           1.45  
 844 kumpf           1.198             MessageLoaderParms parms(
 845                                       "src.Server.cimserver.SERVER_STOPPED",
 846                                       "CIM Server stopped.");
 847 humberto        1.106 
 848 humberto        1.97              cout << MessageLoader::getMessage(parms) << endl;
 849 kumpf           1.202             return 0;
 850 mike            1.35          }
 851 mike            1.32  
 852 kumpf           1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
 853 kumpf           1.36          // Leave this in until people get familiar with the logs.
 854 humberto        1.97          MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
 855 h.sterling      1.153                                  "Logs Directory = ");
 856 humberto        1.97          cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
 857 kumpf           1.57  #endif
 858 mike            1.32      }
 859 kumpf           1.203     catch (Exception& e)
 860 mike            1.32      {
 861 kumpf           1.203         MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 862                                   "cimserver not started: $0", e.getMessage());
 863 kumpf           1.222         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 864                                   parms);
 865 kumpf           1.203         cerr << MessageLoader::getMessage(parms) << endl;
 866                       
 867                               return 1;
 868 marek           1.186     }
 869 david           1.85  
 870 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS) && defined(PEGASUS_ZOS_SECURITY)
 871 marek           1.186     startupCheckBPXServer(true);
 872                           startupCheckProfileCIMSERVclassWBEM();
 873                           startupEnableMSC();
 874 david           1.85  #endif
 875 mike            1.32  
 876 kumpf           1.139 #if defined(PEGASUS_DEBUG)
 877 mike            1.32      // Put out startup up message.
 878 kumpf           1.202     cout << _cimServerProcess->getProductName() << " " <<
 879                               _cimServerProcess->getCompleteVersion() << endl;
 880 humberto        1.97  #endif
 881                       
 882 kumpf           1.202     // reset message loading to NON-process locale
 883                           MessageLoader::_useProcessLocale = false;
 884 mike            1.32  
 885 kumpf           1.137     // Get the parent's PID before forking
 886 kumpf           1.198     _serverRunStatus.setParentPid(System::getPID());
 887 david.dillard   1.165 
 888 kumpf           1.202     // Do not fork when using privilege separation (executor will daemonize
 889                           // itself later).
 890 kumpf           1.63      if (daemonOption)
 891                           {
 892 kumpf           1.202         if (-1 == _cimServerProcess->cimserver_fork())
 893                                   return -1;
 894 kumpf           1.63      }
 895 chuck           1.66  
 896 chuck           1.96      // Now we are after the fork...
 897                           // Create a dummy Thread object that can be used to store the
 898 kumpf           1.176     // AcceptLanguageList object for CIM requests that are serviced
 899 chuck           1.96      // by this thread (initial thread of server).  Need to do this
 900                           // because this thread is not in a ThreadPool, but is used
 901                           // to service CIM requests.
 902                           // The run function for the dummy Thread should never be called,
 903 konrad.r        1.166     dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
 904 david.dillard   1.165     Thread::setCurrent(dummyInitialThread);
 905 kumpf           1.202     try
 906                           {
 907 kumpf           1.214         Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages());
 908 kumpf           1.202     }
 909                           catch (InvalidAcceptLanguageHeader& e)
 910                           {
 911 kumpf           1.203         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 912 kumpf           1.222             MessageLoaderParms(
 913                                       "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
 914                                       "Could not convert the system process locale into a valid "
 915                                           "AcceptLanguage format."));
 916 kumpf           1.203         Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 917                                   e.getMessage());
 918 humberto        1.108     }
 919 david.dillard   1.165 
 920 kumpf           1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
 921                           umask(S_IRWXG|S_IRWXO);
 922                       #endif
 923 mday            1.62  
 924 kumpf           1.203     // Start up the CIM Server
 925 mateus.baur     1.175 
 926 kumpf           1.203     try
 927                           {
 928 mateus.baur     1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
 929 kumpf           1.203         //
 930                               // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
 931                               // concurrent writes to this file by multiple cimserver processes
 932                               // starting at the same time.
 933                               //
 934                               CString startupLockFileName = ConfigManager::getHomedPath(
 935 kumpf           1.204             PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
 936 kumpf           1.203 
 937                               // Make sure the start-up lock file exists
 938                               FILE* startupLockFile;
 939                               if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
 940                               {
 941                                   fclose(startupLockFile);
 942                               }
 943 kumpf           1.202 
 944 kumpf           1.203         AutoFileLock fileLock(startupLockFileName);
 945                       #endif
 946 kumpf           1.202 
 947 kumpf           1.203 #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
 948                               //
 949                               // Check if a CIM Server is already running.  If so, print an error
 950                               // message and notify the parent process (if there is one) to terminate
 951                               //
 952                               if (_serverRunStatus.isServerRunning())
 953                               {
 954                                   MessageLoaderParms parms(
 955                                       "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
 956                                       "Unable to start CIMServer. CIMServer is already running.");
 957 kumpf           1.222             Logger::put_l(
 958 kumpf           1.203                 Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 959 kumpf           1.222                 parms);
 960 kumpf           1.203             cerr << MessageLoader::getMessage(parms) << endl;
 961 mateus.baur     1.175 
 962 kumpf           1.203             if (daemonOption)
 963                                   {
 964                                       _cimServerProcess->notify_parent(1);
 965                                   }
 966 kumpf           1.79  
 967 kumpf           1.203             return 1;
 968                               }
 969 kumpf           1.79  
 970 kumpf           1.198         //
 971 kumpf           1.203         // Declare ourselves as the running CIM Server process, and write our
 972                               // PID to the PID file.
 973 kumpf           1.79          //
 974 kumpf           1.203         _serverRunStatus.setServerRunning();
 975                       #endif
 976                       
 977                               // Create and initialize the CIMServer object
 978                       
 979                               _cimServer = new CIMServer();
 980                       
 981                               Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 982                                   configManager->getCurrentValue("enableHttpConnection"));
 983                               Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 984                                   configManager->getCurrentValue("enableHttpsConnection"));
 985                       
 986                       #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 987                               // Make sure at least one connection is enabled
 988                               if (!enableHttpConnection && !enableHttpsConnection)
 989 kumpf           1.198         {
 990 kumpf           1.203             MessageLoaderParms parms(
 991                                       "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 992                                       "Neither HTTP nor HTTPS connection is enabled.");
 993                                   throw Exception(parms);
 994 kumpf           1.198         }
 995 kumpf           1.63  #endif
 996 kumpf           1.51  
 997 venkat.puvvada  1.208         Boolean addIP6Acceptor = false;
 998                               Boolean addIP4Acceptor = false;
 999                       
1000                       #ifdef PEGASUS_OS_TYPE_WINDOWS
1001                               addIP4Acceptor = true;
1002                       #endif
1003                       
1004                       #ifdef PEGASUS_ENABLE_IPV6
1005                               // If IPv6 stack is disabled swicth to IPv4 stack.
1006                               if (System::isIPv6StackActive())
1007                               {
1008                                   addIP6Acceptor = true;
1009                               }
1010                               else
1011                               {
1012 marek           1.233             PEG_TRACE_CSTRING(TRC_SERVER,Tracer::LEVEL4,
1013 venkat.puvvada  1.208                 "IPv6 stack is not active, using IPv4 socket.");
1014                               }
1015                       #endif
1016                               if (!addIP6Acceptor)
1017                               {
1018                                   addIP4Acceptor = true;
1019                               }
1020                       
1021 kumpf           1.203         // The server HTTP and HTTPS ports are determined via this algorithm:
1022                               // 1) If the user explicitly specified a port, use it.
1023                               // 2) If the user did not specify a port, get the port from the
1024                               //    services file.
1025                               // 3) If no value is specified in the services file, use the IANA WBEM
1026                               //    default port.
1027                               // Note that 2 and 3 are done within the System::lookupPort method
1028                               // An empty string from the ConfigManager implies that the user did not
1029                               // specify a port.
1030 kumpf           1.41  
1031 kumpf           1.86          if (enableHttpConnection)
1032                               {
1033 kumpf           1.203             Uint32 portNumberHttp = 0;
1034                                   String httpPort = configManager->getCurrentValue("httpPort");
1035                                   if (httpPort == String::EMPTY)
1036                                   {
1037                                       //
1038                                       // Look up the WBEM-HTTP port number
1039                                       //
1040                                       portNumberHttp = System::lookupPort(
1041                                           WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1042 venkat.puvvada  1.231                 _initConfigProperty("httpPort", portNumberHttp);
1043 kumpf           1.203             }
1044                                   else
1045                                   {
1046                                       //
1047                                       // user-specified
1048                                       //
1049                                       CString portString = httpPort.getCString();
1050                                       char* end = 0;
1051                                       portNumberHttp = strtol(portString, &end, 10);
1052                                       if (!(end != 0 && *end == '\0'))
1053                                       {
1054                                           throw InvalidPropertyValue("httpPort", httpPort);
1055                                       }
1056                                   }
1057                       
1058 venkat.puvvada  1.208             if (addIP6Acceptor)
1059                                   {
1060                                       _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1061                                           portNumberHttp, false);
1062                                   }
1063                                   if (addIP4Acceptor)
1064                                   {
1065                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1066                                           portNumberHttp, false);
1067                                   }
1068 denise.eckstein 1.225             // The port number is converted to a string to avoid the
1069                                   //  addition of localized characters (e.g., "5,988").
1070 denise.eckstein 1.218             char scratchBuffer[22];
1071                                   Uint32 n;
1072                                   const char * portNumberHttpStr = Uint32ToString(
1073 kumpf           1.228                 scratchBuffer, portNumberHttp, n);
1074 kumpf           1.203             MessageLoaderParms parms(
1075 kumpf           1.198                 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1076 denise.eckstein 1.218                 "Listening on HTTP port $0.", portNumberHttpStr);
1077 kumpf           1.222             Logger::put_l(
1078 kumpf           1.203                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1079 kumpf           1.222                 parms);
1080 kumpf           1.203 #if defined(PEGASUS_DEBUG)
1081                                   cout << MessageLoader::getMessage(parms) << endl;
1082                       #endif
1083 kumpf           1.86          }
1084 kumpf           1.198 
1085 kumpf           1.86          if (enableHttpsConnection)
1086                               {
1087 kumpf           1.203             Uint32 portNumberHttps = 0;
1088                                   String httpsPort = configManager->getCurrentValue("httpsPort");
1089                                   if (httpsPort == String::EMPTY)
1090                                   {
1091                                       //
1092                                       // Look up the WBEM-HTTPS port number
1093                                       //
1094                                       portNumberHttps = System::lookupPort(
1095                                           WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1096 venkat.puvvada  1.231                 _initConfigProperty("httpsPort", portNumberHttps);
1097 kumpf           1.203             }
1098                                   else
1099                                   {
1100                                       //
1101                                       // user-specified
1102                                       //
1103                                       CString portString = httpsPort.getCString();
1104                                       char* end = 0;
1105                                       portNumberHttps = strtol(portString, &end, 10);
1106                                       if (!(end != 0 && *end == '\0'))
1107                                       {
1108                                           throw InvalidPropertyValue("httpsPort", httpsPort);
1109                                       }
1110                                   }
1111 venkat.puvvada  1.208             if (addIP6Acceptor)
1112 kumpf           1.228             {
1113 venkat.puvvada  1.208                 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1114                                           portNumberHttps, true);
1115                                   }
1116                                   if (addIP4Acceptor)
1117                                   {
1118                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1119                                           portNumberHttps, true);
1120                                   }
1121 denise.eckstein 1.225             // The port number is converted to a string to avoid the
1122                                   //  addition of localized characters (e.g., "5,989").
1123 denise.eckstein 1.218             char scratchBuffer[22];
1124                                   Uint32 n;
1125                                   const char * portNumberHttpsStr = Uint32ToString(
1126 kumpf           1.228                 scratchBuffer, portNumberHttps, n);
1127 kumpf           1.203             MessageLoaderParms parms(
1128 kumpf           1.198                 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1129 denise.eckstein 1.218                 "Listening on HTTPS port $0.", portNumberHttpsStr);
1130 kumpf           1.222             Logger::put_l(
1131 kumpf           1.203                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1132 kumpf           1.222                 parms);
1133 kumpf           1.203 #if defined(PEGASUS_DEBUG)
1134                                   cout << MessageLoader::getMessage(parms) << endl;
1135                       #endif
1136 kumpf           1.86          }
1137 kumpf           1.135 
1138 h.sterling      1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1139 kumpf           1.203         {
1140 dave.sudlik     1.205             _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
1141 kumpf           1.86  
1142 kumpf           1.198             MessageLoaderParms parms(
1143 kumpf           1.203                 "src.Server.cimserver.LISTENING_ON_LOCAL",
1144                                       "Listening on local connection socket.");
1145 kumpf           1.222             Logger::put_l(
1146 kumpf           1.203                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1147 kumpf           1.222                 parms);
1148 kumpf           1.203 # if defined(PEGASUS_DEBUG)
1149 h.sterling      1.153             cout << MessageLoader::getMessage(parms) << endl;
1150 kumpf           1.203 # endif
1151 kumpf           1.86          }
1152 david           1.85  #endif
1153 mike            1.35  
1154 kumpf           1.198         _cimServer->bind();
1155 kumpf           1.199 
1156 kumpf           1.198         // notify parent process (if there is a parent process) to terminate
1157 konrad.r        1.95          // so user knows that there is cimserver ready to serve CIM requests.
1158 kumpf           1.198         if (daemonOption)
1159                               {
1160                                   _cimServerProcess->notify_parent(0);
1161                               }
1162 mike            1.35  
1163 kumpf           1.139 #if defined(PEGASUS_DEBUG)
1164 kumpf           1.202         cout << "Started. " << endl;
1165 kumpf           1.63  #endif
1166 david.dillard   1.165 
1167 kumpf           1.54          // Put server started message to the logger
1168 kumpf           1.143         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1169                                   Logger::INFORMATION,
1170 kumpf           1.222             MessageLoaderParms(
1171                                       "src.Server.cimserver.STARTED_VERSION",
1172                                       "Started $0 version $1.",
1173                                       _cimServerProcess->getProductName(),
1174                                       _cimServerProcess->getCompleteVersion()));
1175 kumpf           1.45  
1176 marek           1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
1177 kumpf           1.178         if (daemonOption && !debugOutputOption)
1178 kumpf           1.202         {
1179 kumpf           1.178             // Direct standard input, output, and error to /dev/null,
1180                                   // since we are running as a daemon.
1181 thilo.boehm     1.211             close(STDIN_FILENO);
1182 kumpf           1.178             open("/dev/null", O_RDONLY);
1183 thilo.boehm     1.211             close(STDOUT_FILENO);
1184 kumpf           1.178             open("/dev/null", O_RDWR);
1185 thilo.boehm     1.211             close(STDERR_FILENO);
1186 kumpf           1.178             open("/dev/null", O_RDWR);
1187                               }
1188                       #endif
1189 kumpf           1.203     }
1190                           catch (Exception& e)
1191                           {
1192                               MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1193                                   "cimserver not started: $0", e.getMessage());
1194 kumpf           1.222         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1195                                   parms);
1196 kumpf           1.203         cerr << MessageLoader::getMessage(parms) << endl;
1197 kumpf           1.178 
1198 s.kodali        1.234         deleteCIMServer();
1199                       
1200 kumpf           1.203         //
1201                               // notify parent process (if there is a parent process) to terminate
1202                               //
1203                               if (daemonOption)
1204                                   _cimServerProcess->notify_parent(1);
1205                       
1206                               return 1;
1207                           }
1208                       
1209                           // Run the main CIM Server loop
1210                       
1211                           try
1212                           {
1213 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS)
1214 thilo.boehm     1.185 
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                               // Instatiating the automatic restart manager for zOS
1219                               ARM_zOS automaticRestartManager;
1220                       
1221                               // register to zOS ARM
1222                               automaticRestartManager.Register();
1223                       
1224                       #endif
1225                       
1226 marek           1.217 #ifdef PEGASUS_ENABLE_SLP
1227                               _cimServer->startSLPProvider();
1228 kumpf           1.228 #endif
1229 venkat.puvvada  1.232         _cimServer->initComplete();
1230                       
1231 mike            1.35          //
1232                               // Loop to call CIMServer's runForever() method until CIMServer
1233                               // has been shutdown
1234                               //
1235 kumpf           1.202         while (!_cimServer->terminated())
1236                               {
1237                                   _cimServer->runForever();
1238                               }
1239 carson.hovey    1.157 
1240 kumpf           1.45          //
1241                               // normal termination
1242 carson.hovey    1.157         //
1243 kumpf           1.203 
1244 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS)
1245 thilo.boehm     1.185 
1246 kumpf           1.202         // ARM is a z/OS internal restart facility.
1247                               // This is a z/OS specific change.
1248 thilo.boehm     1.185 
1249                               // register to zOS ARM
1250                               automaticRestartManager.DeRegister();
1251                       
1252                       #endif
1253 kumpf           1.143 
1254 kumpf           1.54          // Put server shutdown message to the logger
1255 kumpf           1.222         Logger::put_l(
1256                                   Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1257                                   MessageLoaderParms(
1258                                       "src.Server.cimserver.STOPPED",
1259                                       "$0 stopped.", _cimServerProcess->getProductName()));
1260 mike            1.32      }
1261 kumpf           1.202     catch (Exception& e)
1262 marek           1.195     {
1263 kumpf           1.202         MessageLoaderParms parms(
1264 marek           1.195             "src.Server.cimserver.ERROR",
1265 kumpf           1.202             "Error: $0",
1266                                   e.getMessage());
1267 kumpf           1.222         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1268                                   parms);
1269 kumpf           1.203         cerr << MessageLoader::getMessage(parms) << endl;
1270 marek           1.195 
1271                               deleteCIMServer();
1272                               return 1;
1273                           }
1274 mike            1.32  
1275 h.sterling      1.156     deleteCIMServer();
1276 mike            1.32      return 0;
1277                       }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2