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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2