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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2