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

Diff for /pegasus/src/Pegasus/Common/TraceFileHandler.cpp between version 1.20 and 1.28

version 1.20, 2005/02/06 21:13:14 version 1.28, 2006/04/18 19:08:42
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 37 
Line 39 
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <fstream>  //#include <fstream>
 #include <iostream>  //#include <iostream>
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/TraceFileHandler.h> #include <Pegasus/Common/TraceFileHandler.h>
  
Line 84 
Line 86 
     if (_fileHandle)     if (_fileHandle)
     {     {
         fclose(_fileHandle);         fclose(_fileHandle);
 #if defined(PEGASUS_OS_VMS)  
 //  
 // Clear out the pointer just in case.  
 //  
         _fileHandle = 0;  
 #endif  
     }     }
     if (_fileName)  
     {  
         delete []_fileName;         delete []_fileName;
     }  
 #ifdef PEGASUS_PLATFORM_LINUX_GENERIC_GNU #ifdef PEGASUS_PLATFORM_LINUX_GENERIC_GNU
     if (_baseFileName)  
     {  
         delete []_baseFileName;         delete []_baseFileName;
     }  
 #endif #endif
 } }
  
Line 128 
Line 118 
     {     {
         return 1;         return 1;
     }     }
 #if defined(PEGASUS_OS_VMS)  
     // Check if a file is already open, if so close it  
     if (_fileHandle)  
     {  
         fclose(_fileHandle);  
 //  
 // Clear out the pointer just in case.  
 //  
         _fileHandle = 0;  
     }  
 #endif  
     _fileHandle = _openFile(fileName);     _fileHandle = _openFile(fileName);
   
     if (!_fileHandle)     if (!_fileHandle)
     {     {
         return 1;         return 1;
Line 158 
Line 136 
  
 FILE* TraceFileHandler::_openFile(const char* fileName) FILE* TraceFileHandler::_openFile(const char* fileName)
 { {
   #ifdef PEGASUS_OS_VMS
   //    FILE* fileHandle = fopen(fileName,"a+", "shr=get,put,upd");
       FILE* fileHandle = fopen(fileName,"w", "shr=get,put,upd");
   #else
     FILE* fileHandle = fopen(fileName,"a+");     FILE* fileHandle = fopen(fileName,"a+");
   #endif
     if (!fileHandle)     if (!fileHandle)
     {     {
         // Unable to open file, log a message         // Unable to open file, log a message
         Logger::put_l(Logger::DEBUG_LOG, "Tracer", Logger::WARNING,          Logger::put_l(Logger::DEBUG_LOG, System::CIMSERVER, Logger::WARNING,
             "Common.TraceFileHandler.FAILED_TO_OPEN_FILE",             "Common.TraceFileHandler.FAILED_TO_OPEN_FILE",
             "Failed to open file $0", fileName);             "Failed to open file $0", fileName);
         return 0;         return 0;
     }     }
  
     //     //
       // Verify that the file has the correct owner
       //
       if (!System::verifyFileOwnership(fileName))
       {
           Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING,
              "Common.TraceFileHandler.UNEXPECTED_FILE_OWNER",
              "File $0 is not owned by user $1.", fileName,
              System::getEffectiveUserName());
           fclose(fileHandle);
           return 0;
       }
   
       //
     // Set the file permissions to 0600     // Set the file permissions to 0600
     //     //
 #if !defined(PEGASUS_OS_TYPE_WINDOWS) #if !defined(PEGASUS_OS_TYPE_WINDOWS)
Line 179 
Line 175 
             String(fileName), (_S_IREAD|_S_IWRITE)) )             String(fileName), (_S_IREAD|_S_IWRITE)) )
 #endif #endif
     {     {
         Logger::put_l(Logger::DEBUG_LOG, "Tracer", Logger::WARNING,          Logger::put_l(Logger::DEBUG_LOG, System::CIMSERVER, Logger::WARNING,
            "Common.TraceFileHandler.FAILED_TO_SET_FILE_PERMISSIONS",            "Common.TraceFileHandler.FAILED_TO_SET_FILE_PERMISSIONS",
            "Failed to set permissions on file $0", fileName);            "Failed to set permissions on file $0", fileName);
         fclose(fileHandle);         fclose(fileHandle);
         return 0;         return 0;
     }     }
  
     //  
     // Verify that the file has the correct owner  
     //  
     if (!System::verifyFileOwnership(fileName))  
     {  
         Logger::put_l(Logger::ERROR_LOG, "Tracer", Logger::WARNING,  
            "Common.TraceFileHandler.UNEXPECTED_FILE_OWNER",  
            "File $0 is not owned by user $1.", fileName,  
            System::getEffectiveUserName());  
         fclose(fileHandle);  
         return 0;  
     }  
   
     return fileHandle;     return fileHandle;
 } }
  
Line 264 
Line 247 
             }             }
         }         }
     }     }
     return 1;      PEGASUS_UNREACHABLE(return 1;)
 } }
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.20  
changed lines
  Added in v.1.28

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2