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 #ifndef PEGASUS_SERVICE_NAME
136 #define PEGASUS_SERVICE_NAME "Pegasus CIM Object Manager";
|
137 chuck 1.66 #endif
|
138 h.sterling 1.153 #ifndef PEGASUS_SERVICE_DESCRIPTION
139 #define PEGASUS_SERVICE_DESCRIPTION "Pegasus CIM Object Manager Service";
|
140 mike 1.32 #endif
141
|
142 ouyang.jian 1.206 #ifdef PEGASUS_OS_PASE
143 #include <as400_protos.h> //for _SETCCSID
144 #endif
145
|
146 h.sterling 1.153 class CIMServerProcess : public ServerProcess
147 {
148 public:
149
|
150 kumpf 1.203 CIMServerProcess()
|
151 h.sterling 1.153 {
152 cimserver_set_process(this);
153 }
154
|
155 kumpf 1.203 virtual ~CIMServerProcess()
|
156 h.sterling 1.153 {
157 }
158
159 //defined in PegasusVersion.h
160 virtual const char* getProductName() const
161 {
162 return PEGASUS_PRODUCT_NAME;
163 }
164
165 virtual const char* getExtendedName() const
166 {
167 return PEGASUS_SERVICE_NAME;
168 }
169
170 virtual const char* getDescription() const
171 {
172 return PEGASUS_SERVICE_DESCRIPTION;
173 }
|
174 david.dillard 1.165
|
175 h.sterling 1.153 //defined in PegasusVersion.h
|
176 jim.wunderlich 1.180 virtual const char* getCompleteVersion() const
177 {
|
178 jim.wunderlich 1.181 if (*PEGASUS_PRODUCT_STATUS == '\0' )
|
179 kumpf 1.199 return PEGASUS_PRODUCT_VERSION;
|
180 jim.wunderlich 1.180 else
|
181 kumpf 1.202 return PEGASUS_PRODUCT_VERSION " " PEGASUS_PRODUCT_STATUS;
|
182 jim.wunderlich 1.180 }
183
184 //defined in PegasusVersion.h
|
185 h.sterling 1.153 virtual const char* getVersion() const
186 {
187 return PEGASUS_PRODUCT_VERSION;
188 }
189
190 virtual const char* getProcessName() const
191 {
192 return PEGASUS_PROCESS_NAME;
193 }
194
|
195 kumpf 1.178 int cimserver_run(
196 int argc,
197 char** argv,
198 Boolean shutdownOption,
199 Boolean debugOutputOption);
|
200 h.sterling 1.153
|
201 kumpf 1.203 void cimserver_stop();
|
202 h.sterling 1.153 };
203
|
204 kumpf 1.198 ServerRunStatus _serverRunStatus(
205 PEGASUS_PROCESS_NAME, PEGASUS_CIMSERVER_START_FILE);
|
206 h.sterling 1.153 AutoPtr<CIMServerProcess> _cimServerProcess(new CIMServerProcess());
207 static CIMServer* _cimServer = 0;
|
208 konrad.r 1.166 static Thread* dummyInitialThread = 0;
|
209 kumpf 1.203
|
210 mike 1.35 //
211 // The command name.
212 //
213 static const char COMMAND_NAME [] = "cimserver";
214
215 //
216 // The constant defining usage string.
217 //
218 static const char USAGE [] = "Usage: ";
219
220 /**
221 Constants representing the command line options.
222 */
223 static const char OPTION_VERSION = 'v';
224
225 static const char OPTION_HELP = 'h';
226
227 static const char OPTION_HOME = 'D';
228
229 static const char OPTION_SHUTDOWN = 's';
230
|
231 kumpf 1.203 static const char LONG_HELP[] = "help";
|
232 a.arora 1.142
|
233 kumpf 1.203 static const char LONG_VERSION[] = "version";
|
234 a.arora 1.142
|
235 kumpf 1.178 static const char OPTION_DEBUGOUTPUT = 'X';
|
236 kumpf 1.48
|
237 mike 1.32 /** GetOptions function - This function defines the Options Table
|
238 mike 1.35 and sets up the options from that table using the config manager.
|
239 kumpf 1.198
240 Some possible exceptions: NoSuchFile, FileNotReadable, CannotRenameFile,
241 ConfigFileSyntaxError, UnrecognizedConfigProperty, InvalidPropertyValue,
242 CannotOpenFile.
|
243 mike 1.32 */
244 void GetOptions(
|
245 mike 1.35 ConfigManager* cm,
|
246 mike 1.32 int& argc,
|
247 mateus.baur 1.193 char** argv,
|
248 kumpf 1.198 Boolean shutdownOption)
|
249 mike 1.32 {
|
250 kumpf 1.198 if (shutdownOption)
251 {
252 cm->loadConfigFiles();
253 }
254 else
|
255 mike 1.32 {
|
256 kumpf 1.198 cm->mergeConfigFiles();
257 }
|
258 mateus.baur 1.193
|
259 kumpf 1.198 // Temporarily disable updates to the current configuration
260 // file if shutdownOption is true
261 cm->useConfigFiles = (shutdownOption==false);
|
262 mike 1.33
|
263 kumpf 1.198 cm->mergeCommandLine(argc, argv);
|
264 mateus.baur 1.193
|
265 kumpf 1.198 // Enable updates again
266 cm->useConfigFiles = true;
|
267 mike 1.32 }
268
269 /* PrintHelp - This is temporary until we expand the options manager to allow
270 options help to be defined with the OptionRow entries and presented from
271 those entries.
272 */
273 void PrintHelp(const char* arg0)
274 {
|
275 mike 1.35 String usage = String (USAGE);
|
276 kumpf 1.202 usage.append(COMMAND_NAME);
277 usage.append(" [ [ options ] | [ configProperty=value, ... ] ]\n");
278 usage.append(" options\n");
279 usage.append(" -v, --version - displays CIM Server version number\n");
|
280 denise.eckstein 1.229 usage.append(" --status - displays the running status of"
281 " the CIM Server\n");
|
282 kumpf 1.202 usage.append(" -h, --help - prints this help message\n");
283 usage.append(" -s - shuts down CIM Server\n");
|
284 kumpf 1.138 #if !defined(PEGASUS_USE_RELEASE_DIRS)
|
285 kumpf 1.202 usage.append(" -D [home] - sets pegasus home directory\n");
|
286 humberto 1.97 #endif
287 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
288 kumpf 1.202 usage.append(" -install [name] - installs pegasus as a Windows "
289 "Service\n");
290 usage.append(" [name] is optional and overrides "
291 "the\n");
292 usage.append(" default CIM Server Service Name\n");
293 usage.append(" by appending [name]\n");
294 usage.append(" -remove [name] - removes 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(" -start [name] - starts pegasus as a Windows Service\n");
301 usage.append(" [name] is optional and overrides "
302 "the\n");
303 usage.append(" default CIM Server Service Name\n");
304 usage.append(" by appending [name]\n");
305 usage.append(" -stop [name] - stops pegasus as a Windows Service\n");
306 usage.append(" [name] is optional and overrides "
307 "the\n");
308 usage.append(" default CIM Server Service Name\n");
309 kumpf 1.202 usage.append(" by appending [name]\n\n");
310 #endif
311 usage.append(" configProperty=value\n");
312 usage.append(" - sets CIM Server configuration "
313 "property\n");
|
314 humberto 1.97
315 cout << endl;
|
316 kumpf 1.202 cout << _cimServerProcess->getProductName() << " " <<
317 _cimServerProcess->getCompleteVersion() << endl;
|
318 humberto 1.97 cout << endl;
|
319 david.dillard 1.165
|
320 humberto 1.97 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
321 humberto 1.104 MessageLoaderParms parms("src.Server.cimserver.MENU.WINDOWS", usage);
|
322 kumpf 1.152 #elif defined(PEGASUS_USE_RELEASE_DIRS)
|
323 kumpf 1.202 MessageLoaderParms parms(
324 "src.Server.cimserver.MENU.HPUXLINUXIA64GNU",
325 usage);
|
326 humberto 1.97 #else
|
327 kumpf 1.138 MessageLoaderParms parms("src.Server.cimserver.MENU.STANDARD", usage);
|
328 humberto 1.97 #endif
329 cout << MessageLoader::getMessage(parms) << endl;
|
330 mike 1.35 }
331
|
332 kumpf 1.202 // This needs to be called at various points in the code depending on the
333 // platform and error conditions.
334 // We need to delete the _cimServer reference on exit in order for the
335 // destructors to get called.
|
336 h.sterling 1.156 void deleteCIMServer()
337 {
|
338 kumpf 1.203 delete _cimServer;
339 _cimServer = 0;
|
340 kumpf 1.202
341 if (dummyInitialThread)
342 {
|
343 kumpf 1.199 Thread::clearLanguages();
344 delete dummyInitialThread;
|
345 kumpf 1.202 }
|
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 thilo.boehm 1.237 #if defined(PEGASUS_OS_ZOS)
872 # if defined(PEGASUS_ZOS_SECURITY)
|
873 marek 1.186 startupCheckBPXServer(true);
874 startupCheckProfileCIMSERVclassWBEM();
875 startupEnableMSC();
|
876 thilo.boehm 1.237 # endif
877 startupWaitForTCPIP();
|
878 david 1.85 #endif
|
879 mike 1.32
|
880 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
881 mike 1.32 // Put out startup up message.
|
882 kumpf 1.202 cout << _cimServerProcess->getProductName() << " " <<
883 _cimServerProcess->getCompleteVersion() << endl;
|
884 humberto 1.97 #endif
885
|
886 kumpf 1.202 // reset message loading to NON-process locale
887 MessageLoader::_useProcessLocale = false;
|
888 mike 1.32
|
889 kumpf 1.137 // Get the parent's PID before forking
|
890 kumpf 1.198 _serverRunStatus.setParentPid(System::getPID());
|
891 david.dillard 1.165
|
892 kumpf 1.202 // Do not fork when using privilege separation (executor will daemonize
893 // itself later).
|
894 kumpf 1.63 if (daemonOption)
895 {
|
896 kumpf 1.202 if (-1 == _cimServerProcess->cimserver_fork())
897 return -1;
|
898 kumpf 1.63 }
|
899 chuck 1.66
|
900 chuck 1.96 // Now we are after the fork...
901 // Create a dummy Thread object that can be used to store the
|
902 kumpf 1.176 // AcceptLanguageList object for CIM requests that are serviced
|
903 chuck 1.96 // by this thread (initial thread of server). Need to do this
904 // because this thread is not in a ThreadPool, but is used
905 // to service CIM requests.
906 // The run function for the dummy Thread should never be called,
|
907 konrad.r 1.166 dummyInitialThread = new Thread(dummyThreadFunc, NULL, false);
|
908 david.dillard 1.165 Thread::setCurrent(dummyInitialThread);
|
909 kumpf 1.202 try
910 {
|
911 kumpf 1.214 Thread::setLanguages(LanguageParser::getDefaultAcceptLanguages());
|
912 kumpf 1.202 }
913 catch (InvalidAcceptLanguageHeader& e)
914 {
|
915 kumpf 1.203 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
|
916 kumpf 1.222 MessageLoaderParms(
917 "src.Server.cimserver.FAILED_TO_SET_PROCESS_LOCALE",
918 "Could not convert the system process locale into a valid "
919 "AcceptLanguage format."));
|
920 kumpf 1.203 Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
921 e.getMessage());
|
922 humberto 1.108 }
|
923 david.dillard 1.165
|
924 kumpf 1.167 #ifndef PEGASUS_OS_TYPE_WINDOWS
925 umask(S_IRWXG|S_IRWXO);
926 #endif
|
927 mday 1.62
|
928 kumpf 1.203 // Start up the CIM Server
|
929 mateus.baur 1.175
|
930 kumpf 1.203 try
931 {
|
932 mateus.baur 1.175 #if defined(PEGASUS_OS_TYPE_UNIX)
|
933 kumpf 1.203 //
934 // Lock the CIMSERVER_LOCK_FILE during CIM Server start-up to prevent
935 // concurrent writes to this file by multiple cimserver processes
936 // starting at the same time.
937 //
938 CString startupLockFileName = ConfigManager::getHomedPath(
|
939 kumpf 1.204 PEGASUS_CIMSERVER_START_LOCK_FILE).getCString();
|
940 kumpf 1.203
941 // Make sure the start-up lock file exists
942 FILE* startupLockFile;
943 if ((startupLockFile = fopen(startupLockFileName, "w")) != 0)
944 {
945 fclose(startupLockFile);
946 }
|
947 kumpf 1.202
|
948 kumpf 1.203 AutoFileLock fileLock(startupLockFileName);
949 #endif
|
950 kumpf 1.202
|
951 kumpf 1.203 #if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS)
952 //
953 // Check if a CIM Server is already running. If so, print an error
954 // message and notify the parent process (if there is one) to terminate
955 //
956 if (_serverRunStatus.isServerRunning())
957 {
958 MessageLoaderParms parms(
959 "src.Server.cimserver.UNABLE_TO_START_SERVER_ALREADY_RUNNING",
960 "Unable to start CIMServer. CIMServer is already running.");
|
961 kumpf 1.222 Logger::put_l(
|
962 kumpf 1.203 Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
|
963 kumpf 1.222 parms);
|
964 kumpf 1.203 cerr << MessageLoader::getMessage(parms) << endl;
|
965 mateus.baur 1.175
|
966 kumpf 1.203 if (daemonOption)
967 {
968 _cimServerProcess->notify_parent(1);
969 }
|
970 kumpf 1.79
|
971 kumpf 1.203 return 1;
972 }
|
973 kumpf 1.79
|
974 kumpf 1.198 //
|
975 kumpf 1.203 // Declare ourselves as the running CIM Server process, and write our
976 // PID to the PID file.
|
977 kumpf 1.79 //
|
978 kumpf 1.203 _serverRunStatus.setServerRunning();
979 #endif
980
981 // Create and initialize the CIMServer object
982
983 _cimServer = new CIMServer();
984
985 Boolean enableHttpConnection = ConfigManager::parseBooleanValue(
986 configManager->getCurrentValue("enableHttpConnection"));
987 Boolean enableHttpsConnection = ConfigManager::parseBooleanValue(
988 configManager->getCurrentValue("enableHttpsConnection"));
989
990 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
991 // Make sure at least one connection is enabled
992 if (!enableHttpConnection && !enableHttpsConnection)
|
993 kumpf 1.198 {
|
994 kumpf 1.203 MessageLoaderParms parms(
995 "src.Server.cimserver.HTTP_NOT_ENABLED_SERVER_NOT_STARTING",
996 "Neither HTTP nor HTTPS connection is enabled.");
997 throw Exception(parms);
|
998 kumpf 1.198 }
|
999 kumpf 1.63 #endif
|
1000 kumpf 1.51
|
1001 venkat.puvvada 1.208 Boolean addIP6Acceptor = false;
1002 Boolean addIP4Acceptor = false;
1003
1004 #ifdef PEGASUS_OS_TYPE_WINDOWS
1005 addIP4Acceptor = true;
1006 #endif
1007
1008 #ifdef PEGASUS_ENABLE_IPV6
1009 // If IPv6 stack is disabled swicth to IPv4 stack.
1010 if (System::isIPv6StackActive())
1011 {
1012 addIP6Acceptor = true;
1013 }
1014 else
1015 {
|
1016 marek 1.233 PEG_TRACE_CSTRING(TRC_SERVER,Tracer::LEVEL4,
|
1017 venkat.puvvada 1.208 "IPv6 stack is not active, using IPv4 socket.");
1018 }
1019 #endif
1020 if (!addIP6Acceptor)
1021 {
1022 addIP4Acceptor = true;
1023 }
1024
|
1025 kumpf 1.203 // The server HTTP and HTTPS ports are determined via this algorithm:
1026 // 1) If the user explicitly specified a port, use it.
1027 // 2) If the user did not specify a port, get the port from the
1028 // services file.
1029 // 3) If no value is specified in the services file, use the IANA WBEM
1030 // default port.
1031 // Note that 2 and 3 are done within the System::lookupPort method
1032 // An empty string from the ConfigManager implies that the user did not
1033 // specify a port.
|
1034 kumpf 1.41
|
1035 kumpf 1.86 if (enableHttpConnection)
1036 {
|
1037 kumpf 1.203 Uint32 portNumberHttp = 0;
1038 String httpPort = configManager->getCurrentValue("httpPort");
1039 if (httpPort == String::EMPTY)
1040 {
1041 //
1042 // Look up the WBEM-HTTP port number
1043 //
1044 portNumberHttp = System::lookupPort(
1045 WBEM_HTTP_SERVICE_NAME, WBEM_DEFAULT_HTTP_PORT);
|
1046 venkat.puvvada 1.231 _initConfigProperty("httpPort", portNumberHttp);
|
1047 kumpf 1.203 }
1048 else
1049 {
1050 //
1051 // user-specified
1052 //
1053 CString portString = httpPort.getCString();
1054 char* end = 0;
1055 portNumberHttp = strtol(portString, &end, 10);
1056 if (!(end != 0 && *end == '\0'))
1057 {
1058 throw InvalidPropertyValue("httpPort", httpPort);
1059 }
1060 }
1061
|
1062 venkat.puvvada 1.208 if (addIP6Acceptor)
1063 {
1064 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1065 portNumberHttp, false);
1066 }
1067 if (addIP4Acceptor)
1068 {
1069 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1070 portNumberHttp, false);
1071 }
|
1072 denise.eckstein 1.225 // The port number is converted to a string to avoid the
1073 // addition of localized characters (e.g., "5,988").
|
1074 denise.eckstein 1.218 char scratchBuffer[22];
1075 Uint32 n;
1076 const char * portNumberHttpStr = Uint32ToString(
|
1077 kumpf 1.228 scratchBuffer, portNumberHttp, n);
|
1078 kumpf 1.203 MessageLoaderParms parms(
|
1079 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTP_PORT",
|
1080 denise.eckstein 1.218 "Listening on HTTP port $0.", portNumberHttpStr);
|
1081 kumpf 1.222 Logger::put_l(
|
1082 kumpf 1.203 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1083 kumpf 1.222 parms);
|
1084 kumpf 1.203 #if defined(PEGASUS_DEBUG)
1085 cout << MessageLoader::getMessage(parms) << endl;
1086 #endif
|
1087 kumpf 1.86 }
|
1088 kumpf 1.198
|
1089 kumpf 1.86 if (enableHttpsConnection)
1090 {
|
1091 kumpf 1.203 Uint32 portNumberHttps = 0;
1092 String httpsPort = configManager->getCurrentValue("httpsPort");
1093 if (httpsPort == String::EMPTY)
1094 {
1095 //
1096 // Look up the WBEM-HTTPS port number
1097 //
1098 portNumberHttps = System::lookupPort(
1099 WBEM_HTTPS_SERVICE_NAME, WBEM_DEFAULT_HTTPS_PORT);
|
1100 venkat.puvvada 1.231 _initConfigProperty("httpsPort", portNumberHttps);
|
1101 kumpf 1.203 }
1102 else
1103 {
1104 //
1105 // user-specified
1106 //
1107 CString portString = httpsPort.getCString();
1108 char* end = 0;
1109 portNumberHttps = strtol(portString, &end, 10);
1110 if (!(end != 0 && *end == '\0'))
1111 {
1112 throw InvalidPropertyValue("httpsPort", httpsPort);
1113 }
1114 }
|
1115 venkat.puvvada 1.208 if (addIP6Acceptor)
|
1116 kumpf 1.228 {
|
1117 venkat.puvvada 1.208 _cimServer->addAcceptor(HTTPAcceptor::IPV6_CONNECTION,
1118 portNumberHttps, true);
1119 }
1120 if (addIP4Acceptor)
1121 {
1122 _cimServer->addAcceptor(HTTPAcceptor::IPV4_CONNECTION,
1123 portNumberHttps, true);
1124 }
|
1125 denise.eckstein 1.225 // The port number is converted to a string to avoid the
1126 // addition of localized characters (e.g., "5,989").
|
1127 denise.eckstein 1.218 char scratchBuffer[22];
1128 Uint32 n;
1129 const char * portNumberHttpsStr = Uint32ToString(
|
1130 kumpf 1.228 scratchBuffer, portNumberHttps, n);
|
1131 kumpf 1.203 MessageLoaderParms parms(
|
1132 kumpf 1.198 "src.Server.cimserver.LISTENING_ON_HTTPS_PORT",
|
1133 denise.eckstein 1.218 "Listening on HTTPS port $0.", portNumberHttpsStr);
|
1134 kumpf 1.222 Logger::put_l(
|
1135 kumpf 1.203 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1136 kumpf 1.222 parms);
|
1137 kumpf 1.203 #if defined(PEGASUS_DEBUG)
1138 cout << MessageLoader::getMessage(parms) << endl;
1139 #endif
|
1140 kumpf 1.86 }
|
1141 kumpf 1.135
|
1142 h.sterling 1.159 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
1143 kumpf 1.203 {
|
1144 dave.sudlik 1.205 _cimServer->addAcceptor(HTTPAcceptor::LOCAL_CONNECTION, 0, false);
|
1145 kumpf 1.86
|
1146 kumpf 1.198 MessageLoaderParms parms(
|
1147 kumpf 1.203 "src.Server.cimserver.LISTENING_ON_LOCAL",
1148 "Listening on local connection socket.");
|
1149 kumpf 1.222 Logger::put_l(
|
1150 kumpf 1.203 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
|
1151 kumpf 1.222 parms);
|
1152 kumpf 1.203 # if defined(PEGASUS_DEBUG)
|
1153 h.sterling 1.153 cout << MessageLoader::getMessage(parms) << endl;
|
1154 kumpf 1.203 # endif
|
1155 kumpf 1.86 }
|
1156 david 1.85 #endif
|
1157 mike 1.35
|
1158 kumpf 1.198 _cimServer->bind();
|
1159 kumpf 1.199
|
1160 kumpf 1.198 // notify parent process (if there is a parent process) to terminate
|
1161 konrad.r 1.95 // so user knows that there is cimserver ready to serve CIM requests.
|
1162 kumpf 1.198 if (daemonOption)
1163 {
1164 _cimServerProcess->notify_parent(0);
1165 }
|
1166 mike 1.35
|
1167 kumpf 1.139 #if defined(PEGASUS_DEBUG)
|
1168 kumpf 1.202 cout << "Started. " << endl;
|
1169 kumpf 1.63 #endif
|
1170 david.dillard 1.165
|
1171 kumpf 1.54 // Put server started message to the logger
|
1172 kumpf 1.143 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
1173 Logger::INFORMATION,
|
1174 kumpf 1.222 MessageLoaderParms(
1175 "src.Server.cimserver.STARTED_VERSION",
1176 "Started $0 version $1.",
1177 _cimServerProcess->getProductName(),
1178 _cimServerProcess->getCompleteVersion()));
|
1179 kumpf 1.45
|
1180 marek 1.190 #if defined(PEGASUS_OS_TYPE_UNIX) && !defined(PEGASUS_OS_ZOS)
|
1181 kumpf 1.178 if (daemonOption && !debugOutputOption)
|
1182 kumpf 1.202 {
|
1183 kumpf 1.178 // Direct standard input, output, and error to /dev/null,
1184 // since we are running as a daemon.
|
1185 thilo.boehm 1.211 close(STDIN_FILENO);
|
1186 kumpf 1.178 open("/dev/null", O_RDONLY);
|
1187 thilo.boehm 1.211 close(STDOUT_FILENO);
|
1188 kumpf 1.178 open("/dev/null", O_RDWR);
|
1189 thilo.boehm 1.211 close(STDERR_FILENO);
|
1190 kumpf 1.178 open("/dev/null", O_RDWR);
1191 }
1192 #endif
|
1193 kumpf 1.203 }
1194 catch (Exception& e)
1195 {
1196 MessageLoaderParms parms("src.Server.cimserver.SERVER_NOT_STARTED",
1197 "cimserver not started: $0", e.getMessage());
|
1198 kumpf 1.222 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
1199 parms);
|
1200 kumpf 1.203 cerr << MessageLoader::getMessage(parms) << endl;
|
1201 kumpf 1.178
|
1202 s.kodali 1.234 deleteCIMServer();
1203
|
1204 kumpf 1.203 //
1205 // notify parent process (if there is a parent process) to terminate
1206 //
1207 if (daemonOption)
1208 _cimServerProcess->notify_parent(1);
1209
1210 return 1;
1211 }
1212
1213 // Run the main CIM Server loop
1214
1215 try
1216 {
|
1217 r.kieninger 1.223 #if defined(PEGASUS_OS_ZOS)
|
1218 thilo.boehm 1.185
|
1219 kumpf 1.202 // ARM is a z/OS internal restart facility.
1220 // This is a z/OS specific change.
|
1221 thilo.boehm 1.185
1222 // Instatiating the automatic restart manager for zOS
1223 ARM_zOS automaticRestartManager;
1224
1225 // register to zOS ARM
1226 automaticRestartManager.Register();
1227
1228 #endif
1229
|
1230 marek 1.217 #ifdef PEGASUS_ENABLE_SLP
1231 _cimServer->startSLPProvider();
|
1232 kumpf 1.228 #endif
|
1233 venkat.puvvada 1.232 _cimServer->initComplete();
1234
|
1235 mike 1.35 //
1236 // Loop to call CIMServer's runForever() method until CIMServer
1237 // has been shutdown
1238 //
|
1239 kumpf 1.202 while (!_cimServer->terminated())
1240 {
1241 _cimServer->runForever();
1242 }
|
1243 carson.hovey 1.157
|
1244 kumpf 1.45 //
1245 // normal termination
|
1246 carson.hovey 1.157 //
|
1247 kumpf 1.203
|
1248 r.kieninger 1.223 #if defined(PEGASUS_OS_ZOS)
|
1249 thilo.boehm 1.185
|
1250 kumpf 1.202 // ARM is a z/OS internal restart facility.
1251 // This is a z/OS specific change.
|
1252 thilo.boehm 1.185
1253 // register to zOS ARM
1254 automaticRestartManager.DeRegister();
1255
1256 #endif
|
1257 kumpf 1.143
|
1258 kumpf 1.54 // Put server shutdown message to the logger
|
1259 kumpf 1.222 Logger::put_l(
1260 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1261 MessageLoaderParms(
1262 "src.Server.cimserver.STOPPED",
1263 "$0 stopped.", _cimServerProcess->getProductName()));
|
1264 mike 1.32 }
|
1265 kumpf 1.202 catch (Exception& e)
|
1266 marek 1.195 {
|
1267 kumpf 1.202 MessageLoaderParms parms(
|
1268 marek 1.195 "src.Server.cimserver.ERROR",
|
1269 kumpf 1.202 "Error: $0",
1270 e.getMessage());
|
1271 kumpf 1.222 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1272 parms);
|
1273 kumpf 1.203 cerr << MessageLoader::getMessage(parms) << endl;
|
1274 marek 1.195
1275 deleteCIMServer();
1276 return 1;
1277 }
|
1278 mike 1.32
|
1279 h.sterling 1.156 deleteCIMServer();
|
1280 mike 1.32 return 0;
1281 }
|