summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/talloc/test_magic_differs.sh14
-rw-r--r--lib/talloc/test_magic_differs_helper.c12
-rw-r--r--lib/talloc/wscript11
3 files changed, 36 insertions, 1 deletions
diff --git a/lib/talloc/test_magic_differs.sh b/lib/talloc/test_magic_differs.sh
new file mode 100755
index 00000000000..0f765f0e032
--- /dev/null
+++ b/lib/talloc/test_magic_differs.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# This test ensures that two different talloc processes do not use the same
+# magic value to lessen the opportunity for transferrable attacks.
+
+echo "test: magic differs"
+
+if [
+ "`./talloc_test_magic_differs_helper`" != "`./talloc_test_magic_differs_helper`"
+]; then
+ echo "failure: magic remained the same between executions"
+ exit 1
+fi
+
+echo "success: magic differs"
diff --git a/lib/talloc/test_magic_differs_helper.c b/lib/talloc/test_magic_differs_helper.c
new file mode 100644
index 00000000000..6798827abb1
--- /dev/null
+++ b/lib/talloc/test_magic_differs_helper.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include "talloc.h"
+
+/*
+ * This program is called by a testing shell script in order to ensure that
+ * if the library is loaded into different processes it uses different magic
+ * values in order to thwart security attacks.
+ */
+int main(int argc, char *argv[]) {
+ printf("%i\n", talloc_test_get_magic());
+ return 0;
+}
diff --git a/lib/talloc/wscript b/lib/talloc/wscript
index 19294d9b9b4..9cedbbf8070 100644
--- a/lib/talloc/wscript
+++ b/lib/talloc/wscript
@@ -100,6 +100,10 @@ def build(bld):
testsuite_deps,
install=False)
+ bld.SAMBA_BINARY('talloc_test_magic_differs_helper',
+ 'test_magic_differs_helper.c',
+ 'talloc', install=False)
+
else:
private_library = True
@@ -154,9 +158,14 @@ def test(ctx):
cmd = os.path.join(Utils.g_module.blddir, 'talloc_testsuite')
ret = samba_utils.RUN_COMMAND(cmd)
print("testsuite returned %d" % ret)
+ magic_cmd = os.path.join(srcdir, 'lib', 'talloc',
+ 'test_magic_differs.sh')
+
+ magic_ret = samba_utils.RUN_COMMAND(magic_cmd)
+ print("magic differs test returned %d" % magic_ret)
pyret = samba_utils.RUN_PYTHON_TESTS(['test_pytalloc.py'])
print("python testsuite returned %d" % pyret)
- sys.exit(ret or pyret)
+ sys.exit(ret or magic_ret or pyret)
def dist():
'''makes a tarball for distribution'''