(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 r.kieninger     1.238.2.1 #if defined(PEGASUS_OS_ZOS) && defined(PEGASUS_ZOS_SECURITY)
 839                                       // This checks whether user is authorized to stop the
 840                                       // CIM Server. When unauthorized a message is logged to
 841                                       // to the user and program exits.
 842                                       shutdownCheckProfileCIMSERVclassWBEM();
 843                                       // Depending on the success of the previous check we may not
 844                                       // reach this code!!!
 845                           #endif
 846 david.dillard   1.165                 String configTimeout =
 847 kumpf           1.60                      configManager->getCurrentValue("shutdownTimeout");
 848 kumpf           1.202                 Uint32 timeoutValue =
 849                                           strtol(configTimeout.getCString(), (char **)0, 10);
 850 david.dillard   1.165     
 851 kumpf           1.198                 ServerShutdownClient serverShutdownClient(&_serverRunStatus);
 852                                       serverShutdownClient.shutdown(timeoutValue);
 853 kumpf           1.45      
 854 kumpf           1.198                 MessageLoaderParms parms(
 855                                           "src.Server.cimserver.SERVER_STOPPED",
 856                                           "CIM Server stopped.");
 857 humberto        1.106     
 858 humberto        1.97                  cout << MessageLoader::getMessage(parms) << endl;
 859 kumpf           1.202                 return 0;
 860 mike            1.35              }
 861 mike            1.32      
 862 kumpf           1.198     #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
 863 kumpf           1.36              // Leave this in until people get familiar with the logs.
 864 humberto        1.97              MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
 865 h.sterling      1.153                                      "Logs Directory = ");
 866 humberto        1.97              cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
 867 kumpf           1.57      #endif
 868 mike            1.32          }
 869 kumpf           1.203         catch (Exception& e)
 870 mike            1.32          {
 871 kumpf           1.203             MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 872                                       "cimserver not started: $0", e.getMessage());
 873 kumpf           1.222             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 874                                       parms);
 875 kumpf           1.203             cerr << MessageLoader::getMessage(parms) << endl;
 876                           
 877                                   return 1;
 878 marek           1.186         }
 879 david           1.85      
 880 thilo.boehm     1.237     #if defined(PEGASUS_OS_ZOS) 
 881                           #  if defined(PEGASUS_ZOS_SECURITY)
 882 marek           1.186         startupCheckBPXServer(true);
 883                               startupCheckProfileCIMSERVclassWBEM();
 884                               startupEnableMSC();
 885 thilo.boehm     1.237     #  endif
 886                               startupWaitForTCPIP();
 887 david           1.85      #endif
 888 mike            1.32      
 889 kumpf           1.139     #if defined(PEGASUS_DEBUG)
 890 mike            1.32          // Put out startup up message.
 891 kumpf           1.202         cout << _cimServerProcess->getProductName() << " " <<
 892                                   _cimServerProcess->getCompleteVersion() << endl;
 893 humberto        1.97      #endif
 894                           
 895 kumpf           1.202         // reset message loading to NON-process locale
 896                               MessageLoader::_useProcessLocale = false;
 897 mike            1.32      
 898 kumpf           1.137         // Get the parent's PID before forking
 899 kumpf           1.198         _serverRunStatus.setParentPid(System::getPID());
 900 david.dillard   1.165     
 901 kumpf           1.202         // Do not fork when using privilege separation (executor will daemonize
 902                               // itself later).
 903 kumpf           1.63          if (daemonOption)
 904                               {
 905 kumpf           1.202             if (-1 == _cimServerProcess->cimserver_fork())
 906                                       return -1;
 907 kumpf           1.63          }
 908 chuck           1.66      
 909 chuck           1.96          // Now we are after the fork...
 910                               // Create a dummy Thread object that can be used to store the
 911 kumpf           1.176         // AcceptLanguageList object for CIM requests that are serviced
 912 chuck           1.96          // by this thread (initial thread of server).  Need to do this
 913                               // because this thread is not in a ThreadPool, but is used
 914                               // to service CIM requests.
 915                               // The run function for the dummy Thread should never be called,
 916 konrad.r        1.166         dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
 917 david.dillard   1.165         Thread::setCurrent(dummyInitialThread);
 918 kumpf           1.202         try
 919                               {
 920 kumpf           1.214             Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages());
 921 kumpf           1.202         }
 922                               catch (InvalidAcceptLanguageHeader& e)
 923                               {
 924 kumpf           1.203             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 925 kumpf           1.222                 MessageLoaderParms(
 926                                           "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
 927                                           "Could not convert the system process locale into a valid "
 928                                               "AcceptLanguage format."));
 929 kumpf           1.203             Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 930                                       e.getMessage());
 931 humberto        1.108         }
 932 david.dillard   1.165     
 933 kumpf           1.167     #ifndef PEGASUS_OS_TYPE_WINDOWS
 934                               umask(S_IRWXG|S_IRWXO);
 935                           #endif
 936 mday            1.62      
 937 kumpf           1.203         // Start up the CIM Server
 938 mateus.baur     1.175     
 939 kumpf           1.203         try
 940                               {
 941 mateus.baur     1.175     #if defined(PEGASUS_OS_TYPE_UNIX)
 942 kumpf           1.203             //
 943                                   // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
 944                                   // concurrent writes to this file by multiple cimserver processes
 945                                   // starting at the same time.
 946                                   //
 947                                   CString startupLockFileName = ConfigManager::getHomedPath(
 948 kumpf           1.204                 PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
 949 kumpf           1.203     
 950                                   // Make sure the start-up lock file exists
 951                                   FILE* startupLockFile;
 952                                   if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
 953                                   {
 954                                       fclose(startupLockFile);
 955                                   }
 956 kumpf           1.202     
 957 kumpf           1.203             AutoFileLock fileLock(startupLockFileName);
 958                           #endif
 959 kumpf           1.202     
 960 kumpf           1.203     #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
 961                                   //
 962                                   // Check if a CIM Server is already running.  If so, print an error
 963                                   // message and notify the parent process (if there is one) to terminate
 964                                   //
 965                                   if (_serverRunStatus.isServerRunning())
 966                                   {
 967                                       MessageLoaderParms parms(
 968                                           "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
 969                                           "Unable to start CIMServer. CIMServer is already running.");
 970 kumpf           1.222                 Logger::put_l(
 971 kumpf           1.203                     Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 972 kumpf           1.222                     parms);
 973 kumpf           1.203                 cerr << MessageLoader::getMessage(parms) << endl;
 974 mateus.baur     1.175     
 975 kumpf           1.203                 if (daemonOption)
 976                                       {
 977                                           _cimServerProcess->notify_parent(1);
 978                                       }
 979 kumpf           1.79      
 980 kumpf           1.203                 return 1;
 981                                   }
 982 kumpf           1.79      
 983 kumpf           1.198             //
 984 kumpf           1.203             // Declare ourselves as the running CIM Server process, and write our
 985                                   // PID to the PID file.
 986 kumpf           1.79              //
 987 kumpf           1.203             _serverRunStatus.setServerRunning();
 988                           #endif
 989                           
 990                                   // Create and initialize the CIMServer object
 991                           
 992                                   _cimServer = new CIMServer();
 993                           
 994                                   Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 995                                       configManager->getCurrentValue("enableHttpConnection"));
 996                                   Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 997                                       configManager->getCurrentValue("enableHttpsConnection"));
 998                           
 999                           #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1000                                   // Make sure at least one connection is enabled
