/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
*/
void __memclear(char *id, char *name, char *ip, char *key, int size)
{
*/
void __memclear(char *id, char *name, char *ip, char *key, int size)
{
/* Allocating for the whole structure */
keys->keyentries =(keyentry **)realloc(keys->keyentries,
/* Allocating for the whole structure */
keys->keyentries =(keyentry **)realloc(keys->keyentries,
ErrorExit(MEM_ERROR, __local_name);
}
os_calloc(1, sizeof(keyentry), keys->keyentries[keys->keysize]);
ErrorExit(MEM_ERROR, __local_name);
}
os_calloc(1, sizeof(keyentry), keys->keyentries[keys->keysize]);
/* Setting configured values for id */
os_strdup(id, keys->keyentries[keys->keysize]->id);
/* Setting configured values for id */
os_strdup(id, keys->keyentries[keys->keysize]->id);
- OSHash_Add(keys->keyhash_id,
- keys->keyentries[keys->keysize]->id,
+ OSHash_Add(keys->keyhash_id,
+ keys->keyentries[keys->keysize]->id,
/* agent ip */
os_calloc(1, sizeof(os_ip), keys->keyentries[keys->keysize]->ip);
if(OS_IsValidIP(ip, keys->keyentries[keys->keysize]->ip) == 0)
{
ErrorExit(INVALID_IP, __local_name, ip);
}
/* agent ip */
os_calloc(1, sizeof(os_ip), keys->keyentries[keys->keysize]->ip);
if(OS_IsValidIP(ip, keys->keyentries[keys->keysize]->ip) == 0)
{
ErrorExit(INVALID_IP, __local_name, ip);
}
/* We need to remove the "/" from the cidr */
if((tmp_str = strchr(keys->keyentries[keys->keysize]->ip->ip, '/')) != NULL)
{
*tmp_str = '\0';
}
/* We need to remove the "/" from the cidr */
if((tmp_str = strchr(keys->keyentries[keys->keysize]->ip->ip, '/')) != NULL)
{
*tmp_str = '\0';
}
- OSHash_Add(keys->keyhash_ip,
- keys->keyentries[keys->keysize]->ip->ip,
+ OSHash_Add(keys->keyhash_ip,
+ keys->keyentries[keys->keysize]->ip->ip,
/* MD5 from name, id and key */
OS_MD5_Str(name, filesum1);
OS_MD5_Str(id, filesum2);
/* MD5 from name, id and key */
OS_MD5_Str(name, filesum1);
OS_MD5_Str(id, filesum2);
snprintf(_finalstr, sizeof(_finalstr)-1, "%s%s", filesum1, filesum2);
snprintf(_finalstr, sizeof(_finalstr)-1, "%s%s", filesum1, filesum2);
/* Second md is just the key */
OS_MD5_Str(key, filesum2);
/* Second md is just the key */
OS_MD5_Str(key, filesum2);
/* Generating final key */
memset(_finalstr,'\0', sizeof(_finalstr));
snprintf(_finalstr, 49, "%s%s", filesum2, filesum1);
/* Generating final key */
memset(_finalstr,'\0', sizeof(_finalstr));
snprintf(_finalstr, 49, "%s%s", filesum2, filesum1);
/* Checking if the keys file is present and we can read it. */
if((keys->file_change = File_DateofChange(KEYS_FILE)) < 0)
{
/* Checking if the keys file is present and we can read it. */
if((keys->file_change = File_DateofChange(KEYS_FILE)) < 0)
{
- __memclear(id, name, ip, key, KEYSIZE +1);
-
+ __memclear(id, name, ip, key, KEYSIZE +1);
+
merror(AG_MAX_ERROR, __local_name, MAX_AGENTS -2);
ErrorExit(CONFIG_ERROR, __local_name, KEYS_FILE);
}
merror(AG_MAX_ERROR, __local_name, MAX_AGENTS -2);
ErrorExit(CONFIG_ERROR, __local_name, KEYS_FILE);
}
if(keys->keyentries[i]->key)
free(keys->keyentries[i]->key);
if(keys->keyentries[i]->name)
free(keys->keyentries[i]->name);
if(keys->keyentries[i]->key)
free(keys->keyentries[i]->key);
if(keys->keyentries[i]->name)
free(keys->keyentries[i]->name);
{
merror(ENCFILE_CHANGED, __local_name);
debug1("%s: DEBUG: Freekeys", __local_name);
{
merror(ENCFILE_CHANGED, __local_name);
debug1("%s: DEBUG: Freekeys", __local_name);