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