[PATCH 4/5] Tests for <allow>/<deny> message arguments.
Pekka Pessi
Pekka.Pessi at nokia.com
Fri Jun 4 09:58:45 PDT 2010
---
test/data/invalid-config-files/badargs-1.conf | 15 ++++++++++++
test/data/invalid-config-files/badargs-2.conf | 15 ++++++++++++
test/data/invalid-config-files/badargs-3.conf | 15 ++++++++++++
test/data/invalid-config-files/badargs-4.conf | 15 ++++++++++++
test/data/invalid-config-files/badargs-5.conf | 15 ++++++++++++
test/data/invalid-config-files/badargs-6.conf | 15 ++++++++++++
test/data/invalid-config-files/badargs-7.conf | 14 ++++++++++++
test/data/invalid-config-files/badargs-8.conf | 14 ++++++++++++
test/data/invalid-config-files/badargs-9.conf | 14 ++++++++++++
test/data/valid-config-files/policy-args-1.conf | 24 ++++++++++++++++++++
test/name-test/run-test-systemserver.sh | 27 +++++++++++++++++++++++
test/name-test/tmp-session-like-system.conf | 11 +++++++++
12 files changed, 194 insertions(+), 0 deletions(-)
create mode 100644 test/data/invalid-config-files/badargs-1.conf
create mode 100644 test/data/invalid-config-files/badargs-2.conf
create mode 100644 test/data/invalid-config-files/badargs-3.conf
create mode 100644 test/data/invalid-config-files/badargs-4.conf
create mode 100644 test/data/invalid-config-files/badargs-5.conf
create mode 100644 test/data/invalid-config-files/badargs-6.conf
create mode 100644 test/data/invalid-config-files/badargs-7.conf
create mode 100644 test/data/invalid-config-files/badargs-8.conf
create mode 100644 test/data/invalid-config-files/badargs-9.conf
create mode 100644 test/data/valid-config-files/policy-args-1.conf
diff --git a/test/data/invalid-config-files/badargs-1.conf b/test/data/invalid-config-files/badargs-1.conf
new file mode 100644
index 0000000..ee75374
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-1.conf
@@ -0,0 +1,15 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- No arguments in send_signature -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_signature="" send_arg0="kuik" />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-2.conf b/test/data/invalid-config-files/badargs-2.conf
new file mode 100644
index 0000000..bad12b7
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-2.conf
@@ -0,0 +1,15 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- Invalid value (for byte) -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_signature="sy" send_arg0="kuik" send_arg1="256" />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-3.conf b/test/data/invalid-config-files/badargs-3.conf
new file mode 100644
index 0000000..06faaa9
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-3.conf
@@ -0,0 +1,15 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- Extra characters after value -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_signature="sy" send_arg0="kuik" send_arg1="128 " />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-4.conf b/test/data/invalid-config-files/badargs-4.conf
new file mode 100644
index 0000000..55c5d51
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-4.conf
@@ -0,0 +1,15 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- Too many arguments (arg0..arg29 are supported) -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_signature="ssssssssssssssssssssssssssssss" send_arg30="kuik" />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-5.conf b/test/data/invalid-config-files/badargs-5.conf
new file mode 100644
index 0000000..556c917
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-5.conf
@@ -0,0 +1,15 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- Missing send_signature -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_arg0="kuik" />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-6.conf b/test/data/invalid-config-files/badargs-6.conf
new file mode 100644
index 0000000..924b96e
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-6.conf
@@ -0,0 +1,15 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- Duplicate attribute (detected by XML parser) -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_signature="s" send_arg0="kuik" send_arg0="tilu" />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-7.conf b/test/data/invalid-config-files/badargs-7.conf
new file mode 100644
index 0000000..2a45377
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-7.conf
@@ -0,0 +1,14 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- Unrecognized attribute -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo" extra_attribute="foo" />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-8.conf b/test/data/invalid-config-files/badargs-8.conf
new file mode 100644
index 0000000..7621e1f
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-8.conf
@@ -0,0 +1,14 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- sscanf() thinks -0xffffffff is 1 -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo" send_signature="sss" send_arg-0xffffffff="kuik" />
+ </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/badargs-9.conf b/test/data/invalid-config-files/badargs-9.conf
new file mode 100644
index 0000000..ceb798d
--- /dev/null
+++ b/test/data/invalid-config-files/badargs-9.conf
@@ -0,0 +1,14 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <servicedir>/usr/share/foo</servicedir>
+ <policy context="default">
+ <!-- Leading zeros in attribute name -->
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo" send_signature="sss" send_arg010="kuik" />
+ </policy>
+</busconfig>
diff --git a/test/data/valid-config-files/policy-args-1.conf b/test/data/valid-config-files/policy-args-1.conf
new file mode 100644
index 0000000..81e11f5
--- /dev/null
+++ b/test/data/valid-config-files/policy-args-1.conf
@@ -0,0 +1,24 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>mybususer</user>
+ <listen>unix:path=/foo/bar</listen>
+ <listen>tcp:port=1234</listen>
+ <includedir>basic.d</includedir>
+ <standard_session_servicedirs />
+ <servicedir>/usr/share/foo</servicedir>
+
+ <policy context="default">
+ <allow user="*"/>
+ <allow send_signature="s" send_arg0="string"/>
+ <allow send_signature="sis" send_arg1="1245"/>
+ <allow send_signature="sa(yaay)b" send_arg2="true"/>
+ <allow send_signature="bynqiuxtdsogay"
+ send_arg0="true" send_arg1="0xbf" send_arg2="-8192" send_arg3="65535"
+ send_arg4="-01234567" send_arg5="0xffffffff"
+ send_arg6="-4294967296" send_arg7="0xffff0000ffff0000"
+ send_arg8="-2.3283064365386963e-10" send_arg9="kuik"
+ send_arg10="/foo/bar" send_arg11="bynqiuxtdsogay"
+ send_arg12="" />
+ </policy>
+</busconfig>
diff --git a/test/name-test/run-test-systemserver.sh b/test/name-test/run-test-systemserver.sh
index d3b8d55..cc358b7 100755
--- a/test/name-test/run-test-systemserver.sh
+++ b/test/name-test/run-test-systemserver.sh
@@ -40,6 +40,33 @@ if ! grep -q 'DBus.Error' echo-error-output.tmp; then
exit 1
fi
+echo "running test-echo-argcheck-pass"
+if ! ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/tools/dbus-send --print-reply --dest=org.freedesktop.DBus.TestSuiteEchoService /org/freedesktop/TestSuite org.freedesktop.TestSuite.Echo string:hello > echo-error-output-2.tmp 2>&1 ; then
+ echo "Argument check did not allow message; output was:"
+ echo "====="
+ cat echo-error-output-2.tmp
+ echo "====="
+ exit 1
+fi
+
+echo "running test-echo-argcheck-pass"
+# Echo server does not check signature in incoming messages
+if ! ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG \
+ $DBUS_TOP_BUILDDIR/tools/dbus-send --print-reply \
+ --dest=org.freedesktop.DBus.TestSuiteEchoService /org/freedesktop/TestSuite \
+ org.freedesktop.TestSuite.Echo string:pass \
+ int16:-16 uint16:16 int32:-32 uint32:32 int64:-64 uint64:64 \
+ double:-2.3283064365386963e-10 byte:66 boolean:true \
+ objpath:/pass/me > echo-error-output-3.tmp 2>&1
+then
+ echo "Argument check did not allow message; output was:"
+ echo "====="
+ cat echo-error-output-3.tmp
+ echo "====="
+ exit 1
+fi
+
+
echo "running test echo signal"
if ! python $DBUS_TOP_SRCDIR/test/name-test/test-wait-for-echo.py; then
echo "Failed test-wait-for-echo"
diff --git a/test/name-test/tmp-session-like-system.conf b/test/name-test/tmp-session-like-system.conf
index 29ab115..e9ca62d 100644
--- a/test/name-test/tmp-session-like-system.conf
+++ b/test/name-test/tmp-session-like-system.conf
@@ -54,6 +54,17 @@
<allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
send_interface="org.freedesktop.TestSuite"
send_member="EmitFoo"/>
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_signature="s" send_arg0="hello" />
+ <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+ send_interface="org.freedesktop.TestSuite"
+ send_member="Echo"
+ send_signature="snqiuxtdybo" send_arg0="pass"
+ send_arg1="-16" send_arg2="16" send_arg3="-32" send_arg4="32"
+ send_arg5="-64" send_arg6="64" send_arg7="-2.3283064365386963e-10" send_arg8="66"
+ send_arg9="true" send_arg10="/pass/me" />
</policy>
<policy context="default">
--
1.6.3.3
More information about the dbus
mailing list