integrity checker accepts an option checksum library on construction
This commit is contained in:
@@ -29,8 +29,6 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
|
|
||||||
#define CHECKSUM_LIBRARY IPSEC_DIR"/libchecksum.so"
|
|
||||||
|
|
||||||
typedef struct private_integrity_checker_t private_integrity_checker_t;
|
typedef struct private_integrity_checker_t private_integrity_checker_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,7 +237,7 @@ static void destroy(private_integrity_checker_t *this)
|
|||||||
/**
|
/**
|
||||||
* See header
|
* See header
|
||||||
*/
|
*/
|
||||||
integrity_checker_t *integrity_checker_create()
|
integrity_checker_t *integrity_checker_create(char *checksum_library)
|
||||||
{
|
{
|
||||||
private_integrity_checker_t *this = malloc_thing(private_integrity_checker_t);
|
private_integrity_checker_t *this = malloc_thing(private_integrity_checker_t);
|
||||||
|
|
||||||
@@ -250,26 +248,30 @@ integrity_checker_t *integrity_checker_create()
|
|||||||
this->public.destroy = (void(*)(integrity_checker_t*))destroy;
|
this->public.destroy = (void(*)(integrity_checker_t*))destroy;
|
||||||
|
|
||||||
this->checksum_count = 0;
|
this->checksum_count = 0;
|
||||||
this->handle = dlopen(CHECKSUM_LIBRARY, RTLD_LAZY);
|
this->handle = NULL;
|
||||||
if (this->handle)
|
if (checksum_library)
|
||||||
{
|
{
|
||||||
int *checksum_count;
|
this->handle = dlopen(checksum_library, RTLD_LAZY);
|
||||||
|
if (this->handle)
|
||||||
this->checksums = dlsym(this->handle, "checksums");
|
|
||||||
checksum_count = dlsym(this->handle, "checksum_count");
|
|
||||||
if (this->checksums && checksum_count)
|
|
||||||
{
|
{
|
||||||
this->checksum_count = *checksum_count;
|
int *checksum_count;
|
||||||
|
|
||||||
|
this->checksums = dlsym(this->handle, "checksums");
|
||||||
|
checksum_count = dlsym(this->handle, "checksum_count");
|
||||||
|
if (this->checksums && checksum_count)
|
||||||
|
{
|
||||||
|
this->checksum_count = *checksum_count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBG1("checksum library '%s' invalid", checksum_library);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBG1("checksum library '%s' invalid", CHECKSUM_LIBRARY);
|
DBG1("loading checksum library '%s' failed", checksum_library);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
DBG1("loading checksum library '%s' failed", CHECKSUM_LIBRARY);
|
|
||||||
}
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ struct integrity_checker_t {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a integrity_checker instance.
|
* Create a integrity_checker instance.
|
||||||
|
*
|
||||||
|
* @param checksum_library library containing checksums
|
||||||
*/
|
*/
|
||||||
integrity_checker_t *integrity_checker_create();
|
integrity_checker_t *integrity_checker_create(char *checksum_library);
|
||||||
|
|
||||||
#endif /* INTEGRITY_CHECKER_H_ @}*/
|
#endif /* INTEGRITY_CHECKER_H_ @}*/
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include <utils/leak_detective.h>
|
#include <utils/leak_detective.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define CHECKSUM_LIBRARY IPSEC_DIR"/libchecksum.so"
|
||||||
|
|
||||||
typedef struct private_library_t private_library_t;
|
typedef struct private_library_t private_library_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,7 +131,7 @@ void library_init(char *settings)
|
|||||||
if (lib->settings->get_bool(lib->settings,
|
if (lib->settings->get_bool(lib->settings,
|
||||||
"libstrongswan.integrity_test", FALSE))
|
"libstrongswan.integrity_test", FALSE))
|
||||||
{
|
{
|
||||||
this->public.integrity = integrity_checker_create();
|
this->public.integrity = integrity_checker_create(CHECKSUM_LIBRARY);
|
||||||
if (!lib->integrity->check_segment(lib->integrity,
|
if (!lib->integrity->check_segment(lib->integrity,
|
||||||
"libstrongswan", library_init))
|
"libstrongswan", library_init))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user