(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 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS)
 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 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 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.224 #if !defined(PEGASUS_USE_SYSLOGS)
 721                               String logsDirectory = ConfigManager::getHomedPath(
 722                                   configManager->getCurrentValue("logdir"));
 723                       
 724                               // Set up the Logger.  This does not open the logs.
 725                               // Might be more logical to clean before set.
 726                               Logger::setHomeDirectory(logsDirectory);
 727                       #endif
 728                       
 729                       
 730 ouyang.jian     1.206 #ifdef PEGASUS_OS_PASE
 731 ouyang.jian     1.224         /* write job log to tell where pegasus log is.*/
 732                               if(logsDirectory.size() > 0)
 733                                   // this function only can be found in PASE environment
 734                                   logPegasusDir2joblog(logsDirectory.getCString());
 735                               else
 736                                   logPegasusDir2joblog(".");
 737                       
 738                               // set ccsid to unicode for entire job
 739                               // ccsid is globolization mechanism in PASE environment
 740                               if (_SETCCSID(1208) == -1)
 741                               {
 742                                   MessageLoaderParms parms(
 743                                           "src.Server.cimserver.SET_CCSID_ERROR.PEGASUS_OS_PASE",
 744                                           "Failed to set CCSID, server will stop.");
 745                                   cerr << MessageLoader::getMessage(parms) << endl;
 746                                   Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::FATAL,
 747                                           parms);
 748                                   exit (1);
 749                               }
 750 ouyang.jian     1.206 
 751 ouyang.jian     1.224         char fullJobName[29];
 752                               umeGetJobName(fullJobName, true);
 753                               Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
 754                                       Logger::INFORMATION,
 755                                       MessageLoaderParms(
 756                                           "src.Server.cimserver.SERVER_JOB_NAME.PEGASUS_OS_PASE",
 757                                           "CIM Server's Job Name is: $0", fullJobName));
 758 ouyang.jian     1.206 #endif
 759                       
 760 kumpf           1.221 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 761                               // Make sure at least one connection is enabled
 762 ouyang.jian     1.206 
 763 kumpf           1.221         Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 764                                   configManager->getCurrentValue("enableHttpConnection"));
 765                               Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 766                                   configManager->getCurrentValue("enableHttpsConnection"));
 767                       
 768                               if (!enableHttpConnection && !enableHttpsConnection)
 769                               {
 770                                   MessageLoaderParms parms(
 771 ouyang.jian     1.206                 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 772                                       "Neither HTTP nor HTTPS connection is enabled."
 773 kumpf           1.221                     "  CIMServer will not be started.");
 774 kumpf           1.222             Logger::put_l(
 775                                       Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
 776                                       parms);
 777 kumpf           1.221             cerr << MessageLoader::getMessage(parms) << endl;
 778                                   return 1;
 779                               }
 780 ouyang.jian     1.206 #endif
 781 kumpf           1.221 
 782 mike            1.35          //
 783 kumpf           1.187         // Check to see if we should start Pegasus as a daemon
 784 mike            1.35          //
 785 kumpf           1.187         daemonOption = ConfigManager::parseBooleanValue(
 786                                   configManager->getCurrentValue("daemon"));
 787 david.dillard   1.165 
 788 kumpf           1.215         if ((Executor::detectExecutor() == 0) && (daemonOption == false))
 789                               {
 790                                   MessageLoaderParms parms(
 791                                       "src.Server.cimserver.PRIVSEP_REQUIRES_DAEMON",
 792                                       "Warning: The configuration setting daemon=false is ignored "
 793                                           "with privilege separation enabled.");
 794                                   cerr << MessageLoader::getMessage(parms) << endl;
 795                                   daemonOption = true;
 796                               }
 797                       
 798 kumpf           1.36          //
 799 david.dillard   1.165         // Check to see if we need to shutdown CIMOM
 800 mike            1.35          //
 801                               if (shutdownOption)
 802                               {
 803 david.dillard   1.165             String configTimeout =
 804 kumpf           1.60                  configManager->getCurrentValue("shutdownTimeout");
 805 kumpf           1.202             Uint32 timeoutValue =
 806                                       strtol(configTimeout.getCString(), (char **)0, 10);
 807 david.dillard   1.165 
 808 kumpf           1.198             ServerShutdownClient serverShutdownClient(&_serverRunStatus);
 809                                   serverShutdownClient.shutdown(timeoutValue);
 810 kumpf           1.45  
 811 kumpf           1.198             MessageLoaderParms parms(
 812                                       "src.Server.cimserver.SERVER_STOPPED",
 813                                       "CIM Server stopped.");
 814 humberto        1.106 
 815 humberto        1.97              cout << MessageLoader::getMessage(parms) << endl;
 816 kumpf           1.202             return 0;
 817 mike            1.35          }
 818 mike            1.32  
 819 kumpf           1.198 #if defined(PEGASUS_DEBUG) && !defined(PEGASUS_USE_SYSLOGS)
 820 kumpf           1.36          // Leave this in until people get familiar with the logs.
 821 humberto        1.97          MessageLoaderParms parms("src.Server.cimserver.LOGS_DIRECTORY",
 822 h.sterling      1.153                                  "Logs Directory = ");
 823 humberto        1.97          cout << MessageLoader::getMessage(parms) << logsDirectory << endl;
 824 kumpf           1.57  #endif
 825 mike            1.32      }
 826 kumpf           1.203     catch (Exception& e)
 827 mike            1.32      {
 828 kumpf           1.203         MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
 829                                   "cimserver not started: $0", e.getMessage());
 830 kumpf           1.222         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 831                                   parms);
 832 kumpf           1.203         cerr << MessageLoader::getMessage(parms) << endl;
 833                       
 834                               return 1;
 835 marek           1.186     }
 836 david           1.85  
 837 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS) && defined(PEGASUS_ZOS_SECURITY)
 838 marek           1.186     startupCheckBPXServer(true);
 839                           startupCheckProfileCIMSERVclassWBEM();
 840                           startupEnableMSC();
 841 david           1.85  #endif
 842 mike            1.32  
 843 kumpf           1.139 #if defined(PEGASUS_DEBUG)
 844 mike            1.32      // Put out startup up message.
 845 kumpf           1.202     cout << _cimServerProcess->getProductName() << " " <<
 846                               _cimServerProcess->getCompleteVersion() << endl;
 847 humberto        1.97  #endif
 848                       
 849 kumpf           1.202     // reset message loading to NON-process locale
 850                           MessageLoader::_useProcessLocale = false;
 851 mike            1.32  
 852 kumpf           1.137     // Get the parent's PID before forking
 853 kumpf           1.198     _serverRunStatus.setParentPid(System::getPID());
 854 david.dillard   1.165 
 855 kumpf           1.202     // Do not fork when using privilege separation (executor will daemonize
 856                           // itself later).
 857 kumpf           1.63      if (daemonOption)
 858                           {
 859 kumpf           1.202         if (-1 == _cimServerProcess->cimserver_fork())
 860                                   return -1;
 861 kumpf           1.63      }
 862 chuck           1.66  
 863 chuck           1.96      // Now we are after the fork...
 864                           // Create a dummy Thread object that can be used to store the
 865 kumpf           1.176     // AcceptLanguageList object for CIM requests that are serviced
 866 chuck           1.96      // by this thread (initial thread of server).  Need to do this
 867                           // because this thread is not in a ThreadPool, but is used
 868                           // to service CIM requests.
 869                           // The run function for the dummy Thread should never be called,
 870 konrad.r        1.166     dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
 871 david.dillard   1.165     Thread::setCurrent(dummyInitialThread);
 872 kumpf           1.202     try
 873                           {
 874 kumpf           1.214         Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages());
 875 kumpf           1.202     }
 876                           catch (InvalidAcceptLanguageHeader& e)
 877                           {
 878 kumpf           1.203         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 879 kumpf           1.222             MessageLoaderParms(
 880                                       "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
 881                                       "Could not convert the system process locale into a valid "
 882                                           "AcceptLanguage format."));
 883 kumpf           1.203         Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
 884                                   e.getMessage());
 885 humberto        1.108     }
 886 david.dillard   1.165 
 887 kumpf           1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
 888                           umask(S_IRWXG|S_IRWXO);
 889                       #endif
 890 mday            1.62  
 891 kumpf           1.203     // Start up the CIM Server
 892 mateus.baur     1.175 
 893 kumpf           1.203     try
 894                           {
 895 mateus.baur     1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
 896 kumpf           1.203         //
 897                               // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
 898                               // concurrent writes to this file by multiple cimserver processes
 899                               // starting at the same time.
 900                               //
 901                               CString startupLockFileName = ConfigManager::getHomedPath(
 902 kumpf           1.204             PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
 903 kumpf           1.203 
 904                               // Make sure the start-up lock file exists
 905                               FILE* startupLockFile;
 906                               if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
 907                               {
 908                                   fclose(startupLockFile);
 909                               }
 910 kumpf           1.202 
 911 kumpf           1.203         AutoFileLock fileLock(startupLockFileName);
 912                       #endif
 913 kumpf           1.202 
 914 kumpf           1.203 #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
 915                               //
 916                               // Check if a CIM Server is already running.  If so, print an error
 917                               // message and notify the parent process (if there is one) to terminate
 918                               //
 919                               if (_serverRunStatus.isServerRunning())
 920                               {
 921                                   MessageLoaderParms parms(
 922                                       "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
 923                                       "Unable to start CIMServer. CIMServer is already running.");
 924 kumpf           1.222             Logger::put_l(
 925 kumpf           1.203                 Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 926 kumpf           1.222                 parms);
 927 kumpf           1.203             cerr << MessageLoader::getMessage(parms) << endl;
 928 mateus.baur     1.175 
 929 kumpf           1.203             if (daemonOption)
 930                                   {
 931                                       _cimServerProcess->notify_parent(1);
 932                                   }
 933 kumpf           1.79  
 934 kumpf           1.203             return 1;
 935                               }
 936 kumpf           1.79  
 937 kumpf           1.198         //
 938 kumpf           1.203         // Declare ourselves as the running CIM Server process, and write our
 939                               // PID to the PID file.
 940 kumpf           1.79          //
 941 kumpf           1.203         _serverRunStatus.setServerRunning();
 942                       #endif
 943                       
 944                               // Create and initialize the CIMServer object
 945                       
 946                               _cimServer = new CIMServer();
 947                       
 948                               Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
 949                                   configManager->getCurrentValue("enableHttpConnection"));
 950                               Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
 951                                   configManager->getCurrentValue("enableHttpsConnection"));
 952                       
 953                       #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 954                               // Make sure at least one connection is enabled
 955                               if (!enableHttpConnection && !enableHttpsConnection)
 956 kumpf           1.198         {
 957 kumpf           1.203             MessageLoaderParms parms(
 958                                       "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
 959                                       "Neither HTTP nor HTTPS connection is enabled.");
 960                                   throw Exception(parms);
 961 kumpf           1.198         }
 962 kumpf           1.63  #endif
 963 kumpf           1.51  
 964 venkat.puvvada  1.208         Boolean addIP6Acceptor = false;
 965                               Boolean addIP4Acceptor = false;
 966                       
 967                       #ifdef PEGASUS_OS_TYPE_WINDOWS
 968                               addIP4Acceptor = true;
 969                       #endif
 970                       
 971                       #ifdef PEGASUS_ENABLE_IPV6
 972                               // If IPv6 stack is disabled swicth to IPv4 stack.
 973                               if (System::isIPv6StackActive())
 974                               {
 975                                   addIP6Acceptor = true;
 976                               }
 977                               else
 978                               {
 979                                   MessageLoaderParms parms(
 980                                       "src.Server.cimserver.IPV6_STACK_NOT_ACTIVE",
 981                                       "IPv6 stack is not active, using IPv4 socket.");
 982 kumpf           1.222             Logger::put_l(
 983 venkat.puvvada  1.208                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
 984 kumpf           1.222                 parms);
 985 venkat.puvvada  1.208 #if defined(PEGASUS_DEBUG)
 986                                   cout << MessageLoader::getMessage(parms) << endl;
 987                       #endif
 988                               }
 989                       #endif
 990                               if (!addIP6Acceptor)
 991                               {
 992                                   addIP4Acceptor = true;
 993                               }
 994                       
 995 kumpf           1.203         // The server HTTP and HTTPS ports are determined via this algorithm:
 996                               // 1) If the user explicitly specified a port, use it.
 997                               // 2) If the user did not specify a port, get the port from the
 998                               //    services file.
 999                               // 3) If no value is specified in the services file, use the IANA WBEM
