in_signature validation question

Edward Balas ebalas at grnoc.iu.edu
Sat Aug 13 07:29:03 PDT 2011


All,

I have recently I've started working with DBus and so am a bit of a greenhorn... with that said, I've run into something I'm struggling to understand and was wondering if anyone could help shed some light on the behavior of input validation based on in_signature.

Problem:
- I have a demo method that I have setup with a specific in_signature.
- When I send a request that does not match the signature, the malformed data is passed to the method
- This seems to imply nothing is providing signature validation?  


Demo Code:
-------------------------------------------------------------------------------------------------

import gobject
import dbus
import dbus.service
import dbus.mainloop.glib

class Example(dbus.service.Object):
  def __init__(self, bus,path):
      dbus.service.Object.__init__(self, bus, path)

  @dbus.service.method(dbus_interface='org.demo.example',
                       in_signature='u',
                       out_signature='s'
                       )
  def hmm(self, a2):
      print a2
      return str(a2)

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
name = dbus.service.BusName("org.demo.example", bus)
object = Example(bus, '/controller1')
mainloop = gobject.MainLoop()
print "Running example service."
mainloop.run()

Test Output:
#------------------------------------------------------------------------------------------------------
op at vm:~$ sudo qdbus --system org.demo.example /controller1 
method QString org.demo.example.hmm(uint a2)
method QString org.freedesktop.DBus.Introspectable.Introspect()
opf at vm:~$

From the qdbus command it would appear that I have a method that only accepts a uint as input, yet if I pass a dict, dbus seems to pass that along just the same.

op at vm:~$ sudo dbus-send --type=method_call --print-reply --system --dest=org.demo.example /controller1 org.demo.example.hmm 'dict:uint32:string:1,should this ,2,fail?'

method return sender=:1.19 -> dest=:1.22 reply_serial=2 string "dbus.Dictionary({dbus.UInt32(1L): dbus.String(u'should this '), dbus.UInt32(2L): dbus.String(u'fail?')}, signature=dbus.Signature('us'))" 

op at vm:~$  

I had been assuming that the dbus-daemon was responsible for validating input and would have rejected the method call that did not conform to the signature,  is my understanding off? is this system behaving in an unexpected way?
	
Any insights would be most welcome.

Edward Balas
317-313-2646
ebalas at grnoc.iu.edu






More information about the dbus mailing list