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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2