"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libpromises/lastseen.c" between
cfengine-3.12.6.tar.gz and cfengine-3.12.7.tar.gz

About: CFEngine is a configuration management system for configuring and maintaining Unix-like computers (using an own high level policy language). Community version. Community version. LTS (Long Term Support) release.

lastseen.c  (cfengine-3.12.6):lastseen.c  (cfengine-3.12.7)
skipping to change at line 512 skipping to change at line 512
return res; return res;
} }
/** /**
* @brief removes all traces of key digest 'key' from lastseen DB * @brief removes all traces of key digest 'key' from lastseen DB
* *
* @param[in] key : either in (SHA/MD5 format) * @param[in] key : either in (SHA/MD5 format)
* @param[in,out] ip : return the key corresponding host. * @param[in,out] ip : return the key corresponding host.
* If NULL, return nothing * If NULL, return nothing
* @param[in] ip_size : length of ip parameter * @param[in] ip_size : length of ip parameter
* @param[in] a_entry_required : whether 'aIP_ADDR' entry is required for
* the 'kHOSTKEY' entry deletion
* @retval true if entry was deleted, false otherwise * @retval true if entry was deleted, false otherwise
*/ */
bool DeleteDigestFromLastSeen(const char *key, char *ip, size_t ip_size) bool DeleteDigestFromLastSeen(const char *key, char *ip, size_t ip_size, bool a_ entry_required)
{ {
DBHandle *db; DBHandle *db;
bool res = false; bool res = false;
if (!OpenDB(&db, dbid_lastseen)) if (!OpenDB(&db, dbid_lastseen))
{ {
char *db_path = DBIdToPath(dbid_lastseen); char *db_path = DBIdToPath(dbid_lastseen);
Log(LOG_LEVEL_ERR, "Unable to open lastseen database '%s'", db_path); Log(LOG_LEVEL_ERR, "Unable to open lastseen database '%s'", db_path);
free(db_path); free(db_path);
return false; return false;
skipping to change at line 537 skipping to change at line 539
char bufhost[CF_BUFSIZE + 1]; char bufhost[CF_BUFSIZE + 1];
strcpy(bufkey, "k"); strcpy(bufkey, "k");
strlcat(bufkey, key, CF_BUFSIZE); strlcat(bufkey, key, CF_BUFSIZE);
char host[CF_BUFSIZE]; char host[CF_BUFSIZE];
if (ReadDB(db, bufkey, &host, sizeof(host)) == true) if (ReadDB(db, bufkey, &host, sizeof(host)) == true)
{ {
strcpy(bufhost, "a"); strcpy(bufhost, "a");
strlcat(bufhost, host, CF_BUFSIZE); strlcat(bufhost, host, CF_BUFSIZE);
if (HasKeyDB(db, bufhost, strlen(bufhost) + 1) == false) if (a_entry_required && !HasKeyDB(db, bufhost, strlen(bufhost) + 1))
{ {
res = false; res = false;
goto clean; goto clean;
} }
else else
{ {
if (ip != NULL) if (ip != NULL)
{ {
strlcpy(ip, host, ip_size); strlcpy(ip, host, ip_size);
} }
skipping to change at line 712 skipping to change at line 714
return 254; return 254;
} }
} }
bool is_digest; bool is_digest;
is_digest = IsDigestOrHost(input); is_digest = IsDigestOrHost(input);
if (is_digest == true) if (is_digest == true)
{ {
Log(LOG_LEVEL_VERBOSE, "Removing digest '%s' from lastseen database\n", input); Log(LOG_LEVEL_VERBOSE, "Removing digest '%s' from lastseen database\n", input);
if (DeleteDigestFromLastSeen(input, equivalent, equivalent_size) == fals e) if (!DeleteDigestFromLastSeen(input, equivalent, equivalent_size, must_b e_coherent))
{ {
Log(LOG_LEVEL_ERR, "Unable to remove digest from lastseen database." ); Log(LOG_LEVEL_ERR, "Unable to remove digest from lastseen database." );
return 252; return 252;
} }
} }
else else
{ {
Log(LOG_LEVEL_VERBOSE, "Removing host '%s' from lastseen database\n", in put); Log(LOG_LEVEL_VERBOSE, "Removing host '%s' from lastseen database\n", in put);
if (DeleteIpFromLastSeen(input, equivalent, equivalent_size) == false) if (DeleteIpFromLastSeen(input, equivalent, equivalent_size) == false)
{ {
 End of changes. 4 change blocks. 
3 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)