Bug 18229: Allow signals
authorColin Walters <walters@verbum.org>
Tue, 9 Dec 2008 14:15:06 +0000 (09:15 -0500)
committerColin Walters <walters@verbum.org>
Tue, 9 Dec 2008 14:15:06 +0000 (09:15 -0500)
Our previous fix went too far towards lockdown; many things rely
on signals to work, and there's no really good reason to restrict
which signals can be emitted on the bus because we can't tie
them to a particular sender.

bus/system.conf.in
test/name-test/Makefile.am
test/name-test/run-test-systemserver.sh
test/name-test/test-wait-for-echo.py [new file with mode: 0755]
test/name-test/tmp-session-like-system.conf

index ac2822fa510fb39fe29b3971b8381bee8b1366f5..1b6e716ae5c912e14d9033d1d20f6641d02f9cd5 100644 (file)
@@ -50,6 +50,8 @@
          even if they aren't in here -->
     <allow send_destination="org.freedesktop.DBus"/>
     <allow receive_sender="org.freedesktop.DBus"/>
+    <!-- Allow all signals to be sent by default -->
+    <allow send_type="signal"/>
     <!-- allow sending valid replies -->
     <allow send_requested_reply="true" send_type="method_return"/>
     <allow send_requested_reply="true" send_type="error"/>
index fee1e606d8cb661e8ed4cfb9cd535e45a91dece7..10a2536d8f7ad4bb95fc27211fa56a393f8be772 100644 (file)
@@ -10,7 +10,7 @@ else
 TESTS=
 endif
 
-EXTRA_DIST=run-test.sh 
+EXTRA_DIST=run-test.sh run-test-systemserver.sh test-wait-for-echo.py
 
 if DBUS_BUILD_TESTS
 
index fd82326c729ba278069a7c0ec8c36397ee5fbaf4..34dd6487564e1458a5e38a7b7012ca2687c92fa4 100755 (executable)
@@ -39,3 +39,12 @@ if ! grep -q 'DBus.Error' echo-error-output.tmp; then
   echo "====="
   exit 1
 fi
+
+echo "running test echo signal"
+if ! python ./test-wait-for-echo.py; then
+  echo "Failed test-wait-for-echo"
+  exit 1
+fi
+
+
+exit 0
diff --git a/test/name-test/test-wait-for-echo.py b/test/name-test/test-wait-for-echo.py
new file mode 100755 (executable)
index 0000000..bd09e45
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+import os,sys
+
+try:
+    import gobject
+    import dbus
+    import dbus.mainloop.glib
+except:
+    print "Failed import, aborting test"
+    sys.exit(0)
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+loop = gobject.MainLoop()
+
+exitcode = 0
+
+def handle_noreceipt():
+    print "Failed to get signal"
+    global exitcode
+    exitcode = 1
+    loop.quit()
+
+gobject.timeout_add(7000, handle_noreceipt)
+
+bus = dbus.SessionBus()
+
+def sighandler(*args, **kwargs):
+    print "got signal"
+    loop.quit()   
+
+bus.add_signal_receiver(sighandler, dbus_interface='org.freedesktop.TestSuite', signal_name='Foo')
+
+o = bus.get_object('org.freedesktop.DBus.TestSuiteEchoService', '/org/freedesktop/TestSuite')
+i = dbus.Interface(o, 'org.freedesktop.TestSuite')
+def nullhandler(*args, **kwargs):
+    pass
+i.EmitFoo(reply_handler=nullhandler, error_handler=nullhandler)
+
+loop.run()
+sys.exit(exitcode)
index e483c89bb0f63ddf8fa5d6b7797a2e87cdb62479..96bbf7643353dacba01ed4c1cf5b89025ac9e235 100644 (file)
@@ -29,6 +29,8 @@
          even if they aren't in here -->
     <allow send_destination="org.freedesktop.DBus"/>
     <allow receive_sender="org.freedesktop.DBus"/>
+    <!-- Allow all signals to be sent by default -->
+    <allow send_type="signal"/>
     <!-- valid replies are always allowed -->
     <allow send_requested_reply="true" send_type="method_return"/>
     <allow send_requested_reply="true" send_type="error"/>
 
   <policy context="default">
      <allow own="org.freedesktop.DBus.TestSuiteEchoService"/>
+     <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+            send_interface="org.freedesktop.DBus.Introspectable"/>
+     <allow send_destination="org.freedesktop.DBus.TestSuiteEchoService"
+            send_interface="org.freedesktop.TestSuite"
+            send_member="EmitFoo"/>
   </policy>
 
   <!-- Config files are placed here that among other things,