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

   1 karl  1.179 //%2006////////////////////////////////////////////////////////////////////////
   2 mike  1.32  //
   3 karl  1.141 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl  1.121 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.141 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl  1.149 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 karl  1.179 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12             // EMC Corporation; Symantec Corporation; The Open Group.
  13 mike  1.32  //
  14             // Permission is hereby granted, free of charge, to any person obtaining a copy
  15 kumpf 1.58  // of this software and associated documentation files (the "Software"), to
  16             // deal in the Software without restriction, including without limitation the
  17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18 mike  1.32  // sell copies of the Software, and to permit persons to whom the Software is
  19             // furnished to do so, subject to the following conditions:
  20 karl  1.179 // 
  21 kumpf 1.58  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22 mike  1.32  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24 kumpf 1.58  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27 mike  1.32  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29             //
  30             //==============================================================================
  31             //
  32             //%/////////////////////////////////////////////////////////////////////////////
  33             
  34             
  35             //////////////////////////////////////////////////////////////////////
  36             //
  37 carolann.graves 1.171 // Notes on daemon operation (Unix) and service operation (Win 32):
  38 mike            1.32  //
  39 david.dillard   1.165 // To run pegasus as a daemon on Unix platforms:
  40 mike            1.32  //
  41 kumpf           1.60  // cimserver
  42 mike            1.32  //
  43 kumpf           1.60  // To NOT run pegasus as a daemon on Unix platforms, set the daemon config
  44                       // property to false:
  45                       //
  46                       // cimserver daemon=false
  47                       //
  48 kumpf           1.215 // The daemon config property has no effect on windows operation or when
  49                       // privilege separation is enabled.
  50 mike            1.32  //
  51 mike            1.35  // To shutdown pegasus, use the -s option:
  52 david.dillard   1.165 //
  53                       // cimserver -s
  54 mike            1.35  //
  55 mike            1.32  // To run pegasus as an NT service, there are FOUR  different possibilities:
  56                       //
  57 david.dillard   1.165 // To INSTALL the Pegasus service,
  58 mike            1.32  //
  59                       // cimserver -install
  60                       //
  61 david.dillard   1.165 // To REMOVE the Pegasus service,
  62 mike            1.32  //
  63                       // cimserver -remove
  64                       //
  65 david.dillard   1.165 // To START the Pegasus service,
  66 mike            1.32  //
  67                       // net start cimserver
  68 s.hills         1.117 // or
  69                       // cimserver -start
  70 mike            1.32  //
  71 david.dillard   1.165 // To STOP the Pegasus service,
  72 mike            1.32  //
  73                       // net stop cimserver
  74 s.hills         1.117 // or
  75                       // cimserver -stop
  76 mike            1.32  //
  77 david.dillard   1.165 // Alternatively, you can use the windows service manager. Pegasus shows up
  78 mike            1.32  // in the service database as "Pegasus CIM Object Manager"
  79                       //
  80                       //////////////////////////////////////////////////////////////////////
  81                       
  82                       
  83 mike            1.35  #include <Pegasus/Common/Config.h>
  84 kumpf           1.59  #include <Pegasus/Common/Constants.h>
  85 jim.wunderlich  1.172 #include <Pegasus/Common/PegasusAssert.h>
  86 mike            1.32  #include <Pegasus/Common/FileSystem.h>
  87                       #include <Pegasus/Common/PegasusVersion.h>
  88                       #include <Pegasus/Common/Logger.h>
  89 denise.eckstein 1.218 #include <Pegasus/Common/StringConversion.h>
  90 mike            1.32  #include <Pegasus/Common/System.h>
  91 mike            1.35  #include <Pegasus/Common/Tracer.h>
  92 kumpf           1.174 #include <Pegasus/Common/LanguageParser.h>
  93 mike            1.35  #include <Pegasus/Config/ConfigManager.h>
  94                       #include <Pegasus/Client/CIMClient.h>
  95 h.sterling      1.153 #include <Pegasus/Server/CIMServer.h>
  96                       #include <Service/ServerProcess.h>
  97 kumpf           1.198 #include <Service/ServerShutdownClient.h>
  98                       #include <Service/ServerRunStatus.h>
  99 mike            1.32  
 100 kumpf           1.202 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
 101 thilo.boehm     1.211 #include <Pegasus/Common/SetFileDescriptorToEBCDICEncoding.h>
 102 thilo.boehm     1.185 #include <Service/ARM_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                           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 mike            1.219.4.1        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                               defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
 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 kumpf           1.60              // Get help, version, 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 kumpf           1.216                 else if (strcmp(arg, "--version") == 0)
 520 a.arora         1.142                 {
 521 jim.wunderlich  1.180                     cout << _cimServerProcess->getCompleteVersion() << endl;
 522 kumpf           1.216                     Executor::daemonizeExecutor();
 523 a.arora         1.142                     exit(0);
 524                                       }
 525 mike            1.35                  // Check for -option
 526 a.arora         1.142                 else if (*arg == '-')
 527 mike            1.35                  {
 528                                           // Get the option
 529                                           const char* option = arg + 1;
 530                           
 531                                           //
 532                                           // Check to see if user asked for the version (-v option):
 533                                           //
 534 tony            1.83                      if (*option == OPTION_VERSION &&
 535                                               strlen(option) == 1)
 536 mike            1.35                      {
 537 jim.wunderlich  1.180                         cout << _cimServerProcess->getCompleteVersion() << endl;
 538 kumpf           1.216                         Executor::daemonizeExecutor();
 539 mike            1.35                          exit(0);
 540                                           }
 541                                           //
 542                                           // Check to see if user asked for help (-h option):
 543                                           //
 544 tony            1.83                      else if (*option == OPTION_HELP &&
 545                                                   (strlen(option) == 1))
 546 mike            1.35                      {
 547                                               PrintHelp(argv[0]);
 548 kumpf           1.216                         Executor::daemonizeExecutor();
 549 mike            1.35                          exit(0);
 550                                           }
 551 kumpf           1.138     #if !defined(PEGASUS_USE_RELEASE_DIRS)
 552 tony            1.83                      else if (*option == OPTION_HOME &&
 553                                                   (strlen(option) == 1))
 554 mike            1.35                      {
 555 kumpf           1.60                          if (i + 1 < argc)
 556 mike            1.35                          {
 557                                                   pegasusHome.assign(argv[i + 1]);
 558                                               }
 559                                               else
 560                                               {
 561 humberto        1.99                              String opt(option);
 562 kumpf           1.202                             MessageLoaderParms parms(
 563                                                       "src.Server.cimserver.MISSING_ARGUMENT",
 564                                                       "Missing argument for option -$0",
 565                                                       opt);
 566 h.sterling      1.153                             cout << MessageLoader::getMessage(parms) << endl;
 567 kumpf           1.216                             exit(1);
 568 mike            1.35                          }
 569                           
 570                                               memmove(&argv[i], &argv[i + 2], (argc-i-1) * sizeof(char*));
 571                                               argc -= 2;
 572                                           }
 573 kumpf           1.63      #endif
 574 kumpf           1.48                      //
 575 kumpf           1.178                     // Check to see if user asked for debug output (-X option):
 576 kumpf           1.48                      //
 577 kumpf           1.178                     else if (*option == OPTION_DEBUGOUTPUT &&
 578 tony            1.83                              (strlen(option) == 1))
 579 kumpf           1.48                      {
 580 kumpf           1.178                         MessageLoaderParms parms(
 581                                                   "src.Server.cimserver.UNSUPPORTED_DEBUG_OPTION",
 582                                                   "Unsupported debug output option is enabled.");
 583 h.sterling      1.153                         cout << MessageLoader::getMessage(parms) << endl;
 584 kumpf           1.178     
 585                                               debugOutputOption = true;
 586                           
 587                           #if defined(PEGASUS_OS_HPUX)
 588                                               System::bindVerbose = true;
 589                           #endif
 590                           
 591 kumpf           1.48                          // remove the option from the command line
 592                                               memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 593 david.dillard   1.165                         argc--;
 594 kumpf           1.48                      }
 595 mike            1.35                      //
 596                                           // Check to see if user asked for shutdown (-s option):
 597                                           //
 598 tony            1.82                      else if (*option == OPTION_SHUTDOWN &&
 599                                                   (strlen(option) == 1))
 600 mike            1.35                      {
 601                                               //
 602 kumpf           1.52                          // Check to see if shutdown has already been specified:
 603 mike            1.35                          //
 604 kumpf           1.52                          if (shutdownOption)
 605 mike            1.35                          {
 606 kumpf           1.202                             MessageLoaderParms parms(
 607                                                       "src.Server.cimserver.DUPLICATE_SHUTDOWN_OPTION",
 608                                                       "Duplicate shutdown option specified.");
 609 david.dillard   1.165     
 610 humberto        1.97                              cout << MessageLoader::getMessage(parms) << endl;
 611 kumpf           1.216                             exit(1);
 612 mike            1.35                          }
 613                           
 614 kumpf           1.52                          shutdownOption = true;
 615 david.dillard   1.165     
 616 mike            1.35                          // remove the option from the command line
 617                                               memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));
 618 david.dillard   1.165                         argc--;
 619 mike            1.35                      }
 620                                           else
 621                                               i++;
 622                                       }
 623                                       else
 624                                           i++;
 625 mike            1.32              }
 626 mike            1.35      
 627 kumpf           1.38          //
 628                               // Set the value for pegasusHome property
 629                               //
 630                               ConfigManager::setPegasusHome(pegasusHome);
 631 mike            1.32      
 632 mike            1.35          //
 633 carolann.graves 1.171         // Do the platform specific run
 634 s.hills         1.117         //
 635                           
 636 kumpf           1.178         return _cimServerProcess->platform_run(
 637                                   argc, argv, shutdownOption, debugOutputOption);
 638 s.hills         1.117     }
 639                           
 640 h.sterling      1.153     void CIMServerProcess::cimserver_stop()
 641                           {
 642                               _cimServer->shutdownSignal();
 643                           }
 644 s.hills         1.117     
 645                           //
 646                           // The main, common, running code
 647                           //
 648 david.dillard   1.165     // NOTE: Do NOT call exit().  Use return(), otherwise some platforms
 649 s.hills         1.117     // will fail to shutdown properly/cleanly.
 650                           //
 651 david.dillard   1.165     // TODO: Current change minimal for platform "service" shutdown bug fixes.
 652 carolann.graves 1.171     // Perhaps further extract out common stuff and put into main(), put
 653 david.dillard   1.165     // daemon stuff into platform specific platform_run(), etc.
 654                           // Note: make sure to not put error handling stuff that platform
 655 carolann.graves 1.171     // specific runs may need to deal with better (instead of exit(), etc).
 656 s.hills         1.117     //
 657                           
 658 kumpf           1.178     int CIMServerProcess::cimserver_run(
 659                               int argc,
 660                               char** argv,
 661                               Boolean shutdownOption,
 662                               Boolean debugOutputOption)
 663 s.hills         1.117     {
 664                               Boolean daemonOption = false;
 665                           
 666 ouyang.jian     1.206     #if defined (PEGASUS_OS_PASE) && !defined (PEGASUS_DEBUG)
 667                               // PASE have itself regular for checking privileged user
 668                               if (!System::isPrivilegedUser("*CURRENT  "))
 669                               {
 670                                   MessageLoaderParms parms(
 671                                           "src.Server.cimserver.NO_AUTHORITY.PEGASUS_OS_PASE",
 672                                           "The caller should be a privileged user,"
 673                                           " or the server will not run.");
 674                                   cerr << MessageLoader::getMessage(parms) << endl;
 675                                   exit (1);
 676                               }
 677                               char jobName[11];
 678                               // this function only can be found in PASE environment
 679                               umeGetJobName(jobName, false);
 680                               if (strncmp("QUMECIMOM ", jobName, 10) != 0
 681                                       && strncmp("QUMEENDCIM", jobName, 10) != 0)
 682                               {
 683                                   MessageLoaderParms parms(
 684                                           "src.Server.cimserver.NOT_OFFICIAL_START.PEGASUS_OS_PASE",
 685                                           "cimserver can not be started by user.\nServer will not run.");
 686                                   cerr << MessageLoader::getMessage(parms) << endl;
 687 ouyang.jian     1.206             exit (1);
 688                               }
 689                           
 690                               // Direct standard input, output, and error to /dev/null, 
 691                               // PASE run this job in background, any output in not allowed
 692                               freopen("/dev/null", "r", stdin);
 693                               freopen("/dev/null", "w", stdout);
 694                               freopen("/dev/null", "w", stderr);
 695                           #endif
 696                           
 697 s.hills         1.117         //
 698 mike            1.35          // Get an instance of the Config Manager.
 699                               //
 700 kumpf           1.203         ConfigManager* configManager = ConfigManager::getInstance();
 701 kumpf           1.136         configManager->useConfigFiles = true;
 702 mike            1.35      
 703 mike            1.32          try
 704                               {
 705 kumpf           1.203             //
 706                                   // Get options (from command line and from configuration file); this
 707                                   // removes corresponding options and their arguments from the command
 708                                   // line.  NOTE: If shutdownOption=true, the contents of current config
 709                                   // file are not overwritten by the planned config file.
 710                                   //
 711 mateus.baur     1.193             GetOptions(configManager, argc, argv, shutdownOption);
 712 kumpf           1.127     
 713 kumpf           1.203             //
 714                                   // Initialize the message home directory in the MessageLoader.
 715                                   // This is the default directory where the resource bundles are found.
 716                                   //
 717                                   MessageLoader::setPegasusMsgHome(ConfigManager::getHomedPath(
 718                                       ConfigManager::getInstance()->getCurrentValue("messageDir")));
 719 kumpf           1.86      
 720 ouyang.jian     1.206     #ifdef PEGASUS_OS_PASE
 721                               // set ccsid to unicode for entire job
 722                               // ccsid is globolization mechanism in PASE environment
 723                               if (_SETCCSID(1208) == -1)
 724                               {
 725                                   MessageLoaderParms parms(
 726                                           "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
 727                                           "Failed to set CCSID, server will stop.");
 728                                   cerr << MessageLoader::getMessage(parms) << endl;
 729                                   Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
 730                                           "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
 731                                           "Failed to set CCSID, server will stop.\n");
 732                                   exit (1);
 733                               }
 734                           
 735                               char fullJobName[29];
 736                               umeGetJobName(fullJobName, true);
 737                               Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 738                                       "src.Server.cimserver.SERVER_JOB_NAME.PEGASUS_OS_PASE",
 739                                       "CIM Server's Job Name is: $0", fullJobName);
 740                           #endif
 741 ouyang.jian     1.206     
 742                           #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 743 mike            1.219.4.1         // Make sure at least one connection is enabled
 744                           
 745                                   Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 746                                       configManager->getCurrentValue("enableHttpConnection"));
 747                                   Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 748                                       configManager->getCurrentValue("enableHttpsConnection"));
 749                           
 750                                   if (!enableHttpConnection && !enableHttpsConnection)
 751                                   {
 752                                       Logger::put_l(
 753                                           Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 754 ouyang.jian     1.206                     "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 755                                           "Neither HTTP nor HTTPS connection is enabled."
 756 mike            1.219.4.1                     "  CIMServer will not be started.");
 757                                       MessageLoaderParms parms(
 758                                           "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 759                                           "Neither HTTP nor HTTPS connection is enabled."
 760                                               "  CIMServer will not be started.");
 761                                       cerr << MessageLoader::getMessage(parms) << endl;
 762                                       return 1;
 763                                   }
 764 ouyang.jian     1.206     #endif
 765 mike            1.219.4.1 
 766 mike            1.35              //
 767 kumpf           1.187             // Check to see if we should start Pegasus as a daemon
 768 mike            1.35              //
 769 kumpf           1.187             daemonOption = ConfigManager::parseBooleanValue(
 770                                       configManager->getCurrentValue("daemon"));
 771 david.dillard   1.165     
 772 kumpf           1.215             if ((Executor::detectExecutor() == 0) && (daemonOption == false))
 773                                   {
 774                                       MessageLoaderParms parms(
 775                                           "src.Server.cimserver.PRIVSEP_REQUIRES_DAEMON",
 776                                           "Warning: The configuration setting daemon=false is ignored "
 777                                               "with privilege separation enabled.");
 778                                       cerr << MessageLoader::getMessage(parms) << endl;
 779                                       daemonOption = true;
 780                                   }
 781                           
 782 konrad.r        1.161     #if !defined(PEGASUS_USE_SYSLOGS)
 783 kumpf           1.203             String logsDirectory = ConfigManager::getHomedPath(
 784                                       configManager->getCurrentValue("logdir"));
 785 kumpf           1.36      
 786 kumpf           1.203             // Set up the Logger.  This does not open the logs.
 787 kumpf           1.36              // Might be more logical to clean before set.
 788                                   Logger::setHomeDirectory(logsDirectory);
 789 ouyang.jian     1.206             
 790                           # ifdef PEGASUS_OS_PASE
 791                               /* write job log to tell where pegasus log is.*/
 792                               if(logsDirectory.size() > 0)
 793                                   // this function only can be found in PASE environment
 794                                   logPegasusDir2joblog(logsDirectory.getCString());
 795                               else
 796                                   logPegasusDir2joblog(".");
 797                           # endif
 798 kumpf           1.57      #endif
 799 kumpf           1.36      
 800                                   //
 801 david.dillard   1.165             // Check to see if we need to shutdown CIMOM
 802 mike            1.35              //
 803                                   if (shutdownOption)
 804                                   {
 805 david.dillard   1.165                 String configTimeout =
 806 kumpf           1.60                      configManager->getCurrentValue("shutdownTimeout");
 807 kumpf           1.202                 Uint32 timeoutValue =
 808                                           strtol(configTimeout.getCString(), (char **)0, 10);
 809 david.dillard   1.165     
 810 kumpf           1.198                 ServerShutdownClient serverShutdownClient(&_serverRunStatus);
 811                                       serverShutdownClient.shutdown(timeoutValue);
 812 kumpf           1.45      
 813 kumpf           1.198                 MessageLoaderParms parms(
 814                                           "src.Server.cimserver.SERVER_STOPPED",
 815                                           "CIM Server stopped.");
 816 humberto        1.106     
 817 humberto        1.97                  cout << MessageLoader::getMessage(parms) << endl;
 818 kumpf           1.202                 return 0;
 819 mike            1.35              }
 820 mike            1.32      
 821 kumpf           1.198     #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
 822 kumpf           1.36              // Leave this in until people get familiar with the logs.
 823 humberto        1.97              MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
 824 h.sterling      1.153                                      "Logs Directory = ");
 825 humberto        1.97              cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
 826 kumpf           1.57      #endif
 827 mike            1.32          }
 828 kumpf           1.203         catch (Exception& e)
 829 mike            1.32          {
 830 kumpf           1.203             MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 831                                       "cimserver not started: $0", e.getMessage());
 832                                   Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 833                                       MessageLoader::getMessage(parms));
 834                                   cerr << MessageLoader::getMessage(parms) << endl;
 835                           
 836                                   return 1;
 837 marek           1.186         }
 838 david           1.85      
 839 marek           1.186     #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_ZOS_SECURITY)
 840                               startupCheckBPXServer(true);
 841                               startupCheckProfileCIMSERVclassWBEM();
 842                               startupEnableMSC();
 843 david           1.85      #endif
 844 mike            1.32      
 845 kumpf           1.139     #if defined(PEGASUS_DEBUG)
 846 mike            1.32          // Put out startup up message.
 847 kumpf           1.202         cout << _cimServerProcess->getProductName() << " " <<
 848                                   _cimServerProcess->getCompleteVersion() << endl;
 849 humberto        1.97      #endif
 850                           
 851 kumpf           1.202         // reset message loading to NON-process locale
 852                               MessageLoader::_useProcessLocale = false;
 853 mike            1.32      
 854 kumpf           1.137         // Get the parent's PID before forking
 855 kumpf           1.198         _serverRunStatus.setParentPid(System::getPID());
 856 david.dillard   1.165     
 857 kumpf           1.202         // Do not fork when using privilege separation (executor will daemonize
 858                               // itself later).
 859 kumpf           1.63          if (daemonOption)
 860                               {
 861 kumpf           1.202             if (-1 == _cimServerProcess->cimserver_fork())
 862                                       return -1;
 863 kumpf           1.63          }
 864 chuck           1.66      
 865 chuck           1.96          // Now we are after the fork...
 866                               // Create a dummy Thread object that can be used to store the
 867 kumpf           1.176         // AcceptLanguageList object for CIM requests that are serviced
 868 chuck           1.96          // by this thread (initial thread of server).  Need to do this
 869                               // because this thread is not in a ThreadPool, but is used
 870                               // to service CIM requests.
 871                               // The run function for the dummy Thread should never be called,
 872 konrad.r        1.166         dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
 873 david.dillard   1.165         Thread::setCurrent(dummyInitialThread);
 874 kumpf           1.202         try
 875                               {
 876 kumpf           1.214             Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages());
 877 kumpf           1.202         }
 878                               catch (InvalidAcceptLanguageHeader& e)
 879                               {
 880 kumpf           1.203             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 881                                       "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
 882                                       "Could not convert the system process locale into a valid "
 883                                           "AcceptLanguage format.");
 884                                   Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 885                                       e.getMessage());
 886 humberto        1.108         }
 887 david.dillard   1.165     
 888 kumpf           1.167     #ifndef PEGASUS_OS_TYPE_WINDOWS
 889                               umask(S_IRWXG|S_IRWXO);
 890                           #endif
 891 mday            1.62      
 892 kumpf           1.203         // Start up the CIM Server
 893 mateus.baur     1.175     
 894 kumpf           1.203         try
 895                               {
 896 mateus.baur     1.175     #if defined(PEGASUS_OS_TYPE_UNIX)
 897 kumpf           1.203             //
 898                                   // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
 899                                   // concurrent writes to this file by multiple cimserver processes
 900                                   // starting at the same time.
 901                                   //
 902                                   CString startupLockFileName = ConfigManager::getHomedPath(
 903 kumpf           1.204                 PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
 904 kumpf           1.203     
 905                                   // Make sure the start-up lock file exists
 906                                   FILE* startupLockFile;
 907                                   if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
 908                                   {
 909                                       fclose(startupLockFile);
 910                                   }
 911 kumpf           1.202     
 912 kumpf           1.203             AutoFileLock fileLock(startupLockFileName);
 913                           #endif
 914 kumpf           1.202     
 915 kumpf           1.203     #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
 916                                   //
 917                                   // Check if a CIM Server is already running.  If so, print an error
 918                                   // message and notify the parent process (if there is one) to terminate
 919                                   //
 920                                   if (_serverRunStatus.isServerRunning())
 921                                   {
 922                                       MessageLoaderParms parms(
 923                                           "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
 924                                           "Unable to start CIMServer. CIMServer is already running.");
 925                                       Logger::put(
 926                                           Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 927                                           MessageLoader::getMessage(parms));
 928                                       cerr << MessageLoader::getMessage(parms) << endl;
 929 mateus.baur     1.175     
 930 kumpf           1.203                 if (daemonOption)
 931                                       {
 932                                           _cimServerProcess->notify_parent(1);
 933                                       }
 934 kumpf           1.79      
 935 kumpf           1.203                 return 1;
 936                                   }
 937 kumpf           1.79      
 938 kumpf           1.198             //
 939 kumpf           1.203             // Declare ourselves as the running CIM Server process, and write our
 940                                   // PID to the PID file.
 941 kumpf           1.79              //
 942 kumpf           1.203             _serverRunStatus.setServerRunning();
 943                           #endif
 944                           
 945                                   // Create and initialize the CIMServer object
 946                           
 947                                   _cimServer = new CIMServer();
 948                           
 949                                   Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 950                                       configManager->getCurrentValue("enableHttpConnection"));
 951                                   Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 952                                       configManager->getCurrentValue("enableHttpsConnection"));
 953                           
 954                           #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 955                                   // Make sure at least one connection is enabled
 956                                   if (!enableHttpConnection && !enableHttpsConnection)
 957 kumpf           1.198             {
 958 kumpf           1.203                 MessageLoaderParms parms(
 959                                           "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 960                                           "Neither HTTP nor HTTPS connection is enabled.");
 961                                       throw Exception(parms);
 962 kumpf           1.198             }
 963 kumpf           1.63      #endif
 964 kumpf           1.51      
 965 venkat.puvvada  1.208             Boolean addIP6Acceptor = false;
 966                                   Boolean addIP4Acceptor = false;
 967                           
 968                           #ifdef PEGASUS_OS_TYPE_WINDOWS
 969                                   addIP4Acceptor = true;
 970                           #endif
 971                           
 972                           #ifdef PEGASUS_ENABLE_IPV6
 973                                   // If IPv6 stack is disabled swicth to IPv4 stack.
 974                                   if (System::isIPv6StackActive())
 975                                   {
 976                                       addIP6Acceptor = true;
 977                                   }
 978                                   else
 979                                   {
 980                                       MessageLoaderParms parms(
 981                                           "src.Server.cimserver.IPV6_STACK_NOT_ACTIVE",
 982                                           "IPv6 stack is not active, using IPv4 socket.");
 983                                       Logger::put(
 984                                           Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 985                                           MessageLoader::getMessage(parms));
 986 venkat.puvvada  1.208     #if defined(PEGASUS_DEBUG)
 987                                       cout << MessageLoader::getMessage(parms) << endl;
 988                           #endif
 989                                   }
 990                           #endif
 991                                   if (!addIP6Acceptor)
 992                                   {
 993                                       addIP4Acceptor = true;
 994                                   }
 995                           
 996 kumpf           1.203             // The server HTTP and HTTPS ports are determined via this algorithm:
 997                                   // 1) If the user explicitly specified a port, use it.
 998                                   // 2) If the user did not specify a port, get the port from the
 999                                   //    services file.
1000                                   // 3) If no value is specified in the services file, use the IANA WBEM
1001                                   //    default port.
1002                                   // Note that 2 and 3 are done within the System::lookupPort method
1003                                   // An empty string from the ConfigManager implies that the user did not
1004                                   // specify a port.
1005 kumpf           1.41      
1006 kumpf           1.86              if (enableHttpConnection)
1007                                   {
1008 kumpf           1.203                 Uint32 portNumberHttp = 0;
1009                                       String httpPort = configManager->getCurrentValue("httpPort");
1010                                       if (httpPort == String::EMPTY)
1011                                       {
1012                                           //
1013                                           // Look up the WBEM-HTTP port number
1014                                           //
1015                                           portNumberHttp = System::lookupPort(
1016                                               WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1017                                       }
1018                                       else
1019                                       {
1020                                           //
1021                                           // user-specified
1022                                           //
1023                                           CString portString = httpPort.getCString();
1024                                           char* end = 0;
1025                                           portNumberHttp = strtol(portString, &end, 10);
1026                                           if (!(end != 0 && *end == '\0'))
1027                                           {
1028                                               throw InvalidPropertyValue("httpPort", httpPort);
1029 kumpf           1.203                     }
1030                                       }
1031                           
1032 venkat.puvvada  1.208                 if (addIP6Acceptor)
1033                                       {
1034                                           _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1035                                               portNumberHttp, false);
1036                                       }
1037                                       if (addIP4Acceptor)
1038                                       {
1039                                           _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1040                                               portNumberHttp, false);
1041                                       }
1042 kumpf           1.198     
1043 denise.eckstein 1.218                 char scratchBuffer[22];
1044                                       Uint32 n;
1045                                       const char * portNumberHttpStr = Uint32ToString(
1046                                           scratchBuffer, portNumberHttp, n); 
1047 kumpf           1.203                 MessageLoaderParms parms(
1048 kumpf           1.198                     "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1049 denise.eckstein 1.218                     "Listening on HTTP port $0.", portNumberHttpStr);
1050 kumpf           1.203                 Logger::put(
1051                                           Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1052                                           MessageLoader::getMessage(parms));
1053                           #if defined(PEGASUS_DEBUG)
1054                                       cout << MessageLoader::getMessage(parms) << endl;
1055                           #endif
1056 kumpf           1.86              }
1057 kumpf           1.198     
1058 kumpf           1.86              if (enableHttpsConnection)
1059                                   {
1060 kumpf           1.203                 Uint32 portNumberHttps = 0;
1061                                       String httpsPort = configManager->getCurrentValue("httpsPort");
1062                                       if (httpsPort == String::EMPTY)
1063                                       {
1064                                           //
1065                                           // Look up the WBEM-HTTPS port number
1066                                           //
1067                                           portNumberHttps = System::lookupPort(
1068                                               WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1069                                       }
1070                                       else
1071                                       {
1072                                           //
1073                                           // user-specified
1074                                           //
1075                                           CString portString = httpsPort.getCString();
1076                                           char* end = 0;
1077                                           portNumberHttps = strtol(portString, &end, 10);
1078                                           if (!(end != 0 && *end == '\0'))
1079                                           {
1080                                               throw InvalidPropertyValue("httpsPort", httpsPort);
1081 kumpf           1.203                     }
1082                                       }
1083 venkat.puvvada  1.208                 if (addIP6Acceptor)
1084                                       { 
1085                                           _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1086                                               portNumberHttps, true);
1087                                       }
1088                                       if (addIP4Acceptor)
1089                                       {
1090                                           _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1091                                               portNumberHttps, true);
1092                                       }
1093 denise.eckstein 1.218                 char scratchBuffer[22];
1094                                       Uint32 n;
1095                                       const char * portNumberHttpsStr = Uint32ToString(
1096                                           scratchBuffer, portNumberHttps, n); 
1097 kumpf           1.203                 MessageLoaderParms parms(
1098 kumpf           1.198                     "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1099 denise.eckstein 1.218                     "Listening on HTTPS port $0.", portNumberHttpsStr);
1100 kumpf           1.203                 Logger::put(
1101                                           Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1102                                           MessageLoader::getMessage(parms));
1103                           #if defined(PEGASUS_DEBUG)
1104                                       cout << MessageLoader::getMessage(parms) << endl;
1105                           #endif
1106 kumpf           1.86              }
1107 kumpf           1.135     
1108 h.sterling      1.159     #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1109 kumpf           1.203             {
1110 dave.sudlik     1.205                 _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
1111 kumpf           1.86      
1112 kumpf           1.198                 MessageLoaderParms parms(
1113 kumpf           1.203                     "src.Server.cimserver.LISTENING_ON_LOCAL",
1114                                           "Listening on local connection socket.");
1115                                       Logger::put(
1116                                           Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1117                                           MessageLoader::getMessage(parms));
1118                           # if defined(PEGASUS_DEBUG)
1119 h.sterling      1.153                 cout << MessageLoader::getMessage(parms) << endl;
1120 kumpf           1.203     # endif
1121 kumpf           1.86              }
1122 david           1.85      #endif
1123 mike            1.35      
1124 kumpf           1.198             _cimServer->bind();
1125 kumpf           1.199     
1126 kumpf           1.198             // notify parent process (if there is a parent process) to terminate
1127 konrad.r        1.95              // so user knows that there is cimserver ready to serve CIM requests.
1128 kumpf           1.198             if (daemonOption)
1129                                   {
1130                                       _cimServerProcess->notify_parent(0);
1131                                   }
1132 mike            1.35      
1133 kumpf           1.139     #if defined(PEGASUS_DEBUG)
1134 kumpf           1.202             cout << "Started. " << endl;
1135 kumpf           1.63      #endif
1136 david.dillard   1.165     
1137 kumpf           1.54              // Put server started message to the logger
1138 kumpf           1.143             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1139                                       Logger::INFORMATION,
1140                                       "src.Server.cimserver.STARTED_VERSION",
1141                                       "Started $0 version $1.",
1142 kumpf           1.199                 _cimServerProcess->getProductName(),
1143                                       _cimServerProcess->getCompleteVersion());
1144 kumpf           1.45      
1145 marek           1.190     #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
1146 kumpf           1.178             if (daemonOption && !debugOutputOption)
1147 kumpf           1.202             {
1148 kumpf           1.178                 // Direct standard input, output, and error to /dev/null,
1149                                       // since we are running as a daemon.
1150 thilo.boehm     1.211                 close(STDIN_FILENO);
1151 kumpf           1.178                 open("/dev/null", O_RDONLY);
1152 thilo.boehm     1.211                 close(STDOUT_FILENO);
1153 kumpf           1.178                 open("/dev/null", O_RDWR);
1154 thilo.boehm     1.211                 close(STDERR_FILENO);
1155 kumpf           1.178                 open("/dev/null", O_RDWR);
1156                                   }
1157                           #endif
1158 kumpf           1.203         }
1159                               catch (Exception& e)
1160                               {
1161                                   MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1162                                       "cimserver not started: $0", e.getMessage());
1163                                   Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1164                                       MessageLoader::getMessage(parms));
1165                                   cerr << MessageLoader::getMessage(parms) << endl;
1166 kumpf           1.178     
1167 kumpf           1.203             //
1168                                   // notify parent process (if there is a parent process) to terminate
1169                                   //
1170                                   if (daemonOption)
1171                                       _cimServerProcess->notify_parent(1);
1172                           
1173                                   deleteCIMServer();
1174                                   return 1;
1175                               }
1176                           
1177                               // Run the main CIM Server loop
1178                           
1179                               try
1180                               {
1181 thilo.boehm     1.185     #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1182                           
1183 kumpf           1.202             // ARM is a z/OS internal restart facility.
1184                                   // This is a z/OS specific change.
1185 thilo.boehm     1.185     
1186                                   // Instatiating the automatic restart manager for zOS
1187                                   ARM_zOS automaticRestartManager;
1188                           
1189                                   // register to zOS ARM
1190                                   automaticRestartManager.Register();
1191                           
1192                           #endif
1193                           
1194 marek           1.217     #ifdef PEGASUS_ENABLE_SLP
1195                                   _cimServer->startSLPProvider();
1196                           #endif        
1197 mike            1.35              //
1198                                   // Loop to call CIMServer's runForever() method until CIMServer
1199                                   // has been shutdown
1200                                   //
1201 kumpf           1.202             while (!_cimServer->terminated())
1202                                   {
1203                                       _cimServer->runForever();
1204                                   }
1205 carson.hovey    1.157     
1206 kumpf           1.45              //
1207                                   // normal termination
1208 carson.hovey    1.157             //
1209 kumpf           1.203     
1210 thilo.boehm     1.185     #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
1211                           
1212 kumpf           1.202             // ARM is a z/OS internal restart facility.
1213                                   // This is a z/OS specific change.
1214 thilo.boehm     1.185     
1215                                   // register to zOS ARM
1216                                   automaticRestartManager.DeRegister();
1217                           
1218                           #endif
1219 kumpf           1.143     
1220 kumpf           1.54              // Put server shutdown message to the logger
1221 kumpf           1.143             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1222                                       Logger::INFORMATION, "src.Server.cimserver.STOPPED",
1223 h.sterling      1.153                 "$0 stopped.", _cimServerProcess->getProductName());
1224 mike            1.32          }
1225 kumpf           1.202         catch (Exception& e)
1226 marek           1.195         {
1227 kumpf           1.202             MessageLoaderParms parms(
1228 marek           1.195                 "src.Server.cimserver.ERROR",
1229 kumpf           1.202                 "Error: $0",
1230                                       e.getMessage());
1231 kumpf           1.203             Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1232                                       MessageLoader::getMessage(parms));
1233                                   cerr << MessageLoader::getMessage(parms) << endl;
1234 marek           1.195     
1235                                   deleteCIMServer();
1236                                   return 1;
1237                               }
1238 mike            1.32      
1239 h.sterling      1.156         deleteCIMServer();
1240 mike            1.32          return 0;
1241                           }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2