1000                               //    default port.
1001                               // Note that 2 and 3 are done within the System::lookupPort method
1002                               // An empty string from the ConfigManager implies that the user did not
1003                               // specify a port.
1004 kumpf           1.41  
1005 kumpf           1.86          if (enableHttpConnection)
1006                               {
1007 kumpf           1.203             Uint32 portNumberHttp = 0;
1008                                   String httpPort = configManager->getCurrentValue("httpPort");
1009                                   if (httpPort == String::EMPTY)
1010                                   {
1011                                       //
1012                                       // Look up the WBEM-HTTP port number
1013                                       //
1014                                       portNumberHttp = System::lookupPort(
1015                                           WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
1016                                   }
1017                                   else
1018                                   {
1019                                       //
1020                                       // user-specified
1021                                       //
1022                                       CString portString = httpPort.getCString();
1023                                       char* end = 0;
1024                                       portNumberHttp = strtol(portString, &end, 10);
1025                                       if (!(end != 0 && *end == '\0'))
1026                                       {
1027                                           throw InvalidPropertyValue("httpPort", httpPort);
1028 kumpf           1.203                 }
1029                                   }
1030                       
1031 venkat.puvvada  1.208             if (addIP6Acceptor)
1032                                   {
1033                                       _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1034                                           portNumberHttp, false);
1035                                   }
1036                                   if (addIP4Acceptor)
1037                                   {
1038                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1039                                           portNumberHttp, false);
1040                                   }
1041 kumpf           1.198 
1042 denise.eckstein 1.218             char scratchBuffer[22];
1043                                   Uint32 n;
1044                                   const char * portNumberHttpStr = Uint32ToString(
1045                                       scratchBuffer, portNumberHttp, n); 
1046 kumpf           1.203             MessageLoaderParms parms(
1047 kumpf           1.198                 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
1048 denise.eckstein 1.218                 "Listening on HTTP port $0.", portNumberHttpStr);
1049 kumpf           1.222             Logger::put_l(
1050 kumpf           1.203                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1051 kumpf           1.222                 parms);
1052 kumpf           1.203 #if defined(PEGASUS_DEBUG)
1053                                   cout << MessageLoader::getMessage(parms) << endl;
1054                       #endif
1055 kumpf           1.86          }
1056 kumpf           1.198 
1057 kumpf           1.86          if (enableHttpsConnection)
1058                               {
1059 kumpf           1.203             Uint32 portNumberHttps = 0;
1060                                   String httpsPort = configManager->getCurrentValue("httpsPort");
1061                                   if (httpsPort == String::EMPTY)
1062                                   {
1063                                       //
1064                                       // Look up the WBEM-HTTPS port number
1065                                       //
1066                                       portNumberHttps = System::lookupPort(
1067                                           WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
1068                                   }
1069                                   else
1070                                   {
1071                                       //
1072                                       // user-specified
1073                                       //
1074                                       CString portString = httpsPort.getCString();
1075                                       char* end = 0;
1076                                       portNumberHttps = strtol(portString, &end, 10);
1077                                       if (!(end != 0 && *end == '\0'))
1078                                       {
1079                                           throw InvalidPropertyValue("httpsPort", httpsPort);
1080 kumpf           1.203                 }
1081                                   }
1082 venkat.puvvada  1.208             if (addIP6Acceptor)
1083                                   { 
1084                                       _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1085                                           portNumberHttps, true);
1086                                   }
1087                                   if (addIP4Acceptor)
1088                                   {
1089                                       _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1090                                           portNumberHttps, true);
1091                                   }
1092 denise.eckstein 1.218             char scratchBuffer[22];
1093                                   Uint32 n;
1094                                   const char * portNumberHttpsStr = Uint32ToString(
1095                                       scratchBuffer, portNumberHttps, n); 
1096 kumpf           1.203             MessageLoaderParms parms(
1097 kumpf           1.198                 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
1098 denise.eckstein 1.218                 "Listening on HTTPS port $0.", portNumberHttpsStr);
1099 kumpf           1.222             Logger::put_l(
1100 kumpf           1.203                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1101 kumpf           1.222                 parms);
1102 kumpf           1.203 #if defined(PEGASUS_DEBUG)
1103                                   cout << MessageLoader::getMessage(parms) << endl;
1104                       #endif
1105 kumpf           1.86          }
1106 kumpf           1.135 
1107 h.sterling      1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
1108 kumpf           1.203         {
1109 dave.sudlik     1.205             _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
1110 kumpf           1.86  
1111 kumpf           1.198             MessageLoaderParms parms(
1112 kumpf           1.203                 "src.Server.cimserver.LISTENING_ON_LOCAL",
1113                                       "Listening on local connection socket.");
1114 kumpf           1.222             Logger::put_l(
1115 kumpf           1.203                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1116 kumpf           1.222                 parms);
1117 kumpf           1.203 # if defined(PEGASUS_DEBUG)
1118 h.sterling      1.153             cout << MessageLoader::getMessage(parms) << endl;
1119 kumpf           1.203 # endif
1120 kumpf           1.86          }
1121 david           1.85  #endif
1122 mike            1.35  
1123 kumpf           1.198         _cimServer->bind();
1124 kumpf           1.199 
1125 kumpf           1.198         // notify parent process (if there is a parent process) to terminate
1126 konrad.r        1.95          // so user knows that there is cimserver ready to serve CIM requests.
1127 kumpf           1.198         if (daemonOption)
1128                               {
1129                                   _cimServerProcess->notify_parent(0);
1130                               }
1131 mike            1.35  
1132 kumpf           1.139 #if defined(PEGASUS_DEBUG)
1133 kumpf           1.202         cout << "Started. " << endl;
1134 kumpf           1.63  #endif
1135 david.dillard   1.165 
1136 kumpf           1.54          // Put server started message to the logger
1137 kumpf           1.143         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1138                                   Logger::INFORMATION,
1139 kumpf           1.222             MessageLoaderParms(
1140                                       "src.Server.cimserver.STARTED_VERSION",
1141                                       "Started $0 version $1.",
1142                                       _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 kumpf           1.222         Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1164                                   parms);
1165 kumpf           1.203         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 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS)
1182 thilo.boehm     1.185 
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 r.kieninger     1.223 #if defined(PEGASUS_OS_ZOS)
1211 thilo.boehm     1.185 
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.222         Logger::put_l(
1222                                   Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1223                                   MessageLoaderParms(
1224                                       "src.Server.cimserver.STOPPED",
1225                                       "$0 stopped.", _cimServerProcess->getProductName()));
1226 mike            1.32      }
1227 kumpf           1.202     catch (Exception& e)
1228 marek           1.195     {
1229 kumpf           1.202         MessageLoaderParms parms(
1230 marek           1.195             "src.Server.cimserver.ERROR",
1231 kumpf           1.202             "Error: $0",
1232                                   e.getMessage());
1233 kumpf           1.222         Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1234                                   parms);
1235 kumpf           1.203         cerr << MessageLoader::getMessage(parms) << endl;
1236 marek           1.195 
1237                               deleteCIMServer();
1238                               return 1;
1239                           }
1240 mike            1.32  
1241 h.sterling      1.156     deleteCIMServer();
1242 mike            1.32      return 0;
1243                       }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2