summaryrefslogtreecommitdiff
path: root/main/loader.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2007-11-16 16:56:59 +0000
committerKevin P. Fleming <kpfleming@digium.com>2007-11-16 16:56:59 +0000
commit547306835ea0dcb7f8ea05de79b6f976de89ae9e (patch)
tree0d395555e9304d52b8ccbff9c41623565280a6b9 /main/loader.c
parent2f7440932c2ec97bf61d4f1577b1a56bb6b03e1b (diff)
Merged revisions 89325 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r89325 | kpfleming | 2007-11-16 10:47:46 -0600 (Fri, 16 Nov 2007) | 4 lines To help combat problems where people build external modules (asterisk-addons or others) and then change the build options of the Asterisk build in a way that makes the incompatible without warning, this commit introduces an MD5 signature of the important build-time options and includes that signature into modules when they are built. When the loader loads one of these modules and notices the problem, it will emit a warning to console and refuse to initialize the module, as doing so could cause the system to be unstable or even crash. If you upgrade to this version of Asterisk, you must rebuild *all* of your modules that came from other sources before trying to run this version. If you are using Digium's G.729 binary codec module, you will need v33 or newer. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89326 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/loader.c')
-rw-r--r--main/loader.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/main/loader.c b/main/loader.c
index e51505ea0..b51888dbe 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -76,6 +76,8 @@ static unsigned char expected_key[] =
{ 0x87, 0x76, 0x79, 0x35, 0x23, 0xea, 0x3a, 0xd3,
0x25, 0x2a, 0xbb, 0x35, 0x87, 0xe4, 0x22, 0x24 };
+static unsigned int buildopt_sum[4] = AST_BUILDOPT_SUM;
+
static unsigned int embedding = 1; /* we always start out by registering embedded modules,
since they are here before we dlopen() any
*/
@@ -603,6 +605,8 @@ int ast_module_reload(const char *name)
static unsigned int inspect_module(const struct ast_module *mod)
{
+ unsigned int buildopt_empty[4] = { 0, };
+
if (!mod->info->description) {
ast_log(LOG_WARNING, "Module '%s' does not provide a description.\n", mod->resource);
return 1;
@@ -618,6 +622,13 @@ static unsigned int inspect_module(const struct ast_module *mod)
return 1;
}
+ if (memcmp(buildopt_empty, mod->info->buildopt_sum, sizeof(buildopt_empty)) &&
+ memcmp(buildopt_sum, mod->info->buildopt_sum, sizeof(buildopt_sum))) {
+ ast_log(LOG_WARNING, "Module '%s' was not compiled with the same compile-time options as this version of Asterisk.\n", mod->resource);
+ ast_log(LOG_WARNING, "Module '%s' will not be initialized as it may cause instability.\n", mod->resource);
+ return 1;
+ }
+
return 0;
}