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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2