(file) Return to AuditLoggerToSMF.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 thilo.boehm 1.1 //%2006////////////////////////////////////////////////////////////////////////
  2                 //
  3                 // 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                 // IBM Corp.; EMC Corporation, The Open Group.
  7                 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8                 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9                 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10                 // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11                 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12                 // EMC Corporation; Symantec Corporation; The Open Group.
 13                 //
 14                 // Permission is hereby granted, free of charge, to any person obtaining a copy
 15                 // 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                 // 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                 // 
 21                 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 thilo.boehm 1.1 // 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                 // 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                 // 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                 #include <Pegasus/Common/Config.h>
 35                 #include <Pegasus/Common/Constants.h>
 36                 #include <Pegasus/Common/Logger.h>
 37                 #include <Pegasus/Common/AuditLogger.h>
 38                 #include <Pegasus/Common/Audit_zOS_SMF.h>
 39                 
 40                 #include <stdlib.h>
 41                 
 42                 #ifndef PEGASUS_DISABLE_AUDIT_LOGGER
 43 thilo.boehm 1.1 
 44                 PEGASUS_USING_STD;
 45                 
 46                 PEGASUS_NAMESPACE_BEGIN
 47                 
 48                 // Initialize the global and static variables:
 49                 // - Audit logging is disabled.
 50                 Boolean AuditLogger::_auditLogFlag = false;
 51                 
 52                 // - The initiation call back is set to zero.
 53                 AuditLogger::PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T
 54                     AuditLogger::_auditLogInitializeCallback = 0;
 55                 
 56                 // - The interanl writer for audit messages is used
 57                 AuditLogger::PEGASUS_AUDITLOG_CALLBACK_T AuditLogger::_writeAuditMessage =
 58                     Audit_zOS_SMF::writeRecord ;
 59                 Boolean _isInternalWriterUsed = true;
 60                 
 61                 // - Instantiate the smf helper class.
 62                 Audit_zOS_SMF _smf;
 63                 
 64 thilo.boehm 1.1 // Definition of the CIM operation types for the 
 65                 // CIM operation SMF record.
 66                 enum _smf_cim_oper_type {
 67                     CLASS_OPERATION=0,
 68                     QUALIFER_OPERATION=1,
 69                     INSTANCE_OPERATION=2,
 70                     INVOKE_METHOD=3
 71                 } ;
 72                 
 73                 // Definition of the CIM authentication mode for the
 74                 // CIM authentication SMF record.
 75                 enum _smf_cim_auth_mode {
 76                     LOCAL=0,
 77                     BASIC=1,
 78                     ATTLS=2,
 79                 } ;
 80                 
 81                 
 82                 void AuditLogger::setInitializeCallback(
 83                         PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T auditLogInitializeCallback)
 84                 {
 85 thilo.boehm 1.1     _auditLogInitializeCallback = auditLogInitializeCallback;
 86                 }
 87                 
 88                 
 89                 void AuditLogger::setAuditLogWriterCallback(
 90                     PEGASUS_AUDITLOG_CALLBACK_T writeAuditLogCallback)
 91                 {
 92                     _writeAuditMessage = writeAuditLogCallback;
 93                     _isInternalWriterUsed = false;
 94                 }
 95                 
 96                 void AuditLogger::logCurrentConfig(
 97                     const Array<String> & propertyNames,
 98                     const Array<String> & propertyValues)
 99                 {
100                     // check if SMF is gathering this type of records.
101                     if (_smf.isRecording(CONFIGURATION) ||
102                         (! _isInternalWriterUsed) )
103                     {   
104                         unsigned char * confRecord;
105                         unsigned char * cursor;
106 thilo.boehm 1.1         int cursorOffset;
107                 
108                         _smf86_configuration * confSection;
109                         int nameLen;
110                         int valueLen; 
111                 
112                         // For all properties write a record.
113                         for (Uint32 i = 0; i < propertyNames.size(); i++)
114                         {
115                             // +1 for the 0x00 termination.
116                             nameLen = propertyNames[i].size()+1;
117                             valueLen =  propertyValues[i].size()+1;
118                 
119                             // Allocate the full record.
120                             confRecord = (unsigned char *) calloc(1,
121                                 sizeof(_smf86_configuration_record) + nameLen + valueLen );
122                 
123                             // Initialize the header and product section.
124                             // The length is the total of subtype section + variable parts.
125                             _smf.initMyProlog((_smf86_record_prolog *)confRecord, CONFIGURATION,
126                                 sizeof(_smf86_configuration) + nameLen + valueLen );
127 thilo.boehm 1.1 
128                             // Set the pointer to the subtype section.
129                             confSection = (_smf86_configuration *)
130                                 (confRecord + sizeof(_smf86_record_prolog));
131                 
132                             // No user Id for logging current configuration.
133                             _smf.setEBCDICRecordField(confSection->UserID, "",
134                                 sizeof(confSection->UserID),false);
135                 
136                             // Configutation is listed
137                             confSection->PropChange = 0;
138                 
139                             // The variable values are starting 
140                             // at the end of the subtype section.
141                             cursor = confRecord + sizeof(_smf86_configuration_record);
142                             cursorOffset = sizeof(_smf86_configuration);
143                 
144                            // Set the propety name 
145                            confSection->NameOf = cursorOffset;
146                            confSection->NameNo = 1;
147                            confSection->NameLen = nameLen;
148 thilo.boehm 1.1            _smf.setEBCDICRecordField(cursor,
149                                (const char*)propertyNames[i].getCString(),
150                                nameLen,true);
151                 
152                            cursor = cursor + nameLen;
153                            cursorOffset = cursorOffset + nameLen;
154                            
155                            // Set the property value.
156                            confSection->ValueOf = cursorOffset;
157                            confSection->ValueNo = 1;
158                            confSection->ValueLen = valueLen;
159                            _smf.setEBCDICRecordField(cursor,
160                                (const char*)propertyValues[i].getCString(),
161                                valueLen,true);
162                 
163                             // New property is set to 0, not used at listing the configuration.
164                             confSection->NewValueOf = 0;
165                             confSection->NewValueNo = 0;
166                             confSection->NewValueLen = 0;
167                 
168                             _writeAuditMessage(CONFIGURATION,(char *)confRecord);
169 thilo.boehm 1.1             free(confRecord);
170                         } // End for all properties do.
171                     }
172                 }
173                 
174                 void AuditLogger::logCurrentRegProvider(
175                     const Array < CIMInstance > & instances)
176                 {
177                     // check if SMF is gathering this type of records.
178                     if (_smf.isRecording(CONFIGURATION) ||
179                         (! _isInternalWriterUsed) )
180                     {   
181                         unsigned char * provStatRecord;
182                         unsigned char * cursor;
183                         int cursorOffset;
184                 
185                         _smf86_provider_status * provStatSection;
186                 
187                         String moduleName;
188                         int moduleNameLen;
189                         String statusValue;
190 thilo.boehm 1.1         Uint32 pos;
191                 
192                         // For all current registered providers.
193                         for (Uint32 i = 0; i < instances.size(); i++)
194                         {
195                             // Get the module name.
196                             instances[i].getProperty(instances[i].findProperty(
197                                 _PROPERTY_PROVIDERMODULE_NAME)).getValue().get(moduleName);
198                 
199                             // +1 for the 0x00 termination.
200                             moduleNameLen = moduleName.size()+1;
201                 
202                             // Allocate the full record.
203                             provStatRecord = (unsigned char *) calloc(1,
204                                 sizeof(_smf86_provider_status_record) + moduleNameLen );
205                 
206                             // Initialize the header and product section.
207                             // The length is the total of subtype section + variable parts.
208                             _smf.initMyProlog((_smf86_record_prolog *)provStatRecord, 
209                                 PROVIDER_STATUS,
210                                 sizeof(_smf86_provider_status) + moduleNameLen );
211 thilo.boehm 1.1 
212                             // Set the pointer to the subtype section.
213                             provStatSection = (_smf86_provider_status *)
214                                 (provStatRecord + sizeof(_smf86_record_prolog));
215                 
216                             pos = instances[i].findProperty(_PROPERTY_OPERATIONALSTATUS);
217                 
218                             if (pos == PEG_NOT_FOUND)
219                             {
220                                 provStatSection->CurrStatus = 0;
221                             }
222                             else
223                             {
224                                 CIMValue theValue = instances[i].getProperty(pos).getValue();
225                                 if (theValue.isNull())
226                                 {
227                                     provStatSection->CurrStatus = 0;
228                                 }
229                                 else
230                                 {
231                                     Array<Uint16> moduleStatus;
232 thilo.boehm 1.1                     // Get the module status
233                                     theValue.get(moduleStatus);
234                                     // reset the smf record field 
235                                     provStatSection->CurrStatus = 0;
236                                     for (int j = 0; j < moduleStatus.size();j++)
237                                     {
238                                         // Accumulate the status of the provider 
239                                         // by shifting a bit the value of moduleStatus
240                                         // times to the left to get the right bit set.
241                                         provStatSection->CurrStatus = 
242                                             provStatSection->CurrStatus + 
243                                             ( 1 << moduleStatus[j] );
244                                     }
245                 
246                                 }
247                             } // End of status set.
248                 
249                             // The provider does not change its state.
250                             provStatSection->IsChanging=0;
251                             provStatSection->NewStatus=0;
252                 
253 thilo.boehm 1.1             // The variable values are starting 
254                             // at the end of the subtype section.
255                             cursor = provStatRecord + sizeof(_smf86_provider_status_record);
256                             cursorOffset = sizeof(_smf86_provider_status);
257                 
258                             // Set the provider module name.
259                             provStatSection->ProvNameOf = cursorOffset;
260                             provStatSection->ProvNameNo = 1;
261                             provStatSection->ProvNameLen = moduleNameLen;
262                             _smf.setEBCDICRecordField(cursor,
263                                 (const char*)moduleName.getCString(),
264                                 moduleNameLen,true);
265                 
266                             _writeAuditMessage(PROVIDER_STATUS,(char *)provStatRecord);
267                             free(provStatRecord);
268                 
269                         } // For all current registered providers.
270                     }
271                 }
272                 
273                 void AuditLogger::logCurrentEnvironmentVar()
274 thilo.boehm 1.1 {
275                     // This logging is currently not done within z/OS
276                 }
277                 
278                 void AuditLogger::logSetConfigProperty(
279                     const String & userName,
280                     const String & propertyName,
281                     const String & prePropertyValue,
282                     const String & newPropertyValue,
283                     Boolean isPlanned)
284                 {
285                     // check if SMF is gathering this type of records.
286                 
287                     if (_smf.isRecording(CONFIGURATION) ||
288                         (! _isInternalWriterUsed) )
289                     {
290                         unsigned char * confRecord;
291                         unsigned char * cursor;
292                         int cursorOffset;
293                 
294                         _smf86_configuration * confSection;
295 thilo.boehm 1.1 
296                         // +1 for the 0x00 termination
297                         int nameLen = propertyName.size()+1;
298                         int valueLen =  prePropertyValue.size()+1;
299                         int newValueLen =  newPropertyValue.size()+1;
300                 
301                         // allocate the full record.
302                         confRecord = (unsigned char *) calloc(1,
303                                           sizeof(_smf86_configuration_record) 
304                                           + nameLen + valueLen + newValueLen );
305                 
306                         // Initialize the header and product section.
307                         // The length is the total of subtype section + variable parts.
308                         _smf.initMyProlog((_smf86_record_prolog *)confRecord,
309                             CONFIGURATION,sizeof(_smf86_configuration) +
310                             nameLen + valueLen + newValueLen );
311                 
312                 
313                         // Set the pointer to the subtype section.
314                         confSection = (_smf86_configuration *)
315                                          (confRecord + sizeof(_smf86_record_prolog));
316 thilo.boehm 1.1 
317                        // Set the user id.
318                         _smf.setEBCDICRecordField(confSection->UserID,
319                                                   (const char*)userName.getCString(),
320                                                   sizeof(confSection->UserID),false);
321                 
322                         if (isPlanned)
323                         {
324                             // It is a planed configuration change.
325                             confSection->PropChange = 2;
326                         } 
327                         else
328                         {
329                             // It is a current configuration change.
330                             confSection->PropChange = 1;
331                         }
332                 
333                 
334                         // The variable values are starting 
335                         // at the end of the subtype section.
336                         cursor = confRecord + sizeof(_smf86_configuration_record);
337 thilo.boehm 1.1         cursorOffset = sizeof(_smf86_configuration);
338                 
339                         // set the propety name 
340                         confSection->NameOf = cursorOffset;
341                         confSection->NameNo = 1;
342                         confSection->NameLen = nameLen;
343                         _smf.setEBCDICRecordField(cursor,
344                             (const char*)propertyName.getCString(),
345                             nameLen,true);
346                 
347                         cursor = cursor + nameLen;
348                         cursorOffset = cursorOffset + nameLen;
349                 
350                         // set the property value
351                         confSection->ValueOf = cursorOffset;
352                         confSection->ValueNo = 1;
353                         confSection->ValueLen = valueLen;
354                         _smf.setEBCDICRecordField(cursor,
355                             (const char*)prePropertyValue.getCString(),
356                             valueLen,true);
357                 
358 thilo.boehm 1.1         cursor = cursor + valueLen;
359                         cursorOffset = cursorOffset + valueLen;
360                 
361                         // set the new property value
362                         confSection->NewValueOf = cursorOffset;
363                         confSection->NewValueNo = 1;
364                         confSection->NewValueLen = newValueLen;
365                         _smf.setEBCDICRecordField(cursor,
366                             (const char*)newPropertyValue.getCString(),
367                             newValueLen,true);
368                 
369                         _writeAuditMessage(CONFIGURATION,(char *)confRecord);
370                         free(confRecord);
371                     }
372                 }
373                 
374                 void AuditLogger::logUpdateClassOperation(
375                     const char* cimMethodName,
376                     AuditEvent eventType,
377                     const String& userName,
378                     const String& ipAddr,
379 thilo.boehm 1.1     const CIMNamespaceName& nameSpace,
380                     const CIMName& className,
381                     CIMStatusCode statusCode)
382                 {
383                     // check if SMF is gathering this type of records.
384                     if (_smf.isRecording(CIM_OPERATION) ||
385                         (! _isInternalWriterUsed) )
386                     {   
387                         _writeCIMOperationRecord(
388                             CLASS_OPERATION, userName, statusCode,
389                             ipAddr, cimMethodName, className.getString(),
390                             nameSpace.getString(), String::EMPTY, String::EMPTY );
391                     }
392                 }
393                 
394                 void AuditLogger::logUpdateQualifierOperation(
395                     const char* cimMethodName,
396                     AuditEvent eventType,
397                     const String& userName,
398                     const String& ipAddr,
399                     const CIMNamespaceName& nameSpace,
400 thilo.boehm 1.1     const CIMName& className,
401                     CIMStatusCode statusCode)
402                 {
403                     // check if SMF is gathering this type of records.
404                     if (_smf.isRecording(CIM_OPERATION) ||
405                         (! _isInternalWriterUsed) )
406                     {   
407                         _writeCIMOperationRecord(
408                             QUALIFER_OPERATION, userName, statusCode,
409                             ipAddr, cimMethodName, className.getString(),
410                             nameSpace.getString(), String::EMPTY, String::EMPTY );
411                     }
412                 }
413                 
414                 void AuditLogger::logUpdateInstanceOperation(
415                     const char* cimMethodName,
416                     AuditEvent eventType,
417                     const String& userName,
418                     const String& ipAddr,
419                     const CIMNamespaceName& nameSpace,
420                     const CIMObjectPath& instanceName,
421 thilo.boehm 1.1     const String& moduleName,
422                     const String& providerName,
423                     CIMStatusCode statusCode)
424                 {
425                     // check if SMF is gathering this type of records.
426                     if (_smf.isRecording(CIM_OPERATION) ||
427                         (! _isInternalWriterUsed) )
428                     {   
429                         String cimInstanceName = 
430                             CIMObjectPath("", CIMNamespaceName(), instanceName.getClassName(),
431                             instanceName.getKeyBindings()).toString();
432                 
433                         _writeCIMOperationRecord(
434                             INSTANCE_OPERATION, userName, statusCode,
435                             ipAddr, cimMethodName, cimInstanceName,
436                             nameSpace.getString(), providerName, moduleName );
437                     }
438                 }
439                 
440                 void AuditLogger::logInvokeMethodOperation(
441                     const String& userName,
442 thilo.boehm 1.1     const String& ipAddr,
443                     const CIMNamespaceName& nameSpace,
444                     const CIMObjectPath& objectName,
445                     const CIMName& methodName,
446                     const String& moduleName,
447                     const String& providerName,
448                     CIMStatusCode statusCode)
449                 {
450                     // check if SMF is gathering this type of records.
451                     if (_smf.isRecording(CIM_OPERATION) ||
452                         (! _isInternalWriterUsed) )
453                     {   
454                         String cimObjectName = 
455                             CIMObjectPath("", CIMNamespaceName(), objectName.getClassName(),
456                             objectName.getKeyBindings()).toString();
457                 
458                         _writeCIMOperationRecord(
459                             INVOKE_METHOD, userName, statusCode,
460                             ipAddr, methodName.getString(), cimObjectName,
461                             nameSpace.getString(), providerName,moduleName );
462                     }
463 thilo.boehm 1.1 }
464                 
465                 void AuditLogger::logUpdateProvModuleStatus(
466                     const String & moduleName,
467                     const Array<Uint16> currentModuleStatus,
468                     const Array<Uint16> newModuleStatus)
469                 {
470                         // check if SMF is gathering this type of records.
471                     if (_smf.isRecording(CONFIGURATION) ||
472                         (! _isInternalWriterUsed) )
473                     {   
474                         unsigned char * provStatRecord;
475                         unsigned char * cursor;
476                         int cursorOffset;
477                 
478                         _smf86_provider_status * provStatSection;
479                 
480                         // +1 for the 0x00 termination.
481                         int moduleNameLen = moduleName.size()+1;;
482                         String statusValue;
483                         Uint32 pos;
484 thilo.boehm 1.1 
485                         // Allocate the full record.
486                         provStatRecord = (unsigned char *) calloc(1,
487                             sizeof(_smf86_provider_status_record) + moduleNameLen );
488                 
489                         // Initialize the header and product section.
490                         // The length is the total of subtype section + variable parts.
491                         _smf.initMyProlog((_smf86_record_prolog *)provStatRecord, 
492                             PROVIDER_STATUS,
493                             sizeof(_smf86_provider_status) + moduleNameLen );
494                 
495                         // Set the pointer to the subtype section.
496                         provStatSection = (_smf86_provider_status *)
497                             (provStatRecord + sizeof(_smf86_record_prolog));
498                 
499                         provStatSection->CurrStatus = 0;
500                 
501                         if (currentModuleStatus.size() > 0)
502                         {
503                             for (int j = 0; j < currentModuleStatus.size();j++)
504                             {
505 thilo.boehm 1.1                 // Accumulate the status of the provider 
506                                 // by shifting a bit the value of moduleStatus
507                                 // times to the left to get the right bit set.
508                                 provStatSection->CurrStatus = 
509                                     provStatSection->CurrStatus + 
510                                     ( 1 << currentModuleStatus[j] );
511                             }
512                             
513                         }
514                 
515                         // The provider does change.
516                         provStatSection->IsChanging=1;
517                 
518                         provStatSection->NewStatus=0;
519                 
520                         if (newModuleStatus.size() > 0)
521                         {
522                             // Accumulate the new status of the provider 
523                             // by shifting a bit the value of moduleStatus
524                             // times to the left to get the right bit set.
525                             for (int j = 0; j < newModuleStatus.size();j++)
526 thilo.boehm 1.1             {
527                                 provStatSection->NewStatus = 
528                                     provStatSection->NewStatus + ( 1 << newModuleStatus[j] );
529                             }
530                 
531                         }
532                 
533                         // The variable values are starting 
534                         // at the end of the subtype section.
535                         cursor = provStatRecord + sizeof(_smf86_provider_status_record);
536                         cursorOffset =  sizeof(_smf86_provider_status);
537                 
538                         // Set the provider module name.
539                         provStatSection->ProvNameOf =cursorOffset;
540                         provStatSection->ProvNameNo = 1;
541                         provStatSection->ProvNameLen = moduleNameLen;
542                         _smf.setEBCDICRecordField(cursor,
543                             (const char*)moduleName.getCString(),
544                             moduleNameLen,true);
545                 
546                         _writeAuditMessage(PROVIDER_STATUS,(char *)provStatRecord);
547 thilo.boehm 1.1         free(provStatRecord);
548                     }
549                 
550                 }
551                 
552                 void AuditLogger::logLocalAuthentication(
553                     const String& userName,
554                     Boolean successful)
555                 {         
556                     // check if SMF is gathering this type of records.
557                     if (_smf.isRecording(AUTHENTICATION) ||
558                         (! _isInternalWriterUsed) )
559                     {   
560                         _writeAuthenticationRecord(LOCAL,userName,successful,
561                             "localhost");
562                     }
563                 }
564                 
565                 void AuditLogger::logBasicAuthentication(
566                     const String& userName,
567                     const String& ipAddr,
568 thilo.boehm 1.1     Boolean successful)
569                 {
570                     // check if SMF is gathering this type of records.
571                     if (_smf.isRecording(AUTHENTICATION) ||
572                         (! _isInternalWriterUsed) )
573                     {   
574                         _writeAuthenticationRecord(BASIC,userName,successful,
575                             ipAddr);
576                     }
577                 }
578                 
579                 void AuditLogger::logCertificateBasedAuthentication(
580                     const String& issuerName,
581                     const String& subjectName,
582                     const String& serialNumber,
583                     const String& ipAddr,
584                     Boolean successful)
585                 {
586                     // This fuction is unimplemented within z/OS.
587                     // AT-TLS is doing this kind of logging.
588                 }
589 thilo.boehm 1.1 
590                 void AuditLogger::logCertificateBasedUserValidation(
591                     const String& userName,
592                     const String& issuerName,
593                     const String& subjectName,
594                     const String& serialNumber,
595                     const String& ipAddr,
596                     Boolean successful)
597                 {
598                     // check if SMF is gathering this type of records.
599                     if (_smf.isRecording(AUTHENTICATION) ||
600                         (! _isInternalWriterUsed) )
601                     {   
602                         _writeAuthenticationRecord(ATTLS,userName,successful,
603                             ipAddr);
604                     }
605                 
606                 }
607                 
608                 
609                 void AuditLogger::setEnabled(Boolean enable)
610 thilo.boehm 1.1 {
611                     if (enable)
612                     {
613                         if (!_auditLogFlag)
614                         {
615                             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, 
616                                 Logger::INFORMATION,
617                                 "Common.AuditLogger.ENABLE_AUDIT_LOG",
618                                 "Audit logging is enabled.");
619                 
620                             // only call the audit intiialzation call back if set.
621                             if (_auditLogInitializeCallback != 0)
622                             {
623                                 _auditLogInitializeCallback();
624                             }
625                         }
626                     }
627                     else
628                     {
629                         if (_auditLogFlag)
630                         {
631 thilo.boehm 1.1             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, 
632                                 Logger::INFORMATION,
633                                 "Common.AuditLogger.DISABLE_AUDIT_LOG",
634                                 "Audit logging is disabled.");
635                         }
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 thilo.boehm 1.1     )
653                 {
654                     unsigned char * cimOperRecord;
655                     unsigned char * cursor;
656                     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 thilo.boehm 1.1     if( nameSpaceLen > 0 )
674                         nameSpaceLen = nameSpaceLen + 1;
675                 
676                     if( provNameLen > 0 )
677                         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 thilo.boehm 1.1 
695                     // Set the pointer to the subtype section.
696                     cimOperSection = (_smf86_cim_operation *) 
697                         (cimOperRecord + sizeof(_smf86_record_prolog));
698                 
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 thilo.boehm 1.1     
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                 
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 thilo.boehm 1.1     }
737                     
738                     // Set object path
739                     if (objPathLen > 0 )
740                     {
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 thilo.boehm 1.1     if (nameSpaceLen > 0 )
758                     {
759                         cimOperSection->NameSpaceOf = cursorOffset;
760                         cimOperSection->NameSpaceLen = nameSpaceLen;
761                         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 thilo.boehm 1.1         cimOperSection->ProvNameLen = provNameLen;
779                         cimOperSection->ProvNameNo = 1;
780                         _smf.setEBCDICRecordField(cursor,(const char*)provName.getCString(),
781                                                   provNameLen,true);
782                         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 thilo.boehm 1.1                                   provModNameLen,true);
800                         cursor = cursor + provModNameLen;
801                         cursorOffset = cursorOffset + provModNameLen;
802                     }
803                     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 thilo.boehm 1.1     String clientIP )
821                 {
822                     unsigned char * authenticationRecord;
823                     _smf86_authentication * authenticationSection;
824                 
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 thilo.boehm 1.1     _smf.setEBCDICRecordField(authenticationSection->UserID,
842                                               (const char*)userID.getCString(),
843                                               sizeof(authenticationSection->UserID),false);
844                 
845                     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 thilo.boehm 1.1 
863                 PEGASUS_NAMESPACE_END
864                 
865                 #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2