1001                                   if (!enableHttpConnection && !enableHttpsConnection)
1002 kumpf           1.198             {
1003 kumpf           1.203                 MessageLoaderParms parms(
1004                                           "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
1005                                           "Neither HTTP nor HTTPS connection is enabled.");
1006                                       throw Exception(parms);
1007 kumpf           1.198             }
1008 kumpf           1.63      #endif
1009 kumpf           1.51      
1010 venkat.puvvada  1.208             Boolean addIP6Acceptor = false;
1011                                   Boolean addIP4Acceptor = false;
1012                           
1013                           #ifdef PEGASUS_OS_TYPE_WINDOWS
1014                                   addIP4Acceptor = true;
1015                           #endif
1016                           
1017                           #ifdef PEGASUS_ENABLE_IPV6
1018                                   // If IPv6 stack is disabled swicth to IPv4 stack.
1019                                   if (System::isIPv6StackActive())
1020                                   {
1021                                       addIP6Acceptor = true;
1022                                   }
1023                                   else
1024                                   {
1025 marek           1.233                 PEG_TRACE_CSTRING(TRC_SERVER,Tracer::LEVEL4,
1026 venkat.puvvada  1.208                     "IPv6 stack is not active, using IPv4 socket.");
1027                                   }
1028                           #endif
1029                                   if (!addIP6Acceptor)
1030                                   {
1031                                       addIP4Acceptor = true;
1032                                   }
1033                           
1034 kumpf           1.203             // The server HTTP and HTTPS ports are determined via this algorithm:
1035                                   // 1) If the user explicitly specified a port, use it.
1036                                   // 2) If the user did not specify a port, get the port from the
1037                                   //    services file.
1038                                   // 3) If no value is specified in the services file, use the IANA WBEM
1039                                   //    default port.
1040                                   // Note that 2 and 3 are done within the System::lookupPort method
1041                                   // An empty string from the ConfigManager implies that the user did not
1042                                   // specify a port.
1043 kumpf           1.41      
1044 kumpf           1.86              if (enableHttpConnection)
1045                                   {
1046 kumpf           1.203                 Uint32 portNumberHttp = 0;
1047                                       String httpPort = configManager->getCurrentValue("httpPort");
1048                                       if (httpPort == String::EMPTY)
1049                                       {
1050                                           //
1051                                           // Look up the WBEM-HTTP port number
1052                                           //
1053                                           portNumberHttp = System::lookupPort(
1054                                               WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1055 venkat.puvvada  1.231                     _initConfigProperty("httpPort", portNumberHttp);
1056 kumpf           1.203                 }
1057                                       else
1058                                       {
1059                                           //
1060                                           // user-specified
1061                                           //
1062                                           CString portString = httpPort.getCString();
1063                                           char* end = 0;
1064                                           portNumberHttp = strtol(portString, &end, 10);
1065                                           if (!(end != 0 && *end == '\0'))
1066                                           {
1067                                               throw InvalidPropertyValue("httpPort", httpPort);
1068                                           }
1069                                       }
1070                           
1071 venkat.puvvada  1.208                 if (addIP6Acceptor)
1072                                       {
1073                                           _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1074                                               portNumberHttp, false);
1075                                       }
1076                                       if (addIP4Acceptor)
1077                                       {
1078                                           _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1079                                               portNumberHttp, false);
1080                                       }
1081 denise.eckstein 1.225                 // The port number is converted to a string to avoid the
1082                                       //  addition of localized characters (e.g., "5,988").
1083 denise.eckstein 1.218                 char scratchBuffer[22];
1084                                       Uint32 n;
1085                                       const char * portNumberHttpStr = Uint32ToString(
1086 kumpf           1.228                     scratchBuffer, portNumberHttp, n);
1087 kumpf           1.203                 MessageLoaderParms parms(
1088 kumpf           1.198                     "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1089 denise.eckstein 1.218                     "Listening on HTTP port $0.", portNumberHttpStr);
1090 kumpf           1.222                 Logger::put_l(
1091 kumpf           1.203                     Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1092 kumpf           1.222                     parms);
1093 kumpf           1.203     #if defined(PEGASUS_DEBUG)
1094                                       cout << MessageLoader::getMessage(parms) << endl;
1095                           #endif
1096 kumpf           1.86              }
1097 kumpf           1.198     
1098 kumpf           1.86              if (enableHttpsConnection)
1099                                   {
1100 kumpf           1.203                 Uint32 portNumberHttps = 0;
1101                                       String httpsPort = configManager->getCurrentValue("httpsPort");
1102                                       if (httpsPort == String::EMPTY)
1103                                       {
1104                                           //
1105                                           // Look up the WBEM-HTTPS port number
1106                                           //
1107                                           portNumberHttps = System::lookupPort(
1108                                               WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1109 venkat.puvvada  1.231                     _initConfigProperty("httpsPort", portNumberHttps);
1110 kumpf           1.203                 }
1111                                       else
1112                                       {
1113                                           //
1114                                           // user-specified
1115                                           //
1116                                           CString portString = httpsPort.getCString();
1117                                           char* end = 0;
1118                                           portNumberHttps = strtol(portString, &end, 10);
1119                                           if (!(end != 0 && *end == '\0'))
1120                                           {
1121                                               throw InvalidPropertyValue("httpsPort", httpsPort);
1122                                           }
1123                                       }
1124 venkat.puvvada  1.208                 if (addIP6Acceptor)
1125 kumpf           1.228                 {
1126 venkat.puvvada  1.208                     _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1127                                               portNumberHttps, true);
1128                                       }
1129                                       if (addIP4Acceptor)
1130                                       {
1131                                           _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1132                                               portNumberHttps, true);
1133                                       }
1134 denise.eckstein 1.225                 // The port number is converted to a string to avoid the
1135                                       //  addition of localized characters (e.g., "5,989").
1136 denise.eckstein 1.218                 char scratchBuffer[22];
1137                                       Uint32 n;
1138                                       const char * portNumberHttpsStr = Uint32ToString(
1139 kumpf           1.228                     scratchBuffer, portNumberHttps, n);
1140 kumpf           1.203                 MessageLoaderParms parms(
1141 kumpf           1.198                     "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1142 denise.eckstein 1.218                     "Listening on HTTPS port $0.", portNumberHttpsStr);
1143 kumpf           1.222                 Logger::put_l(
1144 kumpf           1.203                     Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1145 kumpf           1.222                     parms);
1146 kumpf           1.203     #if defined(PEGASUS_DEBUG)
1147                                       cout << MessageLoader::getMessage(parms) << endl;
1148                           #endif
1149 kumpf           1.86              }
1150 kumpf           1.135     
1151 h.sterling      1.159     #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1152 kumpf           1.203             {
1153 dave.sudlik     1.205                 _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
1154 kumpf           1.86      
1155 kumpf           1.198                 MessageLoaderParms parms(
1156 kumpf           1.203                     "src.Server.cimserver.LISTENING_ON_LOCAL",
1157                                           "Listening on local connection socket.");
1158 kumpf           1.222                 Logger::put_l(
1159 kumpf           1.203                     Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1160 kumpf           1.222                     parms);
1161 kumpf           1.203     # if defined(PEGASUS_DEBUG)
1162 h.sterling      1.153                 cout << MessageLoader::getMessage(parms) << endl;
1163 kumpf           1.203     # endif
1164 kumpf           1.86              }
1165 david           1.85      #endif
1166 mike            1.35      
1167 kumpf           1.198             _cimServer->bind();
1168 kumpf           1.199     
1169 kumpf           1.198             // notify parent process (if there is a parent process) to terminate
1170 konrad.r        1.95              // so user knows that there is cimserver ready to serve CIM requests.
1171 kumpf           1.198             if (daemonOption)
1172                                   {
1173                                       _cimServerProcess->notify_parent(0);
1174                                   }
1175 mike            1.35      
1176 kumpf           1.139     #if defined(PEGASUS_DEBUG)
1177 kumpf           1.202             cout << "Started. " << endl;
1178 kumpf           1.63      #endif
1179 david.dillard   1.165     
1180 kumpf           1.54              // Put server started message to the logger
1181 kumpf           1.143             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1182                                       Logger::INFORMATION,
1183 kumpf           1.222                 MessageLoaderParms(
1184                                           "src.Server.cimserver.STARTED_VERSION",
1185                                           "Started $0 version $1.",
1186                                           _cimServerProcess->getProductName(),
1187                                           _cimServerProcess->getCompleteVersion()));
1188 kumpf           1.45      
1189 marek           1.190     #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
1190 kumpf           1.178             if (daemonOption && !debugOutputOption)
1191 kumpf           1.202             {
1192 kumpf           1.178                 // Direct standard input, output, and error to /dev/null,
1193                                       // since we are running as a daemon.
1194 thilo.boehm     1.211                 close(STDIN_FILENO);
1195 kumpf           1.178                 open("/dev/null", O_RDONLY);
1196 thilo.boehm     1.211                 close(STDOUT_FILENO);
1197 kumpf           1.178                 open("/dev/null", O_RDWR);
1198 thilo.boehm     1.211                 close(STDERR_FILENO);
1199 kumpf           1.178                 open("/dev/null", O_RDWR);
1200                                   }
1201                           #endif
1202 kumpf           1.203         }
1203                               catch (Exception& e)
1204                               {
1205                                   MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1206                                       "cimserver not started: $0", e.getMessage());
1207 kumpf           1.222             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1208                                       parms);
1209 kumpf           1.203             cerr << MessageLoader::getMessage(parms) << endl;
1210 kumpf           1.178     
1211 s.kodali        1.234             deleteCIMServer();
1212                           
1213 kumpf           1.203             //
1214                                   // notify parent process (if there is a parent process) to terminate
1215                                   //
1216                                   if (daemonOption)
1217                                       _cimServerProcess->notify_parent(1);
1218                           
1219                                   return 1;
1220                               }
1221                           
1222                               // Run the main CIM Server loop
1223                           
1224                               try
1225                               {
1226 r.kieninger     1.223     #if defined(PEGASUS_OS_ZOS)
1227 thilo.boehm     1.185     
1228 kumpf           1.202             // ARM is a z/OS internal restart facility.
1229                                   // This is a z/OS specific change.
1230 thilo.boehm     1.185     
1231                                   // Instatiating the automatic restart manager for zOS
1232                                   ARM_zOS automaticRestartManager;
1233                           
1234                                   // register to zOS ARM
1235                                   automaticRestartManager.Register();
1236                           
1237                           #endif
1238                           
1239 marek           1.217     #ifdef PEGASUS_ENABLE_SLP
1240                                   _cimServer->startSLPProvider();
1241 kumpf           1.228     #endif
1242 venkat.puvvada  1.232             _cimServer->initComplete();
1243                           
1244 mike            1.35              //
1245                                   // Loop to call CIMServer's runForever() method until CIMServer
1246                                   // has been shutdown
1247                                   //
1248 kumpf           1.202             while (!_cimServer->terminated())
1249                                   {
1250                                       _cimServer->runForever();
1251                                   }
1252 carson.hovey    1.157     
1253 kumpf           1.45              //
1254                                   // normal termination
1255 carson.hovey    1.157             //
1256 kumpf           1.203     
1257 r.kieninger     1.223     #if defined(PEGASUS_OS_ZOS)
1258 thilo.boehm     1.185     
1259 kumpf           1.202             // ARM is a z/OS internal restart facility.
1260                                   // This is a z/OS specific change.
1261 thilo.boehm     1.185     
1262                                   // register to zOS ARM
1263                                   automaticRestartManager.DeRegister();
1264                           
1265                           #endif
1266 kumpf           1.143     
1267 kumpf           1.54              // Put server shutdown message to the logger
1268 kumpf           1.222             Logger::put_l(
1269                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1270                                       MessageLoaderParms(
1271                                           "src.Server.cimserver.STOPPED",
1272                                           "$0 stopped.", _cimServerProcess->getProductName()));
1273 mike            1.32          }
1274 kumpf           1.202         catch (Exception& e)
1275 marek           1.195         {
1276 kumpf           1.202             MessageLoaderParms parms(
1277 marek           1.195                 "src.Server.cimserver.ERROR",
1278 kumpf           1.202                 "Error: $0",
1279                                       e.getMessage());
1280 kumpf           1.222             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1281                                       parms);
1282 kumpf           1.203             cerr << MessageLoader::getMessage(parms) << endl;
1283 marek           1.195     
1284                                   deleteCIMServer();
1285                                   return 1;
1286                               }
1287 mike            1.32      
1288 h.sterling      1.156         deleteCIMServer();
1289 mike            1.32          return 0;
1290                           }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2