[svn-commits] kpfleming: trunk r89326 - in /trunk: ./ build_tools/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Nov 16 10:57:00 CST 2007


Author: kpfleming
Date: Fri Nov 16 10:56:59 2007
New Revision: 89326

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89326
Log:
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.

........

Modified:
    trunk/   (props changed)
    trunk/build_tools/make_buildopts_h
    trunk/include/asterisk/module.h
    trunk/main/loader.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/build_tools/make_buildopts_h
URL: http://svn.digium.com/view/asterisk/trunk/build_tools/make_buildopts_h?view=diff&rev=89326&r1=89325&r2=89326
==============================================================================
--- trunk/build_tools/make_buildopts_h (original)
+++ trunk/build_tools/make_buildopts_h Fri Nov 16 10:56:59 2007
@@ -19,4 +19,7 @@
 if ${GREP} AST_DEVMODE makeopts | ${GREP} -q yes
 then
 	echo "#define AST_DEVMODE 1"
+	TMP="${TMP} AST_DEVMODE"
 fi
+BUILDSUM=`echo ${TMP} | md5sum`
+echo "#define AST_BUILDOPT_SUM {0x${BUILDSUM:0:8}, 0x${BUILDSUM:8:8}, 0x${BUILDSUM:16:8}, 0x${BUILDSUM:24:8}}"

Modified: trunk/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/module.h?view=diff&rev=89326&r1=89325&r2=89326
==============================================================================
--- trunk/include/asterisk/module.h (original)
+++ trunk/include/asterisk/module.h Fri Nov 16 10:56:59 2007
@@ -216,6 +216,7 @@
 
 	const char *key;
 	unsigned int flags;
+	unsigned int buildopt_sum[4];		/* The value of AST_BUILDOPT_SUM when this module was compiled */
 };
 
 void ast_module_register(const struct ast_module_info *);
@@ -242,7 +243,8 @@
 		AST_MODULE,				\
 		desc,					\
 		keystr,					\
-		flags_to_set				\
+		flags_to_set,				\
+		AST_BUILDOPT_SUM,			\
 	};						\
 	static void  __attribute__ ((constructor)) __reg_module(void) \
 	{ \
@@ -343,6 +345,7 @@
 		.flags = flags_to_set,				\
 		.description = desc,				\
 		.key = keystr,					\
+		.buildopt_sum = AST_BUILDOPT_SUM,		\
 		fields						\
 	};							\
 	static void  __attribute__ ((constructor)) __reg_module(void) \

Modified: trunk/main/loader.c
URL: http://svn.digium.com/view/asterisk/trunk/main/loader.c?view=diff&rev=89326&r1=89325&r2=89326
==============================================================================
--- trunk/main/loader.c (original)
+++ trunk/main/loader.c Fri Nov 16 10:56:59 2007
@@ -76,6 +76,8 @@
 { 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 @@
 
 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;
@@ -615,6 +619,13 @@
 
 	if (verify_key((unsigned char *) mod->info->key)) {
 		ast_log(LOG_WARNING, "Module '%s' did not provide a valid license key.\n", mod->resource);
+		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;
 	}
 




More information about the svn-commits mailing list