2006-12-04 Esteban Sanchez <estebans@artica.es>

* misc/pandora_file.[cc,h]: Added a function to check the existance of
        a file.

        * pandora_ssh_tesct.cc: Check if private and public key files exists
        when doing the test.

        * bin/PandoraAgent.exe: Updated to new commit.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@302 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2006-12-04 11:08:38 +00:00
parent 49afbbf6eb
commit 45278c0fd2
4 changed files with 48 additions and 7 deletions

View File

@ -1,3 +1,13 @@
2006-12-04 Esteban Sanchez <estebans@artica.es>
* misc/pandora_file.[cc,h]: Added a function to check the existance of
a file.
* pandora_ssh_tesct.cc: Check if private and public key files exists
when doing the test.
* bin/PandoraAgent.exe: Updated to new commit.
2006-12-01 Raul Mateos <raulofpandora@gmail.com>
* installer/Pandora_FMS_Windows_Agent-1.2-Setup.exe: Updated with last

View File

@ -25,6 +25,26 @@
using namespace std;
/**
* Checks if a file exists.
*
* @param filepath Path of the file to check.
*
* @retval True if the file exists.
**/
bool
Pandora_File::fileExists (const string filepath) {
string line, result;
ifstream myfile (filepath.c_str ());
if (! myfile.is_open ()) {
return false;
}
myfile.close();
return true;
}
/**
* Reads a file and returns its content.
*

View File

@ -50,7 +50,8 @@ namespace Pandora_File {
class Delete_Error : Pandora_File::File_Exception {
};
string readFile (const string filename);
bool fileExists (const string filename);
string readFile (const string filename);
void removeFile (const string filename);
void writeFile (const string filename, const string data);
}

View File

@ -75,16 +75,26 @@ Pandora_SSH_Test::test () {
TiXmlDeclaration *decl;
bool saved;
remote_host = this->conf->getValue ("server_ip");
pubkey_file = Pandora::getPandoraInstallDir ();
pubkey_file += "key\\id_dsa.pub";
if (! Pandora_File::fileExists (pubkey_file)) {
cout << "Public key file " << pubkey_file << " not found."
<< endl;
return;
}
cout << "Public key file " << pubkey_file << " exists." << endl;
privkey_file = Pandora::getPandoraInstallDir ();
privkey_file += "key\\id_dsa";
cout << "Public key file: " << pubkey_file << endl;
cout << "Private key file: " << privkey_file << endl;
cout << "Connecting with " << remote_host << "..." << endl;
if (! Pandora_File::fileExists (privkey_file)) {
cout << "Private key file " << privkey_file << " not found."
<< endl;
return;
}
cout << "Private key file: " << privkey_file << " exists." << endl;
remote_host = this->conf->getValue ("server_ip");
cout << "Connecting with " << remote_host << "." << endl;
try {
this->ssh_client->connectWithPublicKey (remote_host.c_str (), 22,