29 thilo.boehm 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/Constants.h>
34 #include <Pegasus/Common/Logger.h>
35 #include <Pegasus/Common/AuditLogger.h>
36 #include <Pegasus/Common/Audit_zOS_SMF.h>
37
38 #include <stdlib.h>
39
40 #ifndef PEGASUS_DISABLE_AUDIT_LOGGER
41
42 PEGASUS_USING_STD;
43
44 PEGASUS_NAMESPACE_BEGIN
45
46 // Initialize the global and static variables:
47 // - Audit logging is disabled.
48 Boolean AuditLogger::_auditLogFlag = false;
49
50 thilo.boehm 1.1 // - The initiation call back is set to zero.
51 AuditLogger::PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T
52 AuditLogger::_auditLogInitializeCallback = 0;
53
54 // - The interanl writer for audit messages is used
55 AuditLogger::PEGASUS_AUDITLOG_CALLBACK_T AuditLogger::_writeAuditMessage =
56 Audit_zOS_SMF::writeRecord ;
57 Boolean _isInternalWriterUsed = true;
58
59 // - Instantiate the smf helper class.
60 Audit_zOS_SMF _smf;
61
62 // Definition of the CIM operation types for the
63 // CIM operation SMF record.
64 enum _smf_cim_oper_type {
65 CLASS_OPERATION=0,
66 QUALIFER_OPERATION=1,
67 INSTANCE_OPERATION=2,
68 INVOKE_METHOD=3
69 } ;
70
71 thilo.boehm 1.1 // Definition of the CIM authentication mode for the
72 // CIM authentication SMF record.
73 enum _smf_cim_auth_mode {
74 LOCAL=0,
75 BASIC=1,
76 ATTLS=2,
77 } ;
78
79
80 void AuditLogger::setInitializeCallback(
81 PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T auditLogInitializeCallback)
82 {
83 _auditLogInitializeCallback = auditLogInitializeCallback;
84 }
85
86
87 void AuditLogger::setAuditLogWriterCallback(
88 PEGASUS_AUDITLOG_CALLBACK_T writeAuditLogCallback)
89 {
90 _writeAuditMessage = writeAuditLogCallback;
91 _isInternalWriterUsed = false;
92 thilo.boehm 1.1 }
93
94 void AuditLogger::logCurrentConfig(
95 const Array<String> & propertyNames,
96 const Array<String> & propertyValues)
97 {
98 // check if SMF is gathering this type of records.
99 if (_smf.isRecording(CONFIGURATION) ||
100 (! _isInternalWriterUsed) )
101 {
102 unsigned char * confRecord;
103 unsigned char * cursor;
104 int cursorOffset;
105
106 _smf86_configuration * confSection;
107 int nameLen;
108 int valueLen;
109
110 // For all properties write a record.
111 for (Uint32 i = 0; i < propertyNames.size(); i++)
112 {
113 thilo.boehm 1.1 // +1 for the 0x00 termination.
114 nameLen = propertyNames[i].size()+1;
115 valueLen = propertyValues[i].size()+1;
116
117 // Allocate the full record.
118 confRecord = (unsigned char *) calloc(1,
119 sizeof(_smf86_configuration_record) + nameLen + valueLen );
120
121 // Initialize the header and product section.
122 // The length is the total of subtype section + variable parts.
123 _smf.initMyProlog((_smf86_record_prolog *)confRecord, CONFIGURATION,
124 sizeof(_smf86_configuration) + nameLen + valueLen );
125
126 // Set the pointer to the subtype section.
127 confSection = (_smf86_configuration *)
128 (confRecord + sizeof(_smf86_record_prolog));
129
130 // No user Id for logging current configuration.
131 _smf.setEBCDICRecordField(confSection->UserID, "",
132 sizeof(confSection->UserID),false);
133
134 thilo.boehm 1.1 // Configutation is listed
135 confSection->PropChange = 0;
136
137 // The variable values are starting
138 // at the end of the subtype section.
139 cursor = confRecord + sizeof(_smf86_configuration_record);
140 cursorOffset = sizeof(_smf86_configuration);
141
142 // Set the propety name
143 confSection->NameOf = cursorOffset;
144 confSection->NameNo = 1;
145 confSection->NameLen = nameLen;
146 _smf.setEBCDICRecordField(cursor,
147 (const char*)propertyNames[i].getCString(),
148 nameLen,true);
149
150 cursor = cursor + nameLen;
151 cursorOffset = cursorOffset + nameLen;
152
153 // Set the property value.
154 confSection->ValueOf = cursorOffset;
155 thilo.boehm 1.1 confSection->ValueNo = 1;
156 confSection->ValueLen = valueLen;
157 _smf.setEBCDICRecordField(cursor,
158 (const char*)propertyValues[i].getCString(),
159 valueLen,true);
160
161 // New property is set to 0, not used at listing the configuration.
162 confSection->NewValueOf = 0;
163 confSection->NewValueNo = 0;
164 confSection->NewValueLen = 0;
165
166 _writeAuditMessage(CONFIGURATION,(char *)confRecord);
167 free(confRecord);
168 } // End for all properties do.
169 }
170 }
171
172 void AuditLogger::logCurrentRegProvider(
173 const Array < CIMInstance > & instances)
174 {
175 // check if SMF is gathering this type of records.
176 thilo.boehm 1.1 if (_smf.isRecording(CONFIGURATION) ||
177 (! _isInternalWriterUsed) )
178 {
179 unsigned char * provStatRecord;
180 unsigned char * cursor;
181 int cursorOffset;
182
183 _smf86_provider_status * provStatSection;
184
185 String moduleName;
186 int moduleNameLen;
187 String statusValue;
188 Uint32 pos;
189
190 // For all current registered providers.
191 for (Uint32 i = 0; i < instances.size(); i++)
192 {
193 // Get the module name.
194 instances[i].getProperty(instances[i].findProperty(
195 _PROPERTY_PROVIDERMODULE_NAME)).getValue().get(moduleName);
196
197 thilo.boehm 1.1 // +1 for the 0x00 termination.
198 moduleNameLen = moduleName.size()+1;
199
200 // Allocate the full record.
201 provStatRecord = (unsigned char *) calloc(1,
202 sizeof(_smf86_provider_status_record) + moduleNameLen );
203
204 // Initialize the header and product section.
205 // The length is the total of subtype section + variable parts.
206 _smf.initMyProlog((_smf86_record_prolog *)provStatRecord,
207 PROVIDER_STATUS,
208 sizeof(_smf86_provider_status) + moduleNameLen );
209
210 // Set the pointer to the subtype section.
211 provStatSection = (_smf86_provider_status *)
212 (provStatRecord + sizeof(_smf86_record_prolog));
213
214 pos = instances[i].findProperty(_PROPERTY_OPERATIONALSTATUS);
215
216 if (pos == PEG_NOT_FOUND)
217 {
218 thilo.boehm 1.1 provStatSection->CurrStatus = 0;
219 }
220 else
221 {
222 CIMValue theValue = instances[i].getProperty(pos).getValue();
223 if (theValue.isNull())
224 {
225 provStatSection->CurrStatus = 0;
226 }
227 else
228 {
229 Array<Uint16> moduleStatus;
230 // Get the module status
231 theValue.get(moduleStatus);
232 // reset the smf record field
233 provStatSection->CurrStatus = 0;
234 for (int j = 0; j < moduleStatus.size();j++)
235 {
236 // Accumulate the status of the provider
237 // by shifting a bit the value of moduleStatus
238 // times to the left to get the right bit set.
239 thilo.boehm 1.1 provStatSection->CurrStatus =
240 provStatSection->CurrStatus +
241 ( 1 << moduleStatus[j] );
242 }
243
244 }
245 } // End of status set.
246
247 // The provider does not change its state.
248 provStatSection->IsChanging=0;
249 provStatSection->NewStatus=0;
250
251 // The variable values are starting
252 // at the end of the subtype section.
253 cursor = provStatRecord + sizeof(_smf86_provider_status_record);
254 cursorOffset = sizeof(_smf86_provider_status);
255
256 // Set the provider module name.
257 provStatSection->ProvNameOf = cursorOffset;
258 provStatSection->ProvNameNo = 1;
259 provStatSection->ProvNameLen = moduleNameLen;
260 thilo.boehm 1.1 _smf.setEBCDICRecordField(cursor,
261 (const char*)moduleName.getCString(),
262 moduleNameLen,true);
263
264 _writeAuditMessage(PROVIDER_STATUS,(char *)provStatRecord);
265 free(provStatRecord);
266
267 } // For all current registered providers.
268 }
269 }
270
271 void AuditLogger::logCurrentEnvironmentVar()
272 {
273 // This logging is currently not done within z/OS
274 }
275
276 void AuditLogger::logSetConfigProperty(
277 const String & userName,
278 const String & propertyName,
279 const String & prePropertyValue,
280 const String & newPropertyValue,
281 thilo.boehm 1.1 Boolean isPlanned)
282 {
283 // check if SMF is gathering this type of records.
284
285 if (_smf.isRecording(CONFIGURATION) ||
286 (! _isInternalWriterUsed) )
287 {
288 unsigned char * confRecord;
289 unsigned char * cursor;
290 int cursorOffset;
291
292 _smf86_configuration * confSection;
293
294 // +1 for the 0x00 termination
295 int nameLen = propertyName.size()+1;
296 int valueLen = prePropertyValue.size()+1;
297 int newValueLen = newPropertyValue.size()+1;
298
299 // allocate the full record.
300 confRecord = (unsigned char *) calloc(1,
301 sizeof(_smf86_configuration_record)
302 thilo.boehm 1.1 + nameLen + valueLen + newValueLen );
303
304 // Initialize the header and product section.
305 // The length is the total of subtype section + variable parts.
306 _smf.initMyProlog((_smf86_record_prolog *)confRecord,
307 CONFIGURATION,sizeof(_smf86_configuration) +
308 nameLen + valueLen + newValueLen );
309
310
311 // Set the pointer to the subtype section.
312 confSection = (_smf86_configuration *)
313 (confRecord + sizeof(_smf86_record_prolog));
314
315 // Set the user id.
316 _smf.setEBCDICRecordField(confSection->UserID,
317 (const char*)userName.getCString(),
318 sizeof(confSection->UserID),false);
319
320 if (isPlanned)
321 {
322 // It is a planed configuration change.
323 thilo.boehm 1.1 confSection->PropChange = 2;
324 }
325 else
326 {
327 // It is a current configuration change.
328 confSection->PropChange = 1;
329 }
330
331
332 // The variable values are starting
333 // at the end of the subtype section.
334 cursor = confRecord + sizeof(_smf86_configuration_record);
335 cursorOffset = sizeof(_smf86_configuration);
336
337 // set the propety name
338 confSection->NameOf = cursorOffset;
339 confSection->NameNo = 1;
340 confSection->NameLen = nameLen;
341 _smf.setEBCDICRecordField(cursor,
342 (const char*)propertyName.getCString(),
343 nameLen,true);
344 thilo.boehm 1.1
345 cursor = cursor + nameLen;
346 cursorOffset = cursorOffset + nameLen;
347
348 // set the property value
349 confSection->ValueOf = cursorOffset;
350 confSection->ValueNo = 1;
351 confSection->ValueLen = valueLen;
352 _smf.setEBCDICRecordField(cursor,
353 (const char*)prePropertyValue.getCString(),
354 valueLen,true);
355
356 cursor = cursor + valueLen;
357 cursorOffset = cursorOffset + valueLen;
358
359 // set the new property value
360 confSection->NewValueOf = cursorOffset;
361 confSection->NewValueNo = 1;
362 confSection->NewValueLen = newValueLen;
363 _smf.setEBCDICRecordField(cursor,
364 (const char*)newPropertyValue.getCString(),
365 thilo.boehm 1.1 newValueLen,true);
366
367 _writeAuditMessage(CONFIGURATION,(char *)confRecord);
368 free(confRecord);
369 }
370 }
371
372 void AuditLogger::logUpdateClassOperation(
373 const char* cimMethodName,
374 AuditEvent eventType,
375 const String& userName,
376 const String& ipAddr,
377 const CIMNamespaceName& nameSpace,
378 const CIMName& className,
379 CIMStatusCode statusCode)
380 {
381 // check if SMF is gathering this type of records.
382 if (_smf.isRecording(CIM_OPERATION) ||
383 (! _isInternalWriterUsed) )
384 {
385 _writeCIMOperationRecord(
386 thilo.boehm 1.1 CLASS_OPERATION, userName, statusCode,
387 ipAddr, cimMethodName, className.getString(),
388 nameSpace.getString(), String::EMPTY, String::EMPTY );
389 }
390 }
391
392 void AuditLogger::logUpdateQualifierOperation(
393 const char* cimMethodName,
394 AuditEvent eventType,
395 const String& userName,
396 const String& ipAddr,
397 const CIMNamespaceName& nameSpace,
398 const CIMName& className,
399 CIMStatusCode statusCode)
400 {
401 // check if SMF is gathering this type of records.
402 if (_smf.isRecording(CIM_OPERATION) ||
403 (! _isInternalWriterUsed) )
404 {
405 _writeCIMOperationRecord(
406 QUALIFER_OPERATION, userName, statusCode,
407 thilo.boehm 1.1 ipAddr, cimMethodName, className.getString(),
408 nameSpace.getString(), String::EMPTY, String::EMPTY );
409 }
410 }
411
412 void AuditLogger::logUpdateInstanceOperation(
413 const char* cimMethodName,
414 AuditEvent eventType,
415 const String& userName,
416 const String& ipAddr,
417 const CIMNamespaceName& nameSpace,
418 const CIMObjectPath& instanceName,
419 const String& moduleName,
420 const String& providerName,
421 CIMStatusCode statusCode)
422 {
423 // check if SMF is gathering this type of records.
424 if (_smf.isRecording(CIM_OPERATION) ||
425 (! _isInternalWriterUsed) )
426 {
427 String cimInstanceName =
428 thilo.boehm 1.1 CIMObjectPath("", CIMNamespaceName(), instanceName.getClassName(),
429 instanceName.getKeyBindings()).toString();
430
431 _writeCIMOperationRecord(
432 INSTANCE_OPERATION, userName, statusCode,
433 ipAddr, cimMethodName, cimInstanceName,
434 nameSpace.getString(), providerName, moduleName );
435 }
436 }
437
438 void AuditLogger::logInvokeMethodOperation(
439 const String& userName,
440 const String& ipAddr,
441 const CIMNamespaceName& nameSpace,
442 const CIMObjectPath& objectName,
443 const CIMName& methodName,
444 const String& moduleName,
445 const String& providerName,
446 CIMStatusCode statusCode)
447 {
448 // check if SMF is gathering this type of records.
449 thilo.boehm 1.1 if (_smf.isRecording(CIM_OPERATION) ||
450 (! _isInternalWriterUsed) )
451 {
452 String cimObjectName =
453 CIMObjectPath("", CIMNamespaceName(), objectName.getClassName(),
454 objectName.getKeyBindings()).toString();
455
456 _writeCIMOperationRecord(
457 INVOKE_METHOD, userName, statusCode,
458 ipAddr, methodName.getString(), cimObjectName,
459 nameSpace.getString(), providerName,moduleName );
460 }
461 }
462
463 void AuditLogger::logUpdateProvModuleStatus(
464 const String & moduleName,
465 const Array<Uint16> currentModuleStatus,
466 const Array<Uint16> newModuleStatus)
467 {
468 // check if SMF is gathering this type of records.
469 if (_smf.isRecording(CONFIGURATION) ||
470 thilo.boehm 1.1 (! _isInternalWriterUsed) )
471 {
472 unsigned char * provStatRecord;
473 unsigned char * cursor;
474 int cursorOffset;
475
476 _smf86_provider_status * provStatSection;
477
478 // +1 for the 0x00 termination.
479 int moduleNameLen = moduleName.size()+1;;
480 String statusValue;
481 Uint32 pos;
482
483 // Allocate the full record.
484 provStatRecord = (unsigned char *) calloc(1,
485 sizeof(_smf86_provider_status_record) + moduleNameLen );
486
487 // Initialize the header and product section.
488 // The length is the total of subtype section + variable parts.
489 _smf.initMyProlog((_smf86_record_prolog *)provStatRecord,
490 PROVIDER_STATUS,
491 thilo.boehm 1.1 sizeof(_smf86_provider_status) + moduleNameLen );
492
493 // Set the pointer to the subtype section.
494 provStatSection = (_smf86_provider_status *)
495 (provStatRecord + sizeof(_smf86_record_prolog));
496
497 provStatSection->CurrStatus = 0;
498
499 if (currentModuleStatus.size() > 0)
500 {
501 for (int j = 0; j < currentModuleStatus.size();j++)
502 {
503 // Accumulate the status of the provider
504 // by shifting a bit the value of moduleStatus
505 // times to the left to get the right bit set.
506 provStatSection->CurrStatus =
507 provStatSection->CurrStatus +
508 ( 1 << currentModuleStatus[j] );
509 }
510
511 }
512 thilo.boehm 1.1
513 // The provider does change.
514 provStatSection->IsChanging=1;
515
516 provStatSection->NewStatus=0;
517
518 if (newModuleStatus.size() > 0)
519 {
520 // Accumulate the new status of the provider
521 // by shifting a bit the value of moduleStatus
522 // times to the left to get the right bit set.
523 for (int j = 0; j < newModuleStatus.size();j++)
524 {
525 provStatSection->NewStatus =
526 provStatSection->NewStatus + ( 1 << newModuleStatus[j] );
527 }
528
529 }
530
531 // The variable values are starting
532 // at the end of the subtype section.
533 thilo.boehm 1.1 cursor = provStatRecord + sizeof(_smf86_provider_status_record);
534 cursorOffset = sizeof(_smf86_provider_status);
535
536 // Set the provider module name.
537 provStatSection->ProvNameOf =cursorOffset;
538 provStatSection->ProvNameNo = 1;
539 provStatSection->ProvNameLen = moduleNameLen;
540 _smf.setEBCDICRecordField(cursor,
541 (const char*)moduleName.getCString(),
542 moduleNameLen,true);
543
544 _writeAuditMessage(PROVIDER_STATUS,(char *)provStatRecord);
545 free(provStatRecord);
546 }
547
548 }
549
550 void AuditLogger::logLocalAuthentication(
551 const String& userName,
552 Boolean successful)
553 {
554 thilo.boehm 1.1 // check if SMF is gathering this type of records.
555 if (_smf.isRecording(AUTHENTICATION) ||
556 (! _isInternalWriterUsed) )
557 {
558 _writeAuthenticationRecord(LOCAL,userName,successful,
559 "localhost");
560 }
561 }
562
563 void AuditLogger::logBasicAuthentication(
564 const String& userName,
565 const String& ipAddr,
566 Boolean successful)
567 {
568 // check if SMF is gathering this type of records.
569 if (_smf.isRecording(AUTHENTICATION) ||
570 (! _isInternalWriterUsed) )
571 {
572 _writeAuthenticationRecord(BASIC,userName,successful,
573 ipAddr);
574 }
575 thilo.boehm 1.1 }
576
577 void AuditLogger::logCertificateBasedAuthentication(
578 const String& issuerName,
579 const String& subjectName,
580 const String& serialNumber,
581 const String& ipAddr,
582 Boolean successful)
583 {
584 // This fuction is unimplemented within z/OS.
585 // AT-TLS is doing this kind of logging.
586 }
587
588 void AuditLogger::logCertificateBasedUserValidation(
589 const String& userName,
590 const String& issuerName,
591 const String& subjectName,
592 const String& serialNumber,
593 const String& ipAddr,
594 Boolean successful)
595 {
596 thilo.boehm 1.1 // check if SMF is gathering this type of records.
597 if (_smf.isRecording(AUTHENTICATION) ||
598 (! _isInternalWriterUsed) )
599 {
600 _writeAuthenticationRecord(ATTLS,userName,successful,
601 ipAddr);
602 }
603
604 }
605
606
607 void AuditLogger::setEnabled(Boolean enable)
608 {
609 if (enable)
610 {
611 if (!_auditLogFlag)
612 {
613 Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER,
614 Logger::INFORMATION,
|
635 thilo.boehm 1.1 }
636 }
637
638 _auditLogFlag = enable;
639
640 }
641
642 inline void AuditLogger::_writeCIMOperationRecord(
643 unsigned short cimOpType,
644 String userID,
645 unsigned short cimStatusCode,
646 String clientIP,
647 String operName,
648 String objPath,
649 String nameSpace,
650 String provName,
651 String provModName
652 )
653 {
654 unsigned char * cimOperRecord;
655 unsigned char * cursor;
656 thilo.boehm 1.1 int cursorOffset;
657
658 _smf86_cim_operation * cimOperSection;
659
660 int operNameLen = operName.size();
661 int objPathLen = objPath.size();
662 int nameSpaceLen = nameSpace.size();
663 int provNameLen = provName.size();
664 int provModNameLen = provModName.size();
665
666 // if a string is not empty, + 1 for the trailing 0x00
667 if( operNameLen > 0 )
668 operNameLen = operNameLen + 1 ;
669
670 if( objPathLen > 0 )
671 objPathLen = objPathLen + 1;
672
673 if( nameSpaceLen > 0 )
674 nameSpaceLen = nameSpaceLen + 1;
675
676 if( provNameLen > 0 )
677 thilo.boehm 1.1 provNameLen = provNameLen + 1;
678
679 if( provModNameLen > 0 )
680 provModNameLen = provModNameLen + 1;
681
682 // Allocate the full record.
683 cimOperRecord = (unsigned char *) calloc(1,
684 sizeof(_smf86_cim_operation_record)+
685 operNameLen + objPathLen + nameSpaceLen +
686 provNameLen + provModNameLen );
687
688 // Initialize the header and product section.
689 // The length is the total of subtype section + variable parts.
690 _smf.initMyProlog((_smf86_record_prolog *)cimOperRecord,
691 CIM_OPERATION, sizeof(_smf86_cim_operation)+
692 operNameLen + objPathLen + nameSpaceLen +
693 provNameLen + provModNameLen );
694
695 // Set the pointer to the subtype section.
696 cimOperSection = (_smf86_cim_operation *)
697 (cimOperRecord + sizeof(_smf86_record_prolog));
698 thilo.boehm 1.1
699 // Set cim operation type.
700 cimOperSection->CIMOpType = cimOpType;
701
702 // Set cim operation status code
703 cimOperSection->CIMStatusCode = cimStatusCode;
704
705 // Set the user id.
706 _smf.setEBCDICRecordField(cimOperSection->UserID,
707 (const char*)userID.getCString(),
708 sizeof(cimOperSection->UserID),false);
709
710 // Set the client IP adress.
711 _smf.setEBCDICRecordField(cimOperSection->ClientIP,
712 (const char*)clientIP.getCString(),
713 sizeof(cimOperSection->ClientIP),false);
714
715
716 // The operation name starts from the end of the static record information.
717 cursor = cimOperRecord + sizeof(_smf86_cim_operation_record);
718 cursorOffset = sizeof(_smf86_cim_operation);
719 thilo.boehm 1.1
720 // Set operation name
721 if (operNameLen > 0 )
722 {
723 cimOperSection->OperNameOf = cursorOffset;
724 cimOperSection->OperNameLen = operNameLen;
725 cimOperSection->OperNameNo = 1;
726 _smf.setEBCDICRecordField(cursor,(const char*)operName.getCString(),
727 operNameLen,true);
728 cursor = cursor + operNameLen;
729 cursorOffset = cursorOffset + operNameLen;
730 }
731 else
732 {
733 cimOperSection->OperNameOf = 0;
734 cimOperSection->OperNameLen = 0;
735 cimOperSection->OperNameNo = 0;
736 }
737
738 // Set object path
739 if (objPathLen > 0 )
740 thilo.boehm 1.1 {
741 cimOperSection->ObjPathOf = cursorOffset;
742 cimOperSection->ObjPathLen = objPathLen;
743 cimOperSection->ObjPathNo = 1;
744 _smf.setEBCDICRecordField(cursor,(const char*)objPath.getCString(),
745 objPathLen,true);
746 cursor = cursor + objPathLen;
747 cursorOffset = cursorOffset + objPathLen;
748 }
749 else
750 {
751 cimOperSection->ObjPathOf = 0;
752 cimOperSection->ObjPathLen = 0;
753 cimOperSection->ObjPathNo = 0;
754 }
755
756 // Set name space
757 if (nameSpaceLen > 0 )
758 {
759 cimOperSection->NameSpaceOf = cursorOffset;
760 cimOperSection->NameSpaceLen = nameSpaceLen;
761 thilo.boehm 1.1 cimOperSection->NameSpaceNo = 1;
762 _smf.setEBCDICRecordField(cursor,(const char*)nameSpace.getCString(),
763 nameSpaceLen,true);
764 cursor = cursor + nameSpaceLen;
765 cursorOffset = cursorOffset + nameSpaceLen;
766 }
767 else
768 {
769 cimOperSection->NameSpaceOf = 0;
770 cimOperSection->NameSpaceLen = 0;
771 cimOperSection->NameSpaceNo = 0;
772 }
773
774 // Set provider name
775 if (provNameLen > 0 )
776 {
777 cimOperSection->ProvNameOf = cursorOffset;
778 cimOperSection->ProvNameLen = provNameLen;
779 cimOperSection->ProvNameNo = 1;
780 _smf.setEBCDICRecordField(cursor,(const char*)provName.getCString(),
781 provNameLen,true);
782 thilo.boehm 1.1 cursor = cursor + provNameLen;
783 cursorOffset = cursorOffset + provNameLen;
784 }
785 else
786 {
787 cimOperSection->ProvNameOf = 0;
788 cimOperSection->ProvNameLen = 0;
789 cimOperSection->ProvNameNo = 0;
790 }
791
792 // Set provider module name
793 if (provModNameLen > 0 )
794 {
795 cimOperSection->ProvModNameOf = cursorOffset;
796 cimOperSection->ProvModNameLen = provModNameLen;
797 cimOperSection->ProvModNameNo = 1;
798 _smf.setEBCDICRecordField(cursor,(const char*)provModName.getCString(),
799 provModNameLen,true);
800 cursor = cursor + provModNameLen;
801 cursorOffset = cursorOffset + provModNameLen;
802 }
803 thilo.boehm 1.1 else
804 {
805 cimOperSection->ProvModNameOf = 0;
806 cimOperSection->ProvModNameLen = 0;
807 cimOperSection->ProvModNameNo = 0;
808 }
809
810 _writeAuditMessage(CIM_OPERATION,(char *)cimOperRecord);
811 free(cimOperRecord);
812
813
814 }
815
816 inline void AuditLogger::_writeAuthenticationRecord(
817 unsigned short authMode,
818 String userID,
819 Boolean isAuthenticated,
820 String clientIP )
821 {
822 unsigned char * authenticationRecord;
823 _smf86_authentication * authenticationSection;
824 thilo.boehm 1.1
825 // Allocate the full record.
826 authenticationRecord = (unsigned char *) calloc(1,
827 sizeof(_smf86_auththentication_record));
828
829 // Initialize the header and product section.
830 // The length is the total of subtype section + variable parts.
831 _smf.initMyProlog((_smf86_record_prolog *)authenticationRecord,
832 AUTHENTICATION, sizeof(_smf86_authentication));
833
834 // Set the pointer to the subtype section.
835 authenticationSection = (_smf86_authentication *)
836 (authenticationRecord + sizeof(_smf86_record_prolog));
837
838 authenticationSection->AuthMode = authMode;
839
840 // Set the user id.
841 _smf.setEBCDICRecordField(authenticationSection->UserID,
842 (const char*)userID.getCString(),
843 sizeof(authenticationSection->UserID),false);
844
845 thilo.boehm 1.1 if(isAuthenticated)
846 {
847 authenticationSection->AuthResult=0;
848 }
849 else
850 {
851 authenticationSection->AuthResult=1;
852 }
853
854 // Set the client IP adress.
855 _smf.setEBCDICRecordField(authenticationSection->ClientIP,
856 (const char*)clientIP.getCString(),
857 sizeof(authenticationSection->ClientIP),false);
858
859 _writeAuditMessage(AUTHENTICATION,(char *)authenticationRecord);
860 free(authenticationRecord);
861 }
862
863 PEGASUS_NAMESPACE_END
864
865 #endif
|