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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2