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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2