1 karl 1.177 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.42 //
|
3 karl 1.152 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.124 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.152 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.160 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.177 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.42 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 mike 1.50 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.42 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.124 //
|
21 mike 1.50 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.42 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 mike 1.50 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.42 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
|
34 mike 1.50 #include <Pegasus/Common/Config.h>
35
|
36 mike 1.42 #include <cstdio>
37 #include <cctype>
|
38 mike 1.50 #include <ctime>
|
39 kumpf 1.169
40 #if (defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX)) \
41 && defined(PEGASUS_USE_RELEASE_DIRS)
42 # include <unistd.h>
|
43 kumpf 1.115 #endif
|
44 kumpf 1.169
|
45 kumpf 1.75 #include <Pegasus/Common/Constants.h>
|
46 mike 1.42 #include <Pegasus/Common/FileSystem.h>
|
47 mike 1.183 #include <Pegasus/Common/Signal.h>
|
48 mike 1.50 #include <Pegasus/Common/HTTPAcceptor.h>
|
49 kumpf 1.54 #include <Pegasus/Common/Tracer.h>
|
50 mday 1.58 #include <Pegasus/Common/Cimom.h>
|
51 kumpf 1.78 #include <Pegasus/Common/PegasusVersion.h>
|
52 nag.boranna 1.163 #include <Pegasus/Common/SSLContextManager.h>
|
53 kumpf 1.188 #include <Pegasus/Common/Time.h>
|
54 kumpf 1.78
|
55 mike 1.42 #include <Pegasus/Repository/CIMRepository.h>
|
56 mike 1.50 #include <Pegasus/ExportServer/CIMExportRequestDispatcher.h>
57 #include <Pegasus/ExportServer/CIMExportResponseEncoder.h>
58 #include <Pegasus/ExportServer/CIMExportRequestDecoder.h>
|
59 kumpf 1.54 #include <Pegasus/Config/ConfigManager.h>
|
60 mike 1.50 #include <Pegasus/Security/UserManager/UserManager.h>
|
61 kumpf 1.62 #include <Pegasus/HandlerService/IndicationHandlerService.h>
62 #include <Pegasus/IndicationService/IndicationService.h>
|
63 kumpf 1.184 #include <Pegasus/ProviderManagerService/ProviderManagerService.h>
|
64 mike 1.179 #include <Pegasus/ProviderManager2/Default/DefaultProviderManager.h>
|
65 chip 1.114
|
66 tony 1.134 #ifdef PEGASUS_ENABLE_SLP
67 #include <Pegasus/Client/CIMClient.h>
68 #endif
69
|
70 mreddy 1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
71 #include "SLPAttrib.h"
72 #endif
73
|
74 mike 1.47 #include "CIMServer.h"
|
75 mike 1.50 #include "CIMOperationRequestDispatcher.h"
76 #include "CIMOperationResponseEncoder.h"
77 #include "CIMOperationRequestDecoder.h"
|
78 kumpf 1.54 #include "CIMOperationRequestAuthorizer.h"
|
79 mike 1.50 #include "HTTPAuthenticatorDelegator.h"
|
80 kumpf 1.79 #include "ShutdownProvider.h"
|
81 kumpf 1.101 #include "ShutdownService.h"
|
82 mday 1.103 #include "BinaryMessageHandler.h"
|
83 kumpf 1.69 #include <Pegasus/Common/ModuleController.h>
|
84 kumpf 1.70 #include <Pegasus/ControlProviders/ConfigSettingProvider/ConfigSettingProvider.h>
|
85 kumpf 1.71 #include <Pegasus/ControlProviders/UserAuthProvider/UserAuthProvider.h>
|
86 kumpf 1.74 #include <Pegasus/ControlProviders/ProviderRegistrationProvider/ProviderRegistrationProvider.h>
|
87 karl 1.80 #include <Pegasus/ControlProviders/NamespaceProvider/NamespaceProvider.h>
|
88 humberto 1.110
|
89 karl 1.158 #ifndef PEGASUS_DISABLE_PERFINST
|
90 w.white 1.142 #include <Pegasus/ControlProviders/Statistic/CIMOMStatDataProvider.h>
91 #endif
92
|
93 h.sterling 1.154 #ifdef PEGASUS_HAS_SSL
94 #include <Pegasus/ControlProviders/CertificateProvider/CertificateProvider.h>
95 #endif
|
96 w.white 1.142
|
97 a.arora 1.156 #ifndef PEGASUS_DISABLE_CQL
98 #include <Pegasus/ControlProviders/QueryCapabilitiesProvider/CIMQueryCapabilitiesProvider.h>
99 #endif
100
|
101 karl 1.158 #if !defined(PEGASUS_DISABLE_PERFINST) || defined(PEGASUS_ENABLE_SLP)
|
102 tony 1.134 #include <Pegasus/ControlProviders/InteropProvider/InteropProvider.h>
103 #endif
104
|
105 humberto 1.110 // l10n
106 #include <Pegasus/Common/MessageLoader.h>
107
|
108 mreddy 1.190.2.1 #include <Pegasus/Common/Threads.h>
|
109 a.arora 1.143
|
110 mike 1.42 PEGASUS_NAMESPACE_BEGIN
|
111 mreddy 1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
112 ThreadReturnType PEGASUS_THREAD_CDECL _advertisePegasus(void *parm);
113 # define MAX_LIFE 0x0fff
114 # define SLP_PORT 427
115 # define LOCALHOST_IP "127.0.0.1"
116 #endif
|
117 a.arora 1.143 static CIMServer *_cimserver = NULL;
118
|
119 kumpf 1.100 // Need a static method to act as a callback for the control provider.
120 // This doesn't belong here, but I don't have a better place to put it.
|
121 kumpf 1.73 static Message * controlProviderReceiveMessageCallback(
122 Message * message,
123 void * instance)
|
124 kumpf 1.69 {
|
125 kumpf 1.185 CIMRequestMessage* request = dynamic_cast<CIMRequestMessage*>(message);
126 PEGASUS_ASSERT(request != 0);
127
128 AcceptLanguageList* langs = new AcceptLanguageList(
129 ((AcceptLanguageListContainer) request->operationContext.get(
130 AcceptLanguageListContainer::NAME)).getLanguages());
131 Thread::setLanguages(langs);
132
133 ProviderMessageHandler* pmh =
134 reinterpret_cast<ProviderMessageHandler*>(instance);
135 return pmh->processMessage(request);
|
136 kumpf 1.73 }
|
137 kumpf 1.71
|
138 kumpf 1.137 //
139 // Signal handler for shutdown signals, currently SIGHUP and SIGTERM
140 //
|
141 kumpf 1.108 Boolean handleShutdownSignal = false;
|
142 mreddy 1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
143 // Signal to shutdown the SLP advertising thread
144 Boolean handleCloseSLPThread = false;
145 #endif
|
146 kumpf 1.108 void shutdownSignalHandler(int s_n, PEGASUS_SIGINFO_T * s_info, void * sig)
|
147 kumpf 1.101 {
|
148 kumpf 1.108 PEG_METHOD_ENTER(TRC_SERVER, "shutdownSignalHandler");
149 Tracer::trace(TRC_SERVER, Tracer::LEVEL2, "Signal %d received.", s_n);
|
150 kumpf 1.101
|
151 a.arora 1.143 CIMServer::shutdownSignal();
|
152 kumpf 1.101
153 PEG_METHOD_EXIT();
154 }
155
|
156 s.hills 1.123 void CIMServer::shutdownSignal()
157 {
158 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdownSignal()");
159 handleShutdownSignal = true;
|
160 mreddy 1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
161 handleCloseSLPThread = true;
162 #endif
|
163 a.arora 1.143 _cimserver->tickle_monitor();
|
164 s.hills 1.123 PEG_METHOD_EXIT();
165 }
166
167
|
168 kumpf 1.101 CIMServer::CIMServer(Monitor* monitor)
|
169 kumpf 1.157 : _dieNow(false), _monitor(monitor)
|
170 mike 1.43 {
|
171 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::CIMServer()");
|
172 mday 1.111 _init();
|
173 a.arora 1.143 _cimserver = this;
|
174 mreddy 1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
175 SLPThread = NULL;
176 #endif
|
177 mday 1.111 PEG_METHOD_EXIT();
178 }
179
180
|
181 a.arora 1.143 void CIMServer::tickle_monitor(){
182 _monitor->tickle();
183 }
|
184 mike 1.179
|
185 mday 1.111 void CIMServer::_init(void)
186 {
|
187 kumpf 1.54
|
188 kumpf 1.60 String repositoryRootPath = String::EMPTY;
|
189 jim.wunderlich 1.162 int binaryMode;
190 CIMRepository_Mode Mode;
|
191 mike 1.50
|
192 tony 1.134 #ifdef PEGASUS_ENABLE_SLP
193 _runSLP = true; // Boolean cannot be set in definition.
194 #endif
|
195 kumpf 1.115
|
196 kumpf 1.167 #if (defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX)) \
197 && defined(PEGASUS_USE_RELEASE_DIRS)
198 chdir(PEGASUS_CORE_DIR);
|
199 kumpf 1.115 #endif
|
200 mike 1.50 // -- Save the monitor or create a new one:
|
201 kumpf 1.60 repositoryRootPath =
|
202 nag.boranna 1.161 ConfigManager::getHomedPath(ConfigManager::getInstance()->getCurrentValue("repositoryDir"));
|
203 kumpf 1.60
|
204 mike 1.43 // -- Create a repository:
205
|
206 kumpf 1.81 #ifdef DO_NOT_CREATE_REPOSITORY_ON_STARTUP
207 // If this code is enable, the CIMServer will fail to start
208 // if the repository directory does not exit. If called,
209 // the Repository will create an empty repository.
210
|
211 chip 1.112 // This check has been disabled to allow cimmof to call
|
212 kumpf 1.81 // the CIMServer to build the initial repository.
|
213 kumpf 1.60 if (!FileSystem::isDirectory(repositoryRootPath))
|
214 kumpf 1.54 {
|
215 kumpf 1.75 PEG_METHOD_EXIT();
|
216 nag.boranna 1.161 throw NoSuchDirectory(repositoryRootPath);
|
217 humberto 1.110
|
218 kumpf 1.54 }
|
219 kumpf 1.81 #endif
|
220 mike 1.43
|
221 kumpf 1.182 binaryMode = ConfigManager::parseBooleanValue(
222 ConfigManager::getInstance()->getCurrentValue(
223 "enableBinaryRepository"));
|
224 jim.wunderlich 1.162
225 Mode.flag = CIMRepository_Mode::NONE;
226 if (binaryMode)
227 Mode.flag |= CIMRepository_Mode::BIN;
228
229 _repository = new CIMRepository(repositoryRootPath, Mode);
|
230 mike 1.50
|
231 kumpf 1.76 // -- Create a UserManager object:
232
233 UserManager* userManager = UserManager::getInstance(_repository);
234
|
235 mike 1.50 // -- Create a CIMServerState object:
236
|
237 a.arora 1.133 _serverState.reset(new CIMServerState());
|
238 mike 1.50
|
239 kumpf 1.67 _providerRegistrationManager = new ProviderRegistrationManager(_repository);
240
|
241 mike 1.50 // -- Create queue inter-connections:
|
242 schuur 1.127
|
243 mike 1.179 _providerManager = new ProviderManagerService(
244 _providerRegistrationManager,
245 _repository,
246 DefaultProviderManager::createDefaultProviderManagerCallback);
247
248 // Create IndicationHandlerService:
|
249 kumpf 1.159
|
250 kumpf 1.67 _handlerService = new IndicationHandlerService(_repository);
|
251 kumpf 1.69
|
252 kumpf 1.71 // Create the control service
|
253 kumpf 1.99 _controlService = new ModuleController(PEGASUS_QUEUENAME_CONTROLSERVICE);
|
254 kumpf 1.71
|
255 konrad.r 1.171 // Jump this number up when there are more control providers.
256 _controlProviders.reserveCapacity(16);
|
257 kumpf 1.185
|
258 kumpf 1.71 // Create the Configuration control provider
|
259 kumpf 1.185 ProviderMessageHandler* configProvider = new ProviderMessageHandler(
260 "ConfigSettingProvider", new ConfigSettingProvider(), 0, 0, false);
|
261 konrad.r 1.171
|
262 kumpf 1.185 _controlProviders.append(configProvider);
|
263 kumpf 1.77 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
|
264 kumpf 1.75 PEGASUS_MODULENAME_CONFIGPROVIDER,
|
265 kumpf 1.69 configProvider,
|
266 kumpf 1.73 controlProviderReceiveMessageCallback,
|
267 kumpf 1.181 0);
|
268 kumpf 1.71
269 // Create the User/Authorization control provider
|
270 kumpf 1.185 ProviderMessageHandler* userAuthProvider = new ProviderMessageHandler(
271 "UserAuthProvider", new UserAuthProvider(_repository), 0, 0, false);
272 _controlProviders.append(userAuthProvider);
|
273 kumpf 1.77 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
|
274 kumpf 1.75 PEGASUS_MODULENAME_USERAUTHPROVIDER,
|
275 kumpf 1.71 userAuthProvider,
|
276 kumpf 1.73 controlProviderReceiveMessageCallback,
|
277 kumpf 1.181 0);
|
278 mike 1.50
|
279 kumpf 1.74 // Create the Provider Registration control provider
|
280 kumpf 1.185 ProviderMessageHandler* provRegProvider = new ProviderMessageHandler(
281 "ProviderRegistrationProvider",
282 new ProviderRegistrationProvider(_providerRegistrationManager),
283 0, 0, false);
284 // Warning: The ProviderRegistrationProvider destructor deletes
285 // _providerRegistrationManager
286 _controlProviders.append(provRegProvider);
|
287 kumpf 1.77 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
|
288 kumpf 1.75 PEGASUS_MODULENAME_PROVREGPROVIDER,
|
289 kumpf 1.74 provRegProvider,
290 controlProviderReceiveMessageCallback,
|
291 kumpf 1.181 0);
|
292 kumpf 1.79
|
293 kumpf 1.185 // Create the Shutdown control provider
294 ProviderMessageHandler* shutdownProvider = new ProviderMessageHandler(
295 "ShutdownProvider", new ShutdownProvider(this), 0, 0, false);
296 _controlProviders.append(shutdownProvider);
|
297 kumpf 1.79 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
298 PEGASUS_MODULENAME_SHUTDOWNPROVIDER,
299 shutdownProvider,
|
300 karl 1.80 controlProviderReceiveMessageCallback,
|
301 kumpf 1.181 0);
|
302 karl 1.80
|
303 kumpf 1.185 // Create the namespace control provider
304 ProviderMessageHandler* namespaceProvider = new ProviderMessageHandler(
305 "NamespaceProvider", new NamespaceProvider(_repository), 0, 0, false);
306 _controlProviders.append(namespaceProvider);
|
307 karl 1.80 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
308 PEGASUS_MODULENAME_NAMESPACEPROVIDER,
309 namespaceProvider,
|
310 kumpf 1.79 controlProviderReceiveMessageCallback,
|
311 kumpf 1.181 0);
|
312 nag.boranna 1.161
313 //
314 // Create a SSLContextManager object
315 //
316 _sslContextMgr = new SSLContextManager();
317
|
318 h.sterling 1.154 #ifdef PEGASUS_HAS_SSL
|
319 sushma.fernandes 1.189 // Because this provider allows management of the cimserver truststore
320 // it needs to be available regardless of the value
321 // of sslClientVerificationMode config property.
|
322 kumpf 1.185 ProviderMessageHandler* certificateProvider = new ProviderMessageHandler(
323 "CertificateProvider",
324 new CertificateProvider(_repository, _sslContextMgr),
325 0, 0, false);
326 _controlProviders.append(certificateProvider);
|
327 nag.boranna 1.161 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
328 PEGASUS_MODULENAME_CERTIFICATEPROVIDER,
329 certificateProvider,
330 controlProviderReceiveMessageCallback,
|
331 kumpf 1.181 0);
|
332 h.sterling 1.154 #endif
|
333 h.sterling 1.153
|
334 karl 1.158 #ifndef PEGASUS_DISABLE_PERFINST
|
335 kumpf 1.185 // Create the Statistical Data control provider
336 ProviderMessageHandler* cimomstatdataProvider = new ProviderMessageHandler(
337 "CIMOMStatDataProvider", new CIMOMStatDataProvider(), 0, 0, false);
338 _controlProviders.append(cimomstatdataProvider);
|
339 w.white 1.142 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
340 PEGASUS_MODULENAME_CIMOMSTATDATAPROVIDER, cimomstatdataProvider,
341 controlProviderReceiveMessageCallback,
|
342 kumpf 1.181 0);
|
343 w.white 1.142 #endif
344
|
345 a.arora 1.156 #ifndef PEGASUS_DISABLE_CQL
346
|
347 kumpf 1.185 // Create the Query Capabilities control provider
348 ProviderMessageHandler* cimquerycapprovider = new ProviderMessageHandler(
349 "CIMQueryCapabilitiesProvider",
350 new CIMQueryCapabilitiesProvider(),
351 0, 0, false);
352 _controlProviders.append(cimquerycapprovider);
|
353 a.arora 1.156 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
354 PEGASUS_MODULENAME_CIMQUERYCAPPROVIDER,
355 cimquerycapprovider,
356 controlProviderReceiveMessageCallback,
|
357 kumpf 1.181 0);
|
358 a.arora 1.156 #endif
359
|
360 w.white 1.142
|
361 karl 1.158 #if !defined(PEGASUS_DISABLE_PERFINST) || defined(PEGASUS_ENABLE_SLP)
|
362 w.white 1.149
|
363 kumpf 1.185 // Create the interop control provider
364 ProviderMessageHandler* interopProvider = new ProviderMessageHandler(
365 "InteropProvider", new InteropProvider(_repository), 0, 0, false);
366 _controlProviders.append(interopProvider);
|
367 tony 1.134 ModuleController::register_module(PEGASUS_QUEUENAME_CONTROLSERVICE,
368 PEGASUS_MODULENAME_INTEROPPROVIDER,
369 interopProvider,
370 controlProviderReceiveMessageCallback,
|
371 kumpf 1.181 0);
|
372 tony 1.134 #endif
|
373 kumpf 1.74
|
374 mike 1.50 _cimOperationRequestDispatcher
|
375 nag.boranna 1.161 = new CIMOperationRequestDispatcher(_repository,
|
376 kumpf 1.74 _providerRegistrationManager);
|
377 chip 1.112 _binaryMessageHandler =
|
378 mday 1.103 new BinaryMessageHandler(_cimOperationRequestDispatcher);
|
379 chip 1.112
|
380 mike 1.50 _cimOperationResponseEncoder
|
381 nag.boranna 1.161 = new CIMOperationResponseEncoder;
|
382 mike 1.50
|
383 kumpf 1.54 //
384 // get the configured authentication and authorization flags
385 //
386 ConfigManager* configManager = ConfigManager::getInstance();
387
|
388 kumpf 1.182 Boolean enableAuthentication = ConfigManager::parseBooleanValue(
389 configManager->getCurrentValue("enableAuthentication"));
|
390 kumpf 1.54
391 //
|
392 kumpf 1.104 // Create Authorization queue only if authentication is enabled
|
393 kumpf 1.54 //
|
394 kumpf 1.104 if ( enableAuthentication )
|
395 kumpf 1.54 {
396 _cimOperationRequestAuthorizer = new CIMOperationRequestAuthorizer(
397 _cimOperationRequestDispatcher);
398
399 _cimOperationRequestDecoder = new CIMOperationRequestDecoder(
400 _cimOperationRequestAuthorizer,
401 _cimOperationResponseEncoder->getQueueId());
402 }
403 else
404 {
|
405 kumpf 1.99 _cimOperationRequestAuthorizer = 0;
406
|
407 kumpf 1.54 _cimOperationRequestDecoder = new CIMOperationRequestDecoder(
408 _cimOperationRequestDispatcher,
409 _cimOperationResponseEncoder->getQueueId());
410
411 }
|
412 mike 1.43
|
413 mike 1.50 _cimExportRequestDispatcher
|
414 nag.boranna 1.161 = new CIMExportRequestDispatcher();
|
415 mike 1.43
|
416 mike 1.50 _cimExportResponseEncoder
|
417 nag.boranna 1.161 = new CIMExportResponseEncoder;
|
418 mike 1.43
|
419 mike 1.50 _cimExportRequestDecoder = new CIMExportRequestDecoder(
|
420 nag.boranna 1.161 _cimExportRequestDispatcher,
421 _cimExportResponseEncoder->getQueueId());
|
422 mike 1.43
|
423 kumpf 1.99 _httpAuthenticatorDelegator = new HTTPAuthenticatorDelegator(
|
424 mike 1.50 _cimOperationRequestDecoder->getQueueId(),
|
425 h.sterling 1.153 _cimExportRequestDecoder->getQueueId(),
|
426 nag.boranna 1.161 _repository);
|
427 mike 1.43
|
428 kumpf 1.82 // IMPORTANT-NU-20020513: Indication service must start after ExportService
429 // otherwise HandlerService started by indicationService will never
430 // get ExportQueue to export indications for existing subscriptions
431
|
432 kumpf 1.90 _indicationService = 0;
|
433 kumpf 1.182 if (ConfigManager::parseBooleanValue(
434 configManager->getCurrentValue("enableIndicationService")))
|
435 kumpf 1.90 {
436 _indicationService = new IndicationService
437 (_repository, _providerRegistrationManager);
438 }
|
439 mike 1.50
|
440 kumpf 1.108 // Enable the signal handler to shutdown gracefully on SIGHUP and SIGTERM
441 getSigHandle()->registerHandler(PEGASUS_SIGHUP, shutdownSignalHandler);
|
442 kumpf 1.107 getSigHandle()->activate(PEGASUS_SIGHUP);
|
443 kumpf 1.108 getSigHandle()->registerHandler(PEGASUS_SIGTERM, shutdownSignalHandler);
444 getSigHandle()->activate(PEGASUS_SIGTERM);
|
445 mike 1.50
|
446 kumpf 1.132 // Load and initialize providers registed with AutoStart = true
447 _providerRegistrationManager->initializeProviders();
448
|
449 mike 1.43 }
450
|
451 mday 1.111
|
452 konrad.r 1.171 CIMServer::~CIMServer ()
453 {
|
454 kumpf 1.175 PEG_METHOD_ENTER (TRC_SERVER, "CIMServer::~CIMServer()");
|
455 mreddy 1.190.2.1 #ifdef PEGASUS_SLP_REG_TIMEOUT
456 handleCloseSLPThread = true;
457 #endif
|
458 mday 1.111
|
459 kumpf 1.175 // Wait until the Shutdown provider request has cleared through the
460 // system.
461 ShutdownService::getInstance(this)->waitUntilNoMoreRequests(false);
|
462 mday 1.111
|
463 kumpf 1.175 // Ok, shutdown all the MQSs. This shuts their communication channel.
464 ShutdownService::getInstance(this)->shutdownCimomServices();
|
465 kumpf 1.54
|
466 kumpf 1.175 // Start deleting the objects.
467 // The order is very important.
468
469 // The HTTPAcceptor depends on HTTPAuthenticationDelegator
470 for (Uint32 i = 0, n = _acceptors.size (); i < n; i++)
|
471 konrad.r 1.171 {
|
472 kumpf 1.175 HTTPAcceptor *p = _acceptors[i];
473 delete p;
|
474 konrad.r 1.171 }
|
475 kumpf 1.99
|
476 kumpf 1.175 // IndicationService depends on ProviderManagerService,
477 // IndicationHandlerService, and ProviderRegistrationManager, and thus
478 // should be deleted before the ProviderManagerService,
479 // IndicationHandlerService, and ProviderRegistrationManager are deleted.
480 delete _indicationService;
481
482 // HTTPAuthenticationDelegator depends on CIMRepository,
483 // CIMOperationRequestDecoder and CIMExportRequestDecoder
484 delete _httpAuthenticatorDelegator;
485
486 delete _cimExportRequestDecoder;
487
488 delete _cimExportResponseEncoder;
489
490 delete _cimExportRequestDispatcher;
491
492 // CIMOperationRequestDecoder depends on CIMOperationRequestAuthorizer
493 // and CIMOperationResponseEncoder
494 delete _cimOperationRequestDecoder;
495
496 delete _cimOperationResponseEncoder;
497 kumpf 1.175
498 // BinaryMessageHandler depends on CIMOperationRequestDispatcher
499 delete _binaryMessageHandler;
500
501 // CIMOperationRequestAuthorizer depends on
502 // CIMOperationRequestDispatcher
503 delete _cimOperationRequestAuthorizer;
504
505 // IndicationHandlerService uses CIMOperationRequestDispatcher
506 delete _handlerService;
507
508 // CIMOperationRequestDispatcher depends on
509 // CIMRepository and ProviderRegistrationManager.
510 // CIMOperationRequestDispatcher keeps an internal list of control
511 // providers. Must delete this before ModuleController.
512 delete _cimOperationRequestDispatcher;
513
514 // ModuleController takes care of deleting all wrappers around
515 // the control providers.
516 delete _controlService;
517
518 kumpf 1.175 // Find all of the control providers (module)
519 // Must delete CIMOperationRequestDispatcher _before_ deleting each
520 // of the control provider. The CIMOperationRequestDispatcher keeps
521 // its own table of the internal providers (pointers).
522 for (Uint32 i = 0, n = _controlProviders.size(); i < n; i++)
|
523 konrad.r 1.171 {
|
524 kumpf 1.185 ProviderMessageHandler *p = _controlProviders[i];
525 p->terminate();
|
526 kumpf 1.175 delete p;
|
527 konrad.r 1.171 }
528
|
529 kumpf 1.175 // The SSL control providers use the SSL context manager.
530 delete _sslContextMgr;
531
532 // ProviderManagerService depends on ProviderRegistrationManager.
533 // Note that deleting the ProviderManagerService causes the
534 // DefaultProviderManager (if loaded) to get unloaded. Dynamically
535 // unloading the DefaultProviderManager library affects (on HP-UX, at
536 // least) the statically loaded version of this library used by the
|
537 kumpf 1.185 // ProviderMessageHandler wrapper for the control providers. Deleting
|
538 kumpf 1.175 // the ProviderManagerService after the control providers is a
539 // workaround for this problem.
540 delete _providerManager;
541
542 delete _providerRegistrationManager;
|
543 konrad.r 1.171
|
544 kumpf 1.175 // Almost everybody uses the CIMRepository.
545 delete _repository;
|
546 kumpf 1.99
|
547 kumpf 1.175 // Destroy the singleton services
548 ConfigManager::destroy();
549 UserManager::destroy();
550 ShutdownService::destroy();
|
551 konrad.r 1.172
|
552 kumpf 1.175 PEG_METHOD_EXIT ();
|
553 mike 1.43 }
554
|
555 kumpf 1.101 void CIMServer::addAcceptor(
556 Boolean localConnection,
557 Uint32 portNumber,
|
558 sushma.fernandes 1.189 Boolean useSSL)
|
559 kumpf 1.101 {
560 HTTPAcceptor* acceptor;
|
561 sushma.fernandes 1.189
562 acceptor = new HTTPAcceptor(
|
563 nag.boranna 1.161 _monitor,
564 _httpAuthenticatorDelegator,
565 localConnection,
566 portNumber,
|
567 sushma.fernandes 1.189 useSSL ? _getSSLContext() : 0,
|
568 nag.boranna 1.164 useSSL ? _sslContextMgr->getSSLContextObjectLock() : 0 );
|
569 marek 1.180
570 ConfigManager* configManager = ConfigManager::getInstance();
571 String socketWriteConfigTimeout =
572 configManager->getCurrentValue("socketWriteTimeout");
573 // Set timeout value for server socket timeouts
574 // depending on config option
575 Uint32 socketWriteTimeout =
576 strtol(socketWriteConfigTimeout.getCString(), (char **)0, 10);
577 // equal what went wrong, there has to be a timeout
578 if (socketWriteTimeout == 0) socketWriteTimeout = 20;
579 acceptor->setSocketWriteTimeout(socketWriteTimeout);
580
|
581 kumpf 1.101 _acceptors.append(acceptor);
582 }
583
584 void CIMServer::bind()
|
585 mike 1.43 {
|
586 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::bind()");
|
587 kumpf 1.54
|
588 kumpf 1.157 if (_acceptors.size() == 0)
589 {
590 MessageLoaderParms mlp = MessageLoaderParms(
591 "Server.CIMServer.BIND_FAILED",
592 "No CIM Server connections are enabled.");
|
593 chip 1.112
|
594 kumpf 1.157 throw BindFailedException(mlp);
595 }
|
596 chip 1.112
|
597 kumpf 1.157 for (Uint32 i=0; i<_acceptors.size(); i++)
598 {
599 _acceptors[i]->bind();
|
600 kumpf 1.101 }
|
601 chip 1.112
|
602 kumpf 1.75 PEG_METHOD_EXIT();
|
603 mike 1.43 }
604
605 void CIMServer::runForever()
606 {
|
607 mday 1.111 // Note: Trace code in this method will be invoked frequently.
608 if(!_dieNow)
|
609 kumpf 1.157 {
|
610 a.arora 1.143 #ifdef PEGASUS_ENABLE_SLP
|
611 nag.boranna 1.161 // Note - this func prevents multiple starting of slp provider
612 startSLPProvider();
|
613 a.arora 1.143 #endif
614
|
615 kumpf 1.186 _monitor->run(500000);
616
617 static struct timeval lastIdleCleanupTime = {0, 0};
618 struct timeval now;
|
619 kumpf 1.188 Time::gettimeofday(&now);
|
620 mreddy 1.190.2.2
621 #ifdef PEGASUS_SLP_REG_TIMEOUT
622 static struct timeval lastReregistrationTime = {0, 0};
623 const char * reRegTime = getenv("PEG_SLP_REG_TIMEOUT");
624 if (now.tv_sec - lastReregistrationTime.tv_sec > (atoi(reRegTime) * 60))
625 {
626 lastReregistrationTime.tv_sec = now.tv_sec;
627 startSLPProvider();
628 }
629 #endif
630
|
631 mreddy 1.190.2.1 if (now.tv_sec - lastIdleCleanupTime.tv_sec >= 100)
|
632 nag.boranna 1.161 {
|
633 kumpf 1.186 lastIdleCleanupTime.tv_sec = now.tv_sec;
|
634 nag.boranna 1.161 try
635 {
636 _providerManager->unloadIdleProviders();
|
637 kumpf 1.190 MessageQueueService::get_thread_pool()->cleanupIdleThreads();
|
638 nag.boranna 1.161 }
639 catch(...)
640 {
641 }
642 }
643 if (handleShutdownSignal)
644 {
645 Tracer::trace(TRC_SERVER, Tracer::LEVEL3,
646 "CIMServer::runForever - signal received. Shutting down.");
647 ShutdownService::getInstance(this)->shutdown(true, 10, false);
648 // Set to false must be after call to shutdown. See
649 // stopClientConnection.
650 handleShutdownSignal = false;
651 }
|
652 kumpf 1.157 }
|
653 mike 1.50 }
|
654 mday 1.118
|
655 mike 1.50 void CIMServer::stopClientConnection()
656 {
|
657 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::stopClientConnection()");
|
658 kumpf 1.54
|
659 kumpf 1.157 // tell Monitor to stop listening for client connections
660 if (handleShutdownSignal)
661 // If shutting down, this is in the same thread as runForever.
662 // No need to wait for the thread to see the stop flag.
663 _monitor->stopListeningForConnections(false);
664 else
665 // If not shutting down, this is not in the same thread as runForever.
666 // Need to wait for the thread to see the stop flag.
667 _monitor->stopListeningForConnections(true);
668
669 //
670 // Wait 150 milliseconds to allow time for the Monitor to stop
671 // listening for client connections.
672 //
673 // This wait time is the timeout value for the select() call
674 // in the Monitor's run() method (currently set to 100
675 // milliseconds) plus a delta of 50 milliseconds. The reason
676 // for the wait here is to make sure that the Monitor entries
677 // are updated before closing the connection sockets.
678 //
679 // PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4, "Wait 150 milliseconds.");
|
680 mike 1.183 // Threads::sleep(150); not needed anymore due to the semaphore
|
681 kumpf 1.157 // in the monitor
682
683 for (Uint32 i=0; i<_acceptors.size(); i++)
|
684 kumpf 1.117 {
|
685 kumpf 1.157 _acceptors[i]->closeConnectionSocket();
|
686 kumpf 1.101 }
|
687 chip 1.112
|
688 kumpf 1.75 PEG_METHOD_EXIT();
|
689 mike 1.50 }
690
691 void CIMServer::shutdown()
692 {
|
693 mreddy 1.190.2.1 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdown()");
|
694 dave.sudlik 1.176 #ifdef PEGASUS_DEBUG
695 _repository->DisplayCacheStatistics();
696 #endif
697
|
698 mike 1.50 _dieNow = true;
|
699 kumpf 1.157 _cimserver->tickle_monitor();
|
700 kumpf 1.54
|
701 kumpf 1.75 PEG_METHOD_EXIT();
|
702 mike 1.50 }
703
704 void CIMServer::resume()
705 {
|
706 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::resume()");
|
707 kumpf 1.54
|
708 kumpf 1.101 for (Uint32 i=0; i<_acceptors.size(); i++)
709 {
710 _acceptors[i]->reopenConnectionSocket();
711 }
|
712 kumpf 1.54
|
713 kumpf 1.75 PEG_METHOD_EXIT();
|
714 mike 1.50 }
715
716 void CIMServer::setState(Uint32 state)
717 {
|
718 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::setState()");
|
719 kumpf 1.54
|
720 mike 1.50 _serverState->setState(state);
|
721 chip 1.53
|
722 kumpf 1.85 //
723 // get the configured authentication and authorization flags
724 //
725 ConfigManager* configManager = ConfigManager::getInstance();
726
|
727 kumpf 1.182 Boolean enableAuthentication = ConfigManager::parseBooleanValue(
728 configManager->getCurrentValue("enableAuthentication"));
729 Boolean enableNamespaceAuthorization = ConfigManager::parseBooleanValue(
730 configManager->getCurrentValue("enableNamespaceAuthorization"));
|
731 kumpf 1.85
|
732 mike 1.50 if (state == CIMServerState::TERMINATING)
733 {
734 // tell decoder that CIMServer is terminating
735 _cimOperationRequestDecoder->setServerTerminating(true);
736 _cimExportRequestDecoder->setServerTerminating(true);
|
737 kumpf 1.85
738 // tell authorizer that CIMServer is terminating ONLY if
739 // authentication and authorization are enabled
740 //
|
741 kumpf 1.87 if ( enableAuthentication && enableNamespaceAuthorization )
|
742 kumpf 1.85 {
743 _cimOperationRequestAuthorizer->setServerTerminating(true);
744 }
|
745 mike 1.50 }
746 else
747 {
748 // tell decoder that CIMServer is not terminating
749 _cimOperationRequestDecoder->setServerTerminating(false);
750 _cimExportRequestDecoder->setServerTerminating(false);
|
751 kumpf 1.85
752 // tell authorizer that CIMServer is terminating ONLY if
753 // authentication and authorization are enabled
754 //
|
755 kumpf 1.87 if ( enableAuthentication && enableNamespaceAuthorization )
|
756 kumpf 1.85 {
757 _cimOperationRequestAuthorizer->setServerTerminating(false);
758 }
|
759 mike 1.50 }
|
760 kumpf 1.75 PEG_METHOD_EXIT();
|
761 mike 1.50 }
762
763 Uint32 CIMServer::getOutstandingRequestCount()
764 {
|
765 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::getOutstandingRequestCount()");
|
766 kumpf 1.54
|
767 kumpf 1.101 Uint32 requestCount = 0;
|
768 mday 1.111
|
769 kumpf 1.157 for (Uint32 i=0; i<_acceptors.size(); i++)
770 {
771 requestCount += _acceptors[i]->getOutstandingRequestCount();
|
772 kumpf 1.101 }
|
773 chip 1.112
|
774 kumpf 1.75 PEG_METHOD_EXIT();
775 return requestCount;
|
776 kumpf 1.101 }
777
|
778 nag.boranna 1.163 //
|
779 sushma.fernandes 1.189 SSLContext* CIMServer::_getSSLContext()
|
780 nag.boranna 1.163 {
781 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_getSSLContext()");
782
783 static const String PROPERTY_NAME__SSL_CERT_FILEPATH =
784 "sslCertificateFilePath";
785 static const String PROPERTY_NAME__SSL_KEY_FILEPATH = "sslKeyFilePath";
786 static const String PROPERTY_NAME__SSL_TRUST_STORE = "sslTrustStore";
787 static const String PROPERTY_NAME__SSL_CRL_STORE = "crlStore";
788 static const String PROPERTY_NAME__SSL_CLIENT_VERIFICATION =
789 "sslClientVerificationMode";
790 static const String PROPERTY_NAME__SSL_AUTO_TRUST_STORE_UPDATE =
791 "enableSSLTrustStoreAutoUpdate";
792 static const String PROPERTY_NAME__SSL_TRUST_STORE_USERNAME =
793 "sslTrustStoreUserName";
794 static const String PROPERTY_NAME__HTTP_ENABLED =
795 "enableHttpConnection";
796
797 String verifyClient = String::EMPTY;
798 String trustStore = String::EMPTY;
799 SSLContext* sslContext = 0;
800
801 nag.boranna 1.163 //
802 // Get a config manager instance
803 //
804 ConfigManager* configManager = ConfigManager::getInstance();
805
|
806 sushma.fernandes 1.189 // Note that if invalid values were set for either sslKeyFilePath,
807 // sslCertificateFilePath, crlStore or sslTrustStore, the invalid
808 // paths would have been detected in SecurityPropertyOwner and
809 // terminated the server startup. This happens regardless of whether
810 // or not HTTPS is enabled (not a great design, but that seems to
811 // be how other properties are validated as well)
812 //
813 // Get the sslClientVerificationMode property from the Config
814 // Manager.
815 //
816 verifyClient = configManager->getCurrentValue(
817 PROPERTY_NAME__SSL_CLIENT_VERIFICATION);
818
819 //
820 // Get the sslTrustStore property from the Config Manager.
821 //
822 trustStore = configManager->getCurrentValue(
823 PROPERTY_NAME__SSL_TRUST_STORE);
824
825 if (trustStore != String::EMPTY)
|
826 nag.boranna 1.163 {
|
827 sushma.fernandes 1.189 trustStore = ConfigManager::getHomedPath(trustStore);
828 }
|
829 nag.boranna 1.163
|
830 sushma.fernandes 1.189 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4,
831 "Server trust store name: " + trustStore);
|
832 nag.boranna 1.163
|
833 sushma.fernandes 1.189 //
834 // Get the sslTrustStoreUserName property from the Config Manager.
835 //
836 String trustStoreUserName = String::EMPTY;
837 trustStoreUserName = configManager->getCurrentValue(
838 PROPERTY_NAME__SSL_TRUST_STORE_USERNAME);
|
839 nag.boranna 1.163
|
840 sushma.fernandes 1.189 if (!String::equal(verifyClient, "disabled"))
841 {
|
842 nag.boranna 1.163 //
|
843 sushma.fernandes 1.189 // 'required' setting must have a valid truststore
844 // 'optional' setting can be used with or without a truststore;
845 // log a warning if a truststore is not specified
|
846 nag.boranna 1.163 //
|
847 sushma.fernandes 1.189 if (trustStore == String::EMPTY)
|
848 nag.boranna 1.163 {
|
849 sushma.fernandes 1.189 if (String::equal(verifyClient, "required"))
850 {
851 MessageLoaderParms parms(
852 "Pegasus.Server.CIMServer.SSL_CLIENT_VERIFICATION_EMPTY_TRUSTSTORE",
853 "The \"sslTrustStore\" configuration property must be set if \"sslClientVerificationMode\" is 'required'. cimserver not started.");
854 PEG_METHOD_EXIT();
855 throw SSLException(parms);
856 }
857 else if (String::equal(verifyClient, "optional"))
|
858 nag.boranna 1.163 {
|
859 sushma.fernandes 1.189 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
860 Logger::WARNING,
861 "SSL client verification is enabled but no truststore was specified.");
|
862 nag.boranna 1.163 }
|
863 sushma.fernandes 1.189 }
|
864 h.sterling 1.165
|
865 h.sterling 1.168 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
866 sushma.fernandes 1.189 //
867 // ATTN: 'required' setting must have http port enabled.
868 // If only https is enabled, and a call to shutdown the
869 // cimserver is given, the call will hang and a forced shutdown
870 // will ensue. This is because the CIMClient::connectLocal call
871 // cannot specify a certificate for authentication against
872 // the local server. This limitation is being investigated.
873 // See Bugzilla 2995.
874 //
875 if (String::equal(verifyClient, "required"))
876 {
877 if (!ConfigManager::parseBooleanValue(
878 configManager->getCurrentValue(
879 PROPERTY_NAME__HTTP_ENABLED)))
|
880 nag.boranna 1.163 {
|
881 sushma.fernandes 1.189 MessageLoaderParms parms(
882 "Pegasus.Server.SSLContextManager.INVALID_CONF_HTTPS_REQUIRED",
883 "The \"sslClientVerificationMode\" property cannot be "
884 "set to \"required\" if HTTP is disabled, as the "
885 "cimserver will be unable to properly shutdown. "
886 "The recommended course of action is to change "
887 "the property value to \"optional\". cimserver "
888 "not started.");
889 PEG_METHOD_EXIT();
890 throw SSLException(parms);
|
891 nag.boranna 1.163 }
|
892 sushma.fernandes 1.189 }
|
893 h.sterling 1.165 #endif
|
894 nag.boranna 1.163 //
|
895 sushma.fernandes 1.189 // A truststore username must be specified if
896 // sslClientVerificationMode is enabled and the truststore is a
897 // single CA file. If the truststore is a directory, then the
898 // CertificateProvider should be used to register users with
899 // certificates.
|
900 nag.boranna 1.163 //
|
901 sushma.fernandes 1.189 if ((trustStore != String::EMPTY) &&
902 (!FileSystem::isDirectory(trustStore)))
|
903 nag.boranna 1.163 {
|
904 sushma.fernandes 1.189 if (trustStoreUserName == String::EMPTY)
905 {
906 MessageLoaderParms parms(
907 "Pegasus.Server.CIMServer.SSL_CLIENT_VERIFICATION_EMPTY_USERNAME",
908 "The \"sslTrustStoreUserName\" property must specify a valid username if \"sslClientVerificationMode\" is 'required' or 'optional' and the truststore is a single CA file. To register individual certificates to users, you must use a truststore directory along with the CertificateProvider. cimserver not started.");
909 PEG_METHOD_EXIT();
910 throw SSLException(parms);
911 }
|
912 nag.boranna 1.163 }
913 }
914
|
915 sushma.fernandes 1.178 #ifdef PEGASUS_ENABLE_SSL_CRL_VERIFICATION
|
916 nag.boranna 1.163 //
917 // Get the crlStore property from the Config Manager.
918 //
919 String crlStore = configManager->getCurrentValue(
920 PROPERTY_NAME__SSL_CRL_STORE);
921
922 if (crlStore != String::EMPTY)
923 {
924 crlStore = ConfigManager::getHomedPath(crlStore);
925 }
|
926 sushma.fernandes 1.178 #else
927 String crlStore = String::EMPTY;
928 #endif
|
929 nag.boranna 1.163
930 //
931 // Get the sslCertificateFilePath property from the Config Manager.
932 //
933 String certPath;
934 certPath = ConfigManager::getHomedPath(
935 configManager->getCurrentValue(PROPERTY_NAME__SSL_CERT_FILEPATH));
936
937 //
938 // Get the sslKeyFilePath property from the Config Manager.
939 //
940 String keyPath;
941 keyPath = ConfigManager::getHomedPath(
942 configManager->getCurrentValue(PROPERTY_NAME__SSL_KEY_FILEPATH));
943
944 String randFile = String::EMPTY;
945
946 #ifdef PEGASUS_SSL_RANDOMFILE
947 // NOTE: It is technically not necessary to set up a random file on
948 // the server side, but it is easier to use a consistent interface
949 // on the client and server than to optimize out the random file on
950 nag.boranna 1.163 // the server side.
951 randFile = ConfigManager::getHomedPath(PEGASUS_SSLSERVER_RANDOMFILE);
952 #endif
953
|
954 sushma.fernandes 1.189 //
955 // Create the SSLContext defined by the configuration properties
956 //
957 if (String::equal(verifyClient, "required"))
|
958 nag.boranna 1.163 {
|
959 sushma.fernandes 1.189 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
960 "SSL Client verification REQUIRED.");
|
961 nag.boranna 1.163
|
962 sushma.fernandes 1.189 _sslContextMgr->createSSLContext(
963 trustStore, certPath, keyPath, crlStore, false, randFile);
964 }
965 else if (String::equal(verifyClient, "optional"))
966 {
967 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
968 "SSL Client verification OPTIONAL.");
|
969 nag.boranna 1.163
|
970 sushma.fernandes 1.189 _sslContextMgr->createSSLContext(
971 trustStore, certPath, keyPath, crlStore, true, randFile);
|
972 nag.boranna 1.163 }
|
973 sushma.fernandes 1.189 else if (String::equal(verifyClient, "disabled") ||
974 verifyClient == String::EMPTY)
|
975 nag.boranna 1.163 {
|
976 sushma.fernandes 1.189 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
977 "SSL Client verification DISABLED.");
|
978 nag.boranna 1.163
|
979 sushma.fernandes 1.189 _sslContextMgr->createSSLContext(
980 String::EMPTY, certPath, keyPath, crlStore, false, randFile);
|
981 nag.boranna 1.163 }
|
982 sushma.fernandes 1.189 sslContext = _sslContextMgr->getSSLContext();
|
983 nag.boranna 1.163
984 PEG_METHOD_EXIT();
985 return sslContext;
986 }
|
987 h.sterling 1.130
|
988 tony 1.134 #ifdef PEGASUS_ENABLE_SLP
|
989 mike 1.183 ThreadReturnType PEGASUS_THREAD_CDECL _callSLPProvider(void *parm);
|
990 tony 1.134
991
992 // This is a control function that starts a new thread which issues a
993 // cim operation to start the slp provider.
994 void CIMServer::startSLPProvider()
995 {
996
997 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "CIMServer::startSLPProvider");
998
|
999 mreddy 1.190.2.1 // onetime check is not needed for re-registration.
1000 //if(!reRegister)
|
1001 tony 1.134 {
|
1002 mreddy 1.190.2.1 // This is a onetime function. If already issued, or config is not to use simply
1003 // return
1004 if (!_runSLP)
1005 {
1006 return;
1007 }
|
1008 tony 1.134
|
1009 mreddy 1.190.2.1 // Get Config parameter to determine if we should start SLP.
1010 ConfigManager* configManager = ConfigManager::getInstance();
1011 _runSLP = ConfigManager::parseBooleanValue(
1012 configManager->getCurrentValue("slp"));
1013
1014 // If false, do not start slp provider
1015 if (!_runSLP)
1016 {
1017 return;
1018 }
1019 //SLP startup is onetime function; reset the switch so this
1020 // function does not get called a second time.
1021 _runSLP = false;
1022 }
1023 // Start SLPProvider for Built-in SA and Open SLP SA. if the PEGASUS_SLP_REG_TIMEOUT is defined
1024 // start a thread which advertises CIMOM with a external SLP SA.
1025 #ifdef PEGASUS_SLP_REG_TIMEOUT
1026 _startAdvThread = true;
1027 Thread SLPThread(_advertisePegasus,0,true);
1028 SLPThread.run();
1029 #else
|
1030 tony 1.134 // Create a separate thread, detach and call function to execute the startup.
1031 Thread t( _callSLPProvider, 0, true );
1032 t.run();
|
1033 mreddy 1.190.2.1 #endif
|
1034 tony 1.134
1035 PEG_METHOD_EXIT();
1036 return;
1037 }
1038
1039
1040 // startSLPProvider is a function to get the slp provider kicked off
1041 // during startup. It is placed in the provider manager simply because
1042 // the provider manager is the only component of the system is
1043 // driven by a timer after startup. It should never be here and must be
1044 // moved to somewhere more logical or really replaced. We simply needed
1045 // something that was run shortly after system startup.
1046 // This function is assumed to operate in a separate thread and
1047 // KS 15 February 2004.
1048
|
1049 mike 1.183 ThreadReturnType PEGASUS_THREAD_CDECL _callSLPProvider(void* parm )
|
1050 tony 1.134 {
1051 //
1052 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_callSLPProvider()");
1053 // Create CIMClient object
1054 //
1055 CIMClient client;
1056 //
1057 // open connection to CIMOM
1058 //
1059 String hostStr = System::getHostName();
1060
1061 try
1062 {
1063 //
1064 client.connectLocal();
1065
1066 //
1067 // set client timeout to 2 seconds
1068 //
1069 client.setTimeout(40000);
1070 // construct CIMObjectPath
1071 tony 1.134 //
1072 String referenceStr = "//";
1073 referenceStr.append(hostStr);
1074 referenceStr.append("/");
1075 referenceStr.append(PEGASUS_NAMESPACENAME_INTERNAL.getString());
1076 referenceStr.append(":");
1077 referenceStr.append(PEGASUS_CLASSNAME_WBEMSLPTEMPLATE.getString());
1078 CIMObjectPath reference(referenceStr);
1079
1080 //
1081 // issue the invokeMethod request on the register method
1082 //
1083 Array<CIMParamValue> inParams;
1084 Array<CIMParamValue> outParams;
1085
1086 CIMValue retValue = client.invokeMethod(
1087 PEGASUS_NAMESPACENAME_INTERNAL,
1088 reference,
1089 CIMName("register"),
1090 inParams,
1091 outParams
1092 tony 1.134 );
1093 }
1094
1095 catch(CIMException& e)
1096 {
1097 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1098 "SLP Registration Failed. CIMException. $0", e.getMessage());
1099 }
1100
1101 catch(Exception& e)
1102 {
1103 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1104 "SLP Registration Failed Startup: CIMServer exception. $0", e.getMessage());
1105 }
1106
1107 client.disconnect();
1108
1109 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1110 "SLP Registration Initiated");
1111
1112 PEG_METHOD_EXIT();
|
1113 mike 1.183 return( (ThreadReturnType)32 );
|
1114 tony 1.134 }
1115
|
1116 mreddy 1.190.2.1 // This thread advertises pegasus to a listening SA. The attributes for
1117 // the Pegasus advertisement is obtained from CIM classes with the help
1118 // of SLPAttrib class methods.
1119 ThreadReturnType PEGASUS_THREAD_CDECL _advertisePegasus(void* parm)
1120 {
|
1121 tony 1.134
|
1122 mreddy 1.190.2.1 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_advertisePegasus()");
|
1123 tony 1.134
|
1124 mreddy 1.190.2.1 static SLPAttrib SLPHttpAttribObj;
1125 static SLPAttrib SLPHttpsAttribObj;
1126 struct slp_client *client;
1127 time_t now,last;
1128 lslpMsg msg_list;
1129 char *scopes;
1130 Uint16 life = MAX_LIFE, port=SLP_PORT;
1131 char *addr = strdup(LOCALHOST_IP);
1132 char *type = (char *)NULL;;
1133 char *iface = NULL;
1134 char *httpUrl = (char *)NULL;;
1135 char *httpsUrl = (char *)NULL;;
1136 char *httpAttrs = (char *)NULL;
1137 char *httpsAttrs = (char *)NULL;
1138
1139 if (!handleCloseSLPThread)
1140 {
1141 // Comes here only if the cimserver is not terminated.
1142 // Get all the SLP attributes and data for the Pegasus cimserver.
1143 SLPHttpAttribObj.fillData("http");
1144 SLPHttpsAttribObj.fillData("https");
1145 mreddy 1.190.2.1 SLPHttpAttribObj.formAttributes();
1146 SLPHttpsAttribObj.formAttributes();
1147 }
1148
1149 scopes = strdup("DEFAULT");
1150
1151 type = strdup(SLPHttpAttribObj.getServiceType().getCString());
1152 httpUrl = strdup(SLPHttpAttribObj.getServiceUrl().getCString());
1153 httpsUrl = strdup(SLPHttpsAttribObj.getServiceUrl().getCString());
1154 httpAttrs = strdup(SLPHttpAttribObj.getAttributes().getCString());
1155 httpsAttrs = strdup(SLPHttpsAttribObj.getAttributes().getCString());
1156 if(NULL != (client = create_slp_client(addr,
1157 iface,
1158 SLP_PORT,
1159 "DSA",
1160 scopes,
1161 FALSE,
1162 FALSE)))
1163 {
1164 if (!handleCloseSLPThread)
1165 {
1166 mreddy 1.190.2.1 client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, life);
1167 client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes, life);
1168 }
1169 destroy_slp_client(client);
1170 }
1171
1172 if(type != NULL)
1173 free(type);
1174 if(httpUrl != NULL)
1175 free(httpUrl);
1176 if(httpsUrl != NULL)
1177 free(httpsUrl);
1178 if(httpAttrs != NULL)
1179 free(httpAttrs);
1180 if(httpsAttrs != NULL)
1181 free(httpsAttrs);
1182 if(addr != NULL)
1183 free(addr);
1184 if(scopes != NULL)
1185 free(scopes);
1186 if(iface != NULL)
1187 mreddy 1.190.2.1 free(iface);
|
1188 h.sterling 1.150
|
1189 mreddy 1.190.2.1 PEG_METHOD_EXIT();
1190 return( (ThreadReturnType)32 );
1191 }
1192
1193 // This routine deregisters the CIM Server registration with external SLP SA.
1194
1195 int _deregPegasus()
1196 {
1197
1198 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::deregPegasus()");
1199
1200 static SLPAttrib SLPHttpAttribObj1;
1201 static SLPAttrib SLPHttpsAttribObj1;
1202 struct slp_client *client;
1203 time_t now,last;
1204 lslpMsg msg_list;
1205 char *scopes;
1206 Uint16 life = MAX_LIFE, port=SLP_PORT;
1207 char *addr = strdup(LOCALHOST_IP);
1208 char *type = (char *)NULL;;
1209 char *iface = NULL;
1210 mreddy 1.190.2.1 char *httpUrl = (char *)NULL;;
1211 char *httpsUrl = (char *)NULL;;
1212 char *httpAttrs = (char *)NULL;
1213 char *httpsAttrs = (char *)NULL;
1214
1215
1216 // Get all the SLP attributes and data for the Pegasus cimserver.
1217 SLPHttpAttribObj1.fillData("http");
1218 SLPHttpsAttribObj1.fillData("https");
1219 SLPHttpAttribObj1.formAttributes();
1220 SLPHttpsAttribObj1.formAttributes();
1221
1222 scopes = strdup("DEFAULT");
1223
1224 type = strdup(SLPHttpAttribObj1.getServiceType().getCString());
1225 httpUrl = strdup(SLPHttpAttribObj1.getServiceUrl().getCString());
1226 httpsUrl = strdup(SLPHttpsAttribObj1.getServiceUrl().getCString());
1227 httpAttrs = strdup(SLPHttpAttribObj1.getAttributes().getCString());
1228 httpsAttrs = strdup(SLPHttpsAttribObj1.getAttributes().getCString());
1229 if(NULL != (client = create_slp_client(addr,
1230 iface,
1231 mreddy 1.190.2.1 SLP_PORT,
1232 "DSA",
1233 scopes,
1234 FALSE,
1235 FALSE)))
1236 {
1237 client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, 0);
1238 client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes,0);
1239 destroy_slp_client(client);
1240 }
1241 if(type != NULL)
1242 free(type);
1243 if(httpUrl != NULL)
1244 free(httpUrl);
1245 if(httpsUrl != NULL)
1246 free(httpsUrl);
1247 if(httpAttrs != NULL)
1248 free(httpAttrs);
1249 if(httpsAttrs != NULL)
1250 free(httpsAttrs);
1251 if(addr != NULL)
1252 mreddy 1.190.2.1 free(addr);
1253 if(scopes != NULL)
1254 free(scopes);
1255 if(iface != NULL)
1256 free(iface);
1257
1258 PEG_METHOD_EXIT();
1259 return( 32 );
1260 }
1261 #endif
1262 PEGASUS_NAMESPACE_END
|