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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2