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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2