version 1.26, 2007/04/03 18:50:58
|
version 1.27, 2007/05/25 18:35:19
|
|
|
#include <Pegasus/Common/FileSystem.h> | #include <Pegasus/Common/FileSystem.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
|
#include <Pegasus/Common/Executor.h> |
#if defined(PEGASUS_OS_OS400) | #if defined(PEGASUS_OS_OS400) |
#include "OS400ConvertChar.h" | #include "OS400ConvertChar.h" |
#endif | #endif |
|
|
{ | { |
if (FileSystem::exists(_passwordFile)) | if (FileSystem::exists(_passwordFile)) |
{ | { |
if (! FileSystem::removeFile(_passwordFile)) |
if (Executor::removeFile(_passwordFile.getCString()) != 0) |
{ | { |
throw CannotRemoveFile(_passwordFile); | throw CannotRemoveFile(_passwordFile); |
} | } |
|
|
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Security.UserManager.PasswordFile.TRYING_TO_BACKUP_FILE", | "Security.UserManager.PasswordFile.TRYING_TO_BACKUP_FILE", |
"Trying to use the backup file : $0.", _passwordBackupFile); | "Trying to use the backup file : $0.", _passwordBackupFile); |
if (! FileSystem::renameFile(_passwordBackupFile, _passwordFile)) |
if (Executor::renameFile( |
|
_passwordBackupFile.getCString(), _passwordFile.getCString()) != 0) |
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
|
{ | { |
if ( FileSystem::exists(_passwordFile)) | if ( FileSystem::exists(_passwordFile)) |
{ | { |
if ( ! FileSystem::removeFile(_passwordFile)) |
if (Executor::removeFile(_passwordFile.getCString()) != 0) |
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
|
{ | { |
if ( FileSystem::exists(_passwordFile)) | if ( FileSystem::exists(_passwordFile)) |
{ | { |
if ( ! FileSystem::renameFile(_passwordFile, _passwordBackupFile)) |
if (Executor::renameFile(_passwordFile.getCString(), |
|
_passwordBackupFile.getCString()) != 0) |
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
|
// | // |
// Open the password file for writing | // Open the password file for writing |
// | // |
#if defined(PEGASUS_OS_OS400) |
|
ofstream ofs(_passwordFile.getCString(), PEGASUS_STD(_CCSID_T(1208))); |
FILE* ofs = Executor::openFile(_passwordFile.getCString(), 'w'); |
#else |
|
ofstream ofs(_passwordFile.getCString()); |
|
#endif |
|
if (!ofs) | if (!ofs) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw CannotOpenFile(getFileName()); | throw CannotOpenFile(getFileName()); |
} | } |
| |
ofs.clear(); |
|
|
|
// | // |
// Save user names and passwords to the new file | // Save user names and passwords to the new file |
// | // |
for (PasswordTable::Iterator i = passwordTable.start(); i; i++) | for (PasswordTable::Iterator i = passwordTable.start(); i; i++) |
{ | { |
ofs << i.key() << ":" << i.value() << endl; |
CString key = i.key().getCString(); |
|
CString value = i.value().getCString(); |
|
fprintf(ofs, "%s:%s\n", (const char*)key, (const char*)value); |
} | } |
| |
ofs.close(); |
fclose(ofs); |
| |
if ( FileSystem::exists(_passwordBackupFile)) | if ( FileSystem::exists(_passwordBackupFile)) |
{ | { |
if ( ! FileSystem::removeFile(_passwordBackupFile)) |
if (Executor::removeFile(_passwordBackupFile.getCString()) != 0) |
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, |