(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 kumpf       1.2                 MessageLoaderParms(
618                                     "Common.AuditLogger.ENABLE_AUDIT_LOG",
619                                     "Audit logging is enabled."));
620 thilo.boehm 1.1 
621                             // only call the audit intiialzation call back if set.
622                             if (_auditLogInitializeCallback != 0)
623                             {
624                                 _auditLogInitializeCallback();
625                             }
626                         }
627                     }
628                     else
629                     {
630                         if (_auditLogFlag)
631                         {
632                             Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, 
633                                 Logger::INFORMATION,
634 kumpf       1.2                 MessageLoaderParms(
635                                     "Common.AuditLogger.DISABLE_AUDIT_LOG",
636                                     "Audit logging is disabled."));
637 thilo.boehm 1.1         }
638                     }
639                 
640                     _auditLogFlag = enable;
641                 
642                 }
643                 
644                 inline void AuditLogger::_writeCIMOperationRecord(
645                     unsigned short cimOpType,
646                     String userID,
647                     unsigned short cimStatusCode,
648                     String clientIP,
649                     String operName,
650                     String objPath,
651                     String nameSpace,
652                     String provName,
653                     String provModName
654                     )
655                 {
656                     unsigned char * cimOperRecord;
657                     unsigned char * cursor;
658 thilo.boehm 1.1     int cursorOffset;
659                 
660                     _smf86_cim_operation * cimOperSection;
661                 
662                     int operNameLen = operName.size();
663                     int objPathLen = objPath.size();
664                     int nameSpaceLen = nameSpace.size();
665                     int provNameLen = provName.size();
666                     int provModNameLen = provModName.size();
667                 
668                     // if a string is not empty, + 1 for the trailing 0x00
669                     if( operNameLen > 0 )
670                         operNameLen = operNameLen + 1 ;
671                 
672                     if( objPathLen > 0 )
673                         objPathLen = objPathLen + 1;
674                 
675                     if( nameSpaceLen > 0 )
676                         nameSpaceLen = nameSpaceLen + 1;
677                 
678                     if( provNameLen > 0 )
679 thilo.boehm 1.1         provNameLen = provNameLen + 1;
680                 
681                     if( provModNameLen > 0 )
682                         provModNameLen = provModNameLen + 1;
683                 
684                     // Allocate the full record.
685                     cimOperRecord = (unsigned char *) calloc(1,
686                         sizeof(_smf86_cim_operation_record)+
687                         operNameLen + objPathLen + nameSpaceLen + 
688                         provNameLen + provModNameLen );
689                 
690                     // Initialize the header and product section.
691                     // The length is the total of subtype section + variable parts.
692                     _smf.initMyProlog((_smf86_record_prolog *)cimOperRecord, 
693                         CIM_OPERATION, sizeof(_smf86_cim_operation)+
694                         operNameLen + objPathLen + nameSpaceLen + 
695                         provNameLen + provModNameLen );
696                 
697                     // Set the pointer to the subtype section.
698                     cimOperSection = (_smf86_cim_operation *) 
699                         (cimOperRecord + sizeof(_smf86_record_prolog));
700 thilo.boehm 1.1 
701                     // Set cim operation type.
702                     cimOperSection->CIMOpType = cimOpType;
703                 
704                     // Set cim operation status code
705                     cimOperSection->CIMStatusCode = cimStatusCode;
706                 
707                     // Set the user id.
708                     _smf.setEBCDICRecordField(cimOperSection->UserID,
709                                               (const char*)userID.getCString(),
710                                               sizeof(cimOperSection->UserID),false);
711                 
712                     // Set the client IP adress.
713                     _smf.setEBCDICRecordField(cimOperSection->ClientIP,
714                                               (const char*)clientIP.getCString(),
715                                               sizeof(cimOperSection->ClientIP),false);
716                 
717                     
718                     // The operation name starts from the end of the static record information.
719                     cursor = cimOperRecord + sizeof(_smf86_cim_operation_record);
720                     cursorOffset = sizeof(_smf86_cim_operation);
721 thilo.boehm 1.1 
722                     // Set operation name 
723                     if (operNameLen > 0 )
724                     {
725                         cimOperSection->OperNameOf = cursorOffset;
726                         cimOperSection->OperNameLen = operNameLen;
727                         cimOperSection->OperNameNo = 1;
728                         _smf.setEBCDICRecordField(cursor,(const char*)operName.getCString(),
729                                                   operNameLen,true);
730                         cursor = cursor + operNameLen;
731                         cursorOffset = cursorOffset + operNameLen;
732                     } 
733                     else
734                     {
735                         cimOperSection->OperNameOf = 0;
736                         cimOperSection->OperNameLen = 0;
737                         cimOperSection->OperNameNo = 0;
738                     }
739                     
740                     // Set object path
741                     if (objPathLen > 0 )
742 thilo.boehm 1.1     {
743                         cimOperSection->ObjPathOf = cursorOffset;
744                         cimOperSection->ObjPathLen = objPathLen;
745                         cimOperSection->ObjPathNo = 1;
746                         _smf.setEBCDICRecordField(cursor,(const char*)objPath.getCString(),
747                                                   objPathLen,true);
748                         cursor = cursor + objPathLen;
749                         cursorOffset = cursorOffset + objPathLen;
750                     }
751                     else
752                     {
753                         cimOperSection->ObjPathOf = 0;
754                         cimOperSection->ObjPathLen = 0;
755                         cimOperSection->ObjPathNo = 0;
756                     }
757                 
758                     // Set name space
759                     if (nameSpaceLen > 0 )
760                     {
761                         cimOperSection->NameSpaceOf = cursorOffset;
762                         cimOperSection->NameSpaceLen = nameSpaceLen;
763 thilo.boehm 1.1         cimOperSection->NameSpaceNo = 1;
764                         _smf.setEBCDICRecordField(cursor,(const char*)nameSpace.getCString(),
765                                                   nameSpaceLen,true);
766                         cursor = cursor + nameSpaceLen;
767                         cursorOffset = cursorOffset + nameSpaceLen;
768                     }
769                     else
770                     {
771                         cimOperSection->NameSpaceOf = 0;
772                         cimOperSection->NameSpaceLen = 0;
773                         cimOperSection->NameSpaceNo = 0;
774                     }
775                 
776                     // Set provider name
777                     if (provNameLen > 0 )
778                     {
779                         cimOperSection->ProvNameOf = cursorOffset;
780                         cimOperSection->ProvNameLen = provNameLen;
781                         cimOperSection->ProvNameNo = 1;
782                         _smf.setEBCDICRecordField(cursor,(const char*)provName.getCString(),
783                                                   provNameLen,true);
784 thilo.boehm 1.1         cursor = cursor + provNameLen;
785                         cursorOffset = cursorOffset + provNameLen;
786                     }
787                     else
788                     {
789                         cimOperSection->ProvNameOf = 0;
790                         cimOperSection->ProvNameLen = 0;
791                         cimOperSection->ProvNameNo = 0;
792                     }
793                 
794                     // Set provider module name
795                     if (provModNameLen > 0 )
796                     {
797                         cimOperSection->ProvModNameOf = cursorOffset;
798                         cimOperSection->ProvModNameLen = provModNameLen;
799                         cimOperSection->ProvModNameNo = 1;
800                         _smf.setEBCDICRecordField(cursor,(const char*)provModName.getCString(),
801                                                   provModNameLen,true);
802                         cursor = cursor + provModNameLen;
803                         cursorOffset = cursorOffset + provModNameLen;
804                     }
805 thilo.boehm 1.1     else
806                     {
807                         cimOperSection->ProvModNameOf = 0;
808                         cimOperSection->ProvModNameLen = 0;
809                         cimOperSection->ProvModNameNo = 0;
810                     }
811                     
812                     _writeAuditMessage(CIM_OPERATION,(char *)cimOperRecord);
813                     free(cimOperRecord);
814                 
815                 
816                 }
817                 
818                 inline void AuditLogger::_writeAuthenticationRecord(
819                     unsigned short authMode,
820                     String userID,
821                     Boolean isAuthenticated,
822                     String clientIP )
823                 {
824                     unsigned char * authenticationRecord;
825                     _smf86_authentication * authenticationSection;
826 thilo.boehm 1.1 
827                     // Allocate the full record.
828                     authenticationRecord = (unsigned char *) calloc(1,
829                         sizeof(_smf86_auththentication_record));
830                 
831                     // Initialize the header and product section.
832                     // The length is the total of subtype section + variable parts.
833                     _smf.initMyProlog((_smf86_record_prolog *)authenticationRecord, 
834                         AUTHENTICATION, sizeof(_smf86_authentication));
835                 
836                     // Set the pointer to the subtype section.
837                     authenticationSection = (_smf86_authentication *)
838                                      (authenticationRecord + sizeof(_smf86_record_prolog));
839                 
840                     authenticationSection->AuthMode = authMode;
841                 
842                     // Set the user id.
843                     _smf.setEBCDICRecordField(authenticationSection->UserID,
844                                               (const char*)userID.getCString(),
845                                               sizeof(authenticationSection->UserID),false);
846                 
847 thilo.boehm 1.1     if(isAuthenticated)
848                     {
849                         authenticationSection->AuthResult=0;
850                     }
851                     else
852                     {
853                         authenticationSection->AuthResult=1;
854                     }
855                 
856                     // Set the client IP adress.
857                     _smf.setEBCDICRecordField(authenticationSection->ClientIP,
858                                               (const char*)clientIP.getCString(),
859                                               sizeof(authenticationSection->ClientIP),false);
860                 
861                     _writeAuditMessage(AUTHENTICATION,(char *)authenticationRecord);
862                     free(authenticationRecord);
863                 }
864                 
865                 PEGASUS_NAMESPACE_END
866                 
867                 #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2