2013-04-11 Hirofumi Kosaka <kosaka@rworks.jp>
* win32/pandora_windows_service.cc: Fixed possible resource leaks; - putenv() could run out the environment variable area, if using both file_collection and broker_agent. - possible handle leak at launching tentacle_client. * Cleaned source code style. Merged from branch 4.x. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7962 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
976bd1b478
commit
3ba48c447d
|
@ -1,3 +1,13 @@
|
|||
2013-04-11 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||
|
||||
* win32/pandora_windows_service.cc: Fixed possible resource leaks;
|
||||
- putenv() could run out the environment variable area, if
|
||||
using both file_collection and broker_agent.
|
||||
- possible handle leak at launching tentacle_client.
|
||||
* Cleaned source code style.
|
||||
|
||||
Merged from branch 4.x.
|
||||
|
||||
2013-04-01 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* unix/plugins/inventory: Improved software inventory in RPM format.
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
2013-04-11 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||
|
||||
* pandora_windows_service.cc: Fixed possible resource leaks;
|
||||
- putenv() could run out the environment variable area, if
|
||||
using both file_collection and broker_agent.
|
||||
- possible handle leak at launching tentacle_client.
|
||||
* Cleaned source code style.
|
||||
|
||||
Merged from branch 4.x.
|
||||
|
||||
2013-04-04 Koichiro KIKUCHI <koichiro@rworks.jp>
|
||||
|
||||
* windows_service.cc,
|
||||
|
|
|
@ -694,6 +694,9 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* close thread handle, because it won't be used */
|
||||
CloseHandle (pi.hThread);
|
||||
|
||||
/* Timeout */
|
||||
tentacle_timeout = atoi (conf->getValue ("tentacle_timeout").c_str ());
|
||||
if (tentacle_timeout <= 0) {
|
||||
|
@ -704,7 +707,7 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
|
|||
}
|
||||
|
||||
if (WaitForSingleObject(pi.hProcess, tentacle_timeout) == WAIT_TIMEOUT) {
|
||||
TerminateProcess(pi.hThread, STILL_ACTIVE);
|
||||
TerminateProcess(pi.hProcess, STILL_ACTIVE);
|
||||
CloseHandle (pi.hProcess);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1116,7 +1119,7 @@ Pandora_Windows_Service::checkCollections () {
|
|||
|
||||
int flag, i;
|
||||
char *coll_md5 = NULL, *server_coll_md5 = NULL;
|
||||
string collection_name, collections_dir, collection_md5, tmp;
|
||||
string collection_name, collections_dir, collection_path, collection_md5, tmp;
|
||||
string collection_zip, install_dir, temp_dir, dest_dir, path, env;
|
||||
|
||||
/*Get collections directory*/
|
||||
|
@ -1137,13 +1140,31 @@ Pandora_Windows_Service::checkCollections () {
|
|||
collection_name = conf->getCurrentCollectionName();
|
||||
|
||||
if(! conf->getCurrentCollectionVerify() ) {
|
||||
/*Add the collection directory to the path*/
|
||||
tmp = collections_dir + collection_name;
|
||||
path = getenv ("PATH");
|
||||
env = "PATH=" + path + ";" + tmp;
|
||||
putenv (env.c_str ());
|
||||
conf->setCurrentCollectionVerify();
|
||||
int found;
|
||||
|
||||
/*Add the collection directory to the path (if not exists in %path%)*/
|
||||
collection_path = collections_dir + collection_name;
|
||||
path = getenv ("PATH");
|
||||
|
||||
/* check if the path is just included in the middle of %path% */
|
||||
tmp = collection_path + ";"; /* Added a separator */
|
||||
if(path.find(tmp) == string::npos) {
|
||||
|
||||
/* check if the path is the last entry of %path% */
|
||||
if( ((found = path.rfind(collection_path)) != string::npos)
|
||||
&& ((found + collection_path.length()) == path.length()) )
|
||||
{
|
||||
/* included already (at the tail of %path%) */
|
||||
;
|
||||
}
|
||||
else {
|
||||
/* it's new ! */
|
||||
env = "PATH=" + path + ";" + collection_path;
|
||||
putenv (env.c_str ());
|
||||
}
|
||||
}
|
||||
|
||||
conf->setCurrentCollectionVerify();
|
||||
}
|
||||
|
||||
collection_zip = collection_name+".zip";
|
||||
|
|
Loading…
Reference in New Issue