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 mreddy 1.190.2.4 if (now.tv_sec - lastReregistrationTime.tv_sec > (PEGASUS_SLP_REG_TIMEOUT * 60))
|
624 mreddy 1.190.2.2 {
625 lastReregistrationTime.tv_sec = now.tv_sec;
626 startSLPProvider();
627 }
628 #endif
629
|
630 mreddy 1.190.2.1 if (now.tv_sec - lastIdleCleanupTime.tv_sec >= 100)
|
631 nag.boranna 1.161 {
|
632 kumpf 1.186 lastIdleCleanupTime.tv_sec = now.tv_sec;
|
633 nag.boranna 1.161 try
634 {
635 _providerManager->unloadIdleProviders();
|
636 kumpf 1.190 MessageQueueService::get_thread_pool()->cleanupIdleThreads();
|
637 nag.boranna 1.161 }
638 catch(...)
639 {
640 }
641 }
642 if (handleShutdownSignal)
643 {
644 Tracer::trace(TRC_SERVER, Tracer::LEVEL3,
645 "CIMServer::runForever - signal received. Shutting down.");
646 ShutdownService::getInstance(this)->shutdown(true, 10, false);
647 // Set to false must be after call to shutdown. See
648 // stopClientConnection.
649 handleShutdownSignal = false;
650 }
|
651 kumpf 1.157 }
|
652 mike 1.50 }
|
653 mday 1.118
|
654 mike 1.50 void CIMServer::stopClientConnection()
655 {
|
656 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::stopClientConnection()");
|
657 kumpf 1.54
|
658 kumpf 1.157 // tell Monitor to stop listening for client connections
659 if (handleShutdownSignal)
660 // If shutting down, this is in the same thread as runForever.
661 // No need to wait for the thread to see the stop flag.
662 _monitor->stopListeningForConnections(false);
663 else
664 // If not shutting down, this is not in the same thread as runForever.
665 // Need to wait for the thread to see the stop flag.
666 _monitor->stopListeningForConnections(true);
667
668 //
669 // Wait 150 milliseconds to allow time for the Monitor to stop
670 // listening for client connections.
671 //
672 // This wait time is the timeout value for the select() call
673 // in the Monitor's run() method (currently set to 100
674 // milliseconds) plus a delta of 50 milliseconds. The reason
675 // for the wait here is to make sure that the Monitor entries
676 // are updated before closing the connection sockets.
677 //
678 // PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4, "Wait 150 milliseconds.");
|
679 mike 1.183 // Threads::sleep(150); not needed anymore due to the semaphore
|
680 kumpf 1.157 // in the monitor
681
682 for (Uint32 i=0; i<_acceptors.size(); i++)
|
683 kumpf 1.117 {
|
684 kumpf 1.157 _acceptors[i]->closeConnectionSocket();
|
685 kumpf 1.101 }
|
686 chip 1.112
|
687 kumpf 1.75 PEG_METHOD_EXIT();
|
688 mike 1.50 }
689
690 void CIMServer::shutdown()
691 {
|
692 mreddy 1.190.2.1 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::shutdown()");
|
693 dave.sudlik 1.176 #ifdef PEGASUS_DEBUG
694 _repository->DisplayCacheStatistics();
695 #endif
696
|
697 mike 1.50 _dieNow = true;
|
698 kumpf 1.157 _cimserver->tickle_monitor();
|
699 kumpf 1.54
|
700 kumpf 1.75 PEG_METHOD_EXIT();
|
701 mike 1.50 }
702
703 void CIMServer::resume()
704 {
|
705 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::resume()");
|
706 kumpf 1.54
|
707 kumpf 1.101 for (Uint32 i=0; i<_acceptors.size(); i++)
708 {
709 _acceptors[i]->reopenConnectionSocket();
710 }
|
711 kumpf 1.54
|
712 kumpf 1.75 PEG_METHOD_EXIT();
|
713 mike 1.50 }
714
715 void CIMServer::setState(Uint32 state)
716 {
|
717 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::setState()");
|
718 kumpf 1.54
|
719 mike 1.50 _serverState->setState(state);
|
720 chip 1.53
|
721 kumpf 1.85 //
722 // get the configured authentication and authorization flags
723 //
724 ConfigManager* configManager = ConfigManager::getInstance();
725
|
726 kumpf 1.182 Boolean enableAuthentication = ConfigManager::parseBooleanValue(
727 configManager->getCurrentValue("enableAuthentication"));
728 Boolean enableNamespaceAuthorization = ConfigManager::parseBooleanValue(
729 configManager->getCurrentValue("enableNamespaceAuthorization"));
|
730 kumpf 1.85
|
731 mike 1.50 if (state == CIMServerState::TERMINATING)
732 {
733 // tell decoder that CIMServer is terminating
734 _cimOperationRequestDecoder->setServerTerminating(true);
735 _cimExportRequestDecoder->setServerTerminating(true);
|
736 kumpf 1.85
737 // tell authorizer that CIMServer is terminating ONLY if
738 // authentication and authorization are enabled
739 //
|
740 kumpf 1.87 if ( enableAuthentication && enableNamespaceAuthorization )
|
741 kumpf 1.85 {
742 _cimOperationRequestAuthorizer->setServerTerminating(true);
743 }
|
744 mike 1.50 }
745 else
746 {
747 // tell decoder that CIMServer is not terminating
748 _cimOperationRequestDecoder->setServerTerminating(false);
749 _cimExportRequestDecoder->setServerTerminating(false);
|
750 kumpf 1.85
751 // tell authorizer that CIMServer is terminating ONLY if
752 // authentication and authorization are enabled
753 //
|
754 kumpf 1.87 if ( enableAuthentication && enableNamespaceAuthorization )
|
755 kumpf 1.85 {
756 _cimOperationRequestAuthorizer->setServerTerminating(false);
757 }
|
758 mike 1.50 }
|
759 kumpf 1.75 PEG_METHOD_EXIT();
|
760 mike 1.50 }
761
762 Uint32 CIMServer::getOutstandingRequestCount()
763 {
|
764 kumpf 1.75 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::getOutstandingRequestCount()");
|
765 kumpf 1.54
|
766 kumpf 1.101 Uint32 requestCount = 0;
|
767 mday 1.111
|
768 kumpf 1.157 for (Uint32 i=0; i<_acceptors.size(); i++)
769 {
770 requestCount += _acceptors[i]->getOutstandingRequestCount();
|
771 kumpf 1.101 }
|
772 chip 1.112
|
773 kumpf 1.75 PEG_METHOD_EXIT();
774 return requestCount;
|
775 kumpf 1.101 }
776
|
777 nag.boranna 1.163 //
|
778 sushma.fernandes 1.189 SSLContext* CIMServer::_getSSLContext()
|
779 nag.boranna 1.163 {
780 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_getSSLContext()");
781
782 static const String PROPERTY_NAME__SSL_CERT_FILEPATH =
783 "sslCertificateFilePath";
784 static const String PROPERTY_NAME__SSL_KEY_FILEPATH = "sslKeyFilePath";
785 static const String PROPERTY_NAME__SSL_TRUST_STORE = "sslTrustStore";
786 static const String PROPERTY_NAME__SSL_CRL_STORE = "crlStore";
787 static const String PROPERTY_NAME__SSL_CLIENT_VERIFICATION =
788 "sslClientVerificationMode";
789 static const String PROPERTY_NAME__SSL_AUTO_TRUST_STORE_UPDATE =
790 "enableSSLTrustStoreAutoUpdate";
791 static const String PROPERTY_NAME__SSL_TRUST_STORE_USERNAME =
792 "sslTrustStoreUserName";
793 static const String PROPERTY_NAME__HTTP_ENABLED =
794 "enableHttpConnection";
795
796 String verifyClient = String::EMPTY;
797 String trustStore = String::EMPTY;
798 SSLContext* sslContext = 0;
799
800 nag.boranna 1.163 //
801 // Get a config manager instance
802 //
803 ConfigManager* configManager = ConfigManager::getInstance();
804
|
805 sushma.fernandes 1.189 // Note that if invalid values were set for either sslKeyFilePath,
806 // sslCertificateFilePath, crlStore or sslTrustStore, the invalid
807 // paths would have been detected in SecurityPropertyOwner and
808 // terminated the server startup. This happens regardless of whether
809 // or not HTTPS is enabled (not a great design, but that seems to
810 // be how other properties are validated as well)
811 //
812 // Get the sslClientVerificationMode property from the Config
813 // Manager.
814 //
815 verifyClient = configManager->getCurrentValue(
816 PROPERTY_NAME__SSL_CLIENT_VERIFICATION);
817
818 //
819 // Get the sslTrustStore property from the Config Manager.
820 //
821 trustStore = configManager->getCurrentValue(
822 PROPERTY_NAME__SSL_TRUST_STORE);
823
824 if (trustStore != String::EMPTY)
|
825 nag.boranna 1.163 {
|
826 sushma.fernandes 1.189 trustStore = ConfigManager::getHomedPath(trustStore);
827 }
|
828 nag.boranna 1.163
|
829 sushma.fernandes 1.189 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL4,
830 "Server trust store name: " + trustStore);
|
831 nag.boranna 1.163
|
832 sushma.fernandes 1.189 //
833 // Get the sslTrustStoreUserName property from the Config Manager.
834 //
835 String trustStoreUserName = String::EMPTY;
836 trustStoreUserName = configManager->getCurrentValue(
837 PROPERTY_NAME__SSL_TRUST_STORE_USERNAME);
|
838 nag.boranna 1.163
|
839 sushma.fernandes 1.189 if (!String::equal(verifyClient, "disabled"))
840 {
|
841 nag.boranna 1.163 //
|
842 sushma.fernandes 1.189 // 'required' setting must have a valid truststore
843 // 'optional' setting can be used with or without a truststore;
844 // log a warning if a truststore is not specified
|
845 nag.boranna 1.163 //
|
846 sushma.fernandes 1.189 if (trustStore == String::EMPTY)
|
847 nag.boranna 1.163 {
|
848 sushma.fernandes 1.189 if (String::equal(verifyClient, "required"))
849 {
850 MessageLoaderParms parms(
851 "Pegasus.Server.CIMServer.SSL_CLIENT_VERIFICATION_EMPTY_TRUSTSTORE",
852 "The \"sslTrustStore\" configuration property must be set if \"sslClientVerificationMode\" is 'required'. cimserver not started.");
853 PEG_METHOD_EXIT();
854 throw SSLException(parms);
855 }
856 else if (String::equal(verifyClient, "optional"))
|
857 nag.boranna 1.163 {
|
858 sushma.fernandes 1.189 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER,
859 Logger::WARNING,
860 "SSL client verification is enabled but no truststore was specified.");
|
861 nag.boranna 1.163 }
|
862 sushma.fernandes 1.189 }
|
863 h.sterling 1.165
|
864 h.sterling 1.168 #ifdef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
|
865 sushma.fernandes 1.189 //
866 // ATTN: 'required' setting must have http port enabled.
867 // If only https is enabled, and a call to shutdown the
868 // cimserver is given, the call will hang and a forced shutdown
869 // will ensue. This is because the CIMClient::connectLocal call
870 // cannot specify a certificate for authentication against
871 // the local server. This limitation is being investigated.
872 // See Bugzilla 2995.
873 //
874 if (String::equal(verifyClient, "required"))
875 {
876 if (!ConfigManager::parseBooleanValue(
877 configManager->getCurrentValue(
878 PROPERTY_NAME__HTTP_ENABLED)))
|
879 nag.boranna 1.163 {
|
880 sushma.fernandes 1.189 MessageLoaderParms parms(
881 "Pegasus.Server.SSLContextManager.INVALID_CONF_HTTPS_REQUIRED",
882 "The \"sslClientVerificationMode\" property cannot be "
883 "set to \"required\" if HTTP is disabled, as the "
884 "cimserver will be unable to properly shutdown. "
885 "The recommended course of action is to change "
886 "the property value to \"optional\". cimserver "
887 "not started.");
888 PEG_METHOD_EXIT();
889 throw SSLException(parms);
|
890 nag.boranna 1.163 }
|
891 sushma.fernandes 1.189 }
|
892 h.sterling 1.165 #endif
|
893 nag.boranna 1.163 //
|
894 sushma.fernandes 1.189 // A truststore username must be specified if
895 // sslClientVerificationMode is enabled and the truststore is a
896 // single CA file. If the truststore is a directory, then the
897 // CertificateProvider should be used to register users with
898 // certificates.
|
899 nag.boranna 1.163 //
|
900 sushma.fernandes 1.189 if ((trustStore != String::EMPTY) &&
901 (!FileSystem::isDirectory(trustStore)))
|
902 nag.boranna 1.163 {
|
903 sushma.fernandes 1.189 if (trustStoreUserName == String::EMPTY)
904 {
905 MessageLoaderParms parms(
906 "Pegasus.Server.CIMServer.SSL_CLIENT_VERIFICATION_EMPTY_USERNAME",
907 "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.");
908 PEG_METHOD_EXIT();
909 throw SSLException(parms);
910 }
|
911 nag.boranna 1.163 }
912 }
913
|
914 sushma.fernandes 1.178 #ifdef PEGASUS_ENABLE_SSL_CRL_VERIFICATION
|
915 nag.boranna 1.163 //
916 // Get the crlStore property from the Config Manager.
917 //
918 String crlStore = configManager->getCurrentValue(
919 PROPERTY_NAME__SSL_CRL_STORE);
920
921 if (crlStore != String::EMPTY)
922 {
923 crlStore = ConfigManager::getHomedPath(crlStore);
924 }
|
925 sushma.fernandes 1.178 #else
926 String crlStore = String::EMPTY;
927 #endif
|
928 nag.boranna 1.163
929 //
930 // Get the sslCertificateFilePath property from the Config Manager.
931 //
932 String certPath;
933 certPath = ConfigManager::getHomedPath(
934 configManager->getCurrentValue(PROPERTY_NAME__SSL_CERT_FILEPATH));
935
936 //
937 // Get the sslKeyFilePath property from the Config Manager.
938 //
939 String keyPath;
940 keyPath = ConfigManager::getHomedPath(
941 configManager->getCurrentValue(PROPERTY_NAME__SSL_KEY_FILEPATH));
942
943 String randFile = String::EMPTY;
944
945 #ifdef PEGASUS_SSL_RANDOMFILE
946 // NOTE: It is technically not necessary to set up a random file on
947 // the server side, but it is easier to use a consistent interface
948 // on the client and server than to optimize out the random file on
949 nag.boranna 1.163 // the server side.
950 randFile = ConfigManager::getHomedPath(PEGASUS_SSLSERVER_RANDOMFILE);
951 #endif
952
|
953 sushma.fernandes 1.189 //
954 // Create the SSLContext defined by the configuration properties
955 //
956 if (String::equal(verifyClient, "required"))
|
957 nag.boranna 1.163 {
|
958 sushma.fernandes 1.189 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
959 "SSL Client verification REQUIRED.");
|
960 nag.boranna 1.163
|
961 sushma.fernandes 1.189 _sslContextMgr->createSSLContext(
962 trustStore, certPath, keyPath, crlStore, false, randFile);
963 }
964 else if (String::equal(verifyClient, "optional"))
965 {
966 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
967 "SSL Client verification OPTIONAL.");
|
968 nag.boranna 1.163
|
969 sushma.fernandes 1.189 _sslContextMgr->createSSLContext(
970 trustStore, certPath, keyPath, crlStore, true, randFile);
|
971 nag.boranna 1.163 }
|
972 sushma.fernandes 1.189 else if (String::equal(verifyClient, "disabled") ||
973 verifyClient == String::EMPTY)
|
974 nag.boranna 1.163 {
|
975 sushma.fernandes 1.189 PEG_TRACE_STRING(TRC_SERVER, Tracer::LEVEL2,
976 "SSL Client verification DISABLED.");
|
977 nag.boranna 1.163
|
978 sushma.fernandes 1.189 _sslContextMgr->createSSLContext(
979 String::EMPTY, certPath, keyPath, crlStore, false, randFile);
|
980 nag.boranna 1.163 }
|
981 sushma.fernandes 1.189 sslContext = _sslContextMgr->getSSLContext();
|
982 nag.boranna 1.163
983 PEG_METHOD_EXIT();
984 return sslContext;
985 }
|
986 h.sterling 1.130
|
987 tony 1.134 #ifdef PEGASUS_ENABLE_SLP
|
988 mike 1.183 ThreadReturnType PEGASUS_THREAD_CDECL _callSLPProvider(void *parm);
|
989 tony 1.134
990
991 // This is a control function that starts a new thread which issues a
992 // cim operation to start the slp provider.
993 void CIMServer::startSLPProvider()
994 {
995
996 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "CIMServer::startSLPProvider");
997
|
998 mreddy 1.190.2.1 // onetime check is not needed for re-registration.
999 //if(!reRegister)
|
1000 tony 1.134 {
|
1001 mreddy 1.190.2.1 // This is a onetime function. If already issued, or config is not to use simply
1002 // return
1003 if (!_runSLP)
1004 {
1005 return;
1006 }
|
1007 tony 1.134
|
1008 mreddy 1.190.2.1 // Get Config parameter to determine if we should start SLP.
1009 ConfigManager* configManager = ConfigManager::getInstance();
1010 _runSLP = ConfigManager::parseBooleanValue(
1011 configManager->getCurrentValue("slp"));
1012
1013 // If false, do not start slp provider
1014 if (!_runSLP)
1015 {
1016 return;
1017 }
1018 //SLP startup is onetime function; reset the switch so this
1019 // function does not get called a second time.
1020 _runSLP = false;
1021 }
1022 // Start SLPProvider for Built-in SA and Open SLP SA. if the PEGASUS_SLP_REG_TIMEOUT is defined
1023 // start a thread which advertises CIMOM with a external SLP SA.
1024 #ifdef PEGASUS_SLP_REG_TIMEOUT
1025 _startAdvThread = true;
1026 Thread SLPThread(_advertisePegasus,0,true);
1027 SLPThread.run();
1028 #else
|
1029 tony 1.134 // Create a separate thread, detach and call function to execute the startup.
1030 Thread t( _callSLPProvider, 0, true );
1031 t.run();
|
1032 mreddy 1.190.2.1 #endif
|
1033 tony 1.134
1034 PEG_METHOD_EXIT();
1035 return;
1036 }
1037
1038
1039 // startSLPProvider is a function to get the slp provider kicked off
1040 // during startup. It is placed in the provider manager simply because
1041 // the provider manager is the only component of the system is
1042 // driven by a timer after startup. It should never be here and must be
1043 // moved to somewhere more logical or really replaced. We simply needed
1044 // something that was run shortly after system startup.
1045 // This function is assumed to operate in a separate thread and
1046 // KS 15 February 2004.
1047
|
1048 mike 1.183 ThreadReturnType PEGASUS_THREAD_CDECL _callSLPProvider(void* parm )
|
1049 tony 1.134 {
1050 //
1051 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_callSLPProvider()");
1052 // Create CIMClient object
1053 //
1054 CIMClient client;
1055 //
1056 // open connection to CIMOM
1057 //
1058 String hostStr = System::getHostName();
1059
1060 try
1061 {
1062 //
1063 client.connectLocal();
1064
1065 //
1066 // set client timeout to 2 seconds
1067 //
1068 client.setTimeout(40000);
1069 // construct CIMObjectPath
1070 tony 1.134 //
1071 String referenceStr = "//";
1072 referenceStr.append(hostStr);
1073 referenceStr.append("/");
1074 referenceStr.append(PEGASUS_NAMESPACENAME_INTERNAL.getString());
1075 referenceStr.append(":");
1076 referenceStr.append(PEGASUS_CLASSNAME_WBEMSLPTEMPLATE.getString());
1077 CIMObjectPath reference(referenceStr);
1078
1079 //
1080 // issue the invokeMethod request on the register method
1081 //
1082 Array<CIMParamValue> inParams;
1083 Array<CIMParamValue> outParams;
1084
1085 CIMValue retValue = client.invokeMethod(
1086 PEGASUS_NAMESPACENAME_INTERNAL,
1087 reference,
1088 CIMName("register"),
1089 inParams,
1090 outParams
1091 tony 1.134 );
1092 }
1093
1094 catch(CIMException& e)
1095 {
1096 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1097 "SLP Registration Failed. CIMException. $0", e.getMessage());
1098 }
1099
1100 catch(Exception& e)
1101 {
1102 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,
1103 "SLP Registration Failed Startup: CIMServer exception. $0", e.getMessage());
1104 }
1105
1106 client.disconnect();
1107
1108 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1109 "SLP Registration Initiated");
1110
1111 PEG_METHOD_EXIT();
|
1112 mike 1.183 return( (ThreadReturnType)32 );
|
1113 tony 1.134 }
1114
|
1115 mreddy 1.190.2.1 // This thread advertises pegasus to a listening SA. The attributes for
1116 // the Pegasus advertisement is obtained from CIM classes with the help
1117 // of SLPAttrib class methods.
1118 ThreadReturnType PEGASUS_THREAD_CDECL _advertisePegasus(void* parm)
1119 {
|
1120 tony 1.134
|
1121 mreddy 1.190.2.1 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::_advertisePegasus()");
|
1122 mreddy 1.190.2.4
|
1123 mreddy 1.190.2.1 static SLPAttrib SLPHttpAttribObj;
1124 static SLPAttrib SLPHttpsAttribObj;
1125 struct slp_client *client;
1126 time_t now,last;
1127 lslpMsg msg_list;
1128 char *scopes;
1129 Uint16 life = MAX_LIFE, port=SLP_PORT;
1130 char *addr = strdup(LOCALHOST_IP);
1131 char *type = (char *)NULL;;
1132 char *iface = NULL;
1133 char *httpUrl = (char *)NULL;;
1134 char *httpsUrl = (char *)NULL;;
1135 char *httpAttrs = (char *)NULL;
1136 char *httpsAttrs = (char *)NULL;
1137
1138 if (!handleCloseSLPThread)
1139 {
1140 // Comes here only if the cimserver is not terminated.
1141 // Get all the SLP attributes and data for the Pegasus cimserver.
1142 SLPHttpAttribObj.fillData("http");
1143 SLPHttpsAttribObj.fillData("https");
1144 mreddy 1.190.2.1 SLPHttpAttribObj.formAttributes();
1145 SLPHttpsAttribObj.formAttributes();
1146 }
1147
1148 scopes = strdup("DEFAULT");
1149
1150 type = strdup(SLPHttpAttribObj.getServiceType().getCString());
1151 httpUrl = strdup(SLPHttpAttribObj.getServiceUrl().getCString());
1152 httpsUrl = strdup(SLPHttpsAttribObj.getServiceUrl().getCString());
1153 httpAttrs = strdup(SLPHttpAttribObj.getAttributes().getCString());
1154 httpsAttrs = strdup(SLPHttpsAttribObj.getAttributes().getCString());
1155 if(NULL != (client = create_slp_client(addr,
1156 iface,
1157 SLP_PORT,
1158 "DSA",
1159 scopes,
1160 FALSE,
1161 FALSE)))
1162 {
1163 if (!handleCloseSLPThread)
1164 {
1165 mreddy 1.190.2.1 client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, life);
1166 client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes, life);
1167 }
1168 destroy_slp_client(client);
1169 }
1170
1171 if(type != NULL)
1172 free(type);
1173 if(httpUrl != NULL)
1174 free(httpUrl);
1175 if(httpsUrl != NULL)
1176 free(httpsUrl);
1177 if(httpAttrs != NULL)
1178 free(httpAttrs);
1179 if(httpsAttrs != NULL)
1180 free(httpsAttrs);
1181 if(addr != NULL)
1182 free(addr);
1183 if(scopes != NULL)
1184 free(scopes);
1185 if(iface != NULL)
1186 mreddy 1.190.2.1 free(iface);
|
1187 h.sterling 1.150
|
1188 mreddy 1.190.2.1 PEG_METHOD_EXIT();
1189 return( (ThreadReturnType)32 );
1190 }
1191
1192 // This routine deregisters the CIM Server registration with external SLP SA.
1193
1194 int _deregPegasus()
1195 {
1196
1197 PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::deregPegasus()");
1198
1199 static SLPAttrib SLPHttpAttribObj1;
1200 static SLPAttrib SLPHttpsAttribObj1;
1201 struct slp_client *client;
1202 time_t now,last;
1203 lslpMsg msg_list;
1204 char *scopes;
1205 Uint16 life = MAX_LIFE, port=SLP_PORT;
1206 char *addr = strdup(LOCALHOST_IP);
1207 char *type = (char *)NULL;;
1208 char *iface = NULL;
1209 mreddy 1.190.2.1 char *httpUrl = (char *)NULL;;
1210 char *httpsUrl = (char *)NULL;;
1211 char *httpAttrs = (char *)NULL;
1212 char *httpsAttrs = (char *)NULL;
1213
1214
1215 // Get all the SLP attributes and data for the Pegasus cimserver.
1216 SLPHttpAttribObj1.fillData("http");
1217 SLPHttpsAttribObj1.fillData("https");
1218 SLPHttpAttribObj1.formAttributes();
1219 SLPHttpsAttribObj1.formAttributes();
1220
1221 scopes = strdup("DEFAULT");
1222
1223 type = strdup(SLPHttpAttribObj1.getServiceType().getCString());
1224 httpUrl = strdup(SLPHttpAttribObj1.getServiceUrl().getCString());
1225 httpsUrl = strdup(SLPHttpsAttribObj1.getServiceUrl().getCString());
1226 httpAttrs = strdup(SLPHttpAttribObj1.getAttributes().getCString());
1227 httpsAttrs = strdup(SLPHttpsAttribObj1.getAttributes().getCString());
1228 if(NULL != (client = create_slp_client(addr,
1229 iface,
1230 mreddy 1.190.2.1 SLP_PORT,
1231 "DSA",
1232 scopes,
1233 FALSE,
1234 FALSE)))
1235 {
1236 client->srv_reg_local(client, httpUrl, httpAttrs, type, scopes, 0);
1237 client->srv_reg_local(client, httpsUrl, httpsAttrs, type, scopes,0);
1238 destroy_slp_client(client);
1239 }
1240 if(type != NULL)
1241 free(type);
1242 if(httpUrl != NULL)
1243 free(httpUrl);
1244 if(httpsUrl != NULL)
1245 free(httpsUrl);
1246 if(httpAttrs != NULL)
1247 free(httpAttrs);
1248 if(httpsAttrs != NULL)
1249 free(httpsAttrs);
1250 if(addr != NULL)
1251 mreddy 1.190.2.1 free(addr);
1252 if(scopes != NULL)
1253 free(scopes);
1254 if(iface != NULL)
1255 free(iface);
1256
1257 PEG_METHOD_EXIT();
1258 return( 32 );
1259 }
1260 #endif
1261 PEGASUS_NAMESPACE_END
|