register bash script as dbus object

David Zeuthen david at fubar.dk
Fri Dec 12 10:49:46 PST 2008


On Fri, 2008-12-12 at 09:12 +0300, Александр Лавриненко wrote:
> Greetings everybody!
> 
> I'm trying to write daemon app that needs to register itself with D-BUS as 
> object under some well-known name (say, org.acme.foo). This app whould 
> receive requests for methods and send signals. The problem is that this 
> daemon app needs to be written as bash script. I couldn't find decent docs 
> (preferably with basic examples) on how to achieve this from #!/bin/bash 
> scripts.
> 
> If someone can point me to the docs describing the way to implement dbus 
> object and dbus client with bash scripting this would be great!

This sounds like an incredibly bad idea *especially* if you intend to
expose such things on the system message bus. The reason it's a bad idea
is that with IPC (especially if it crosses the user<->system boundary)
you generally don't want to trust any input from the other end. In other
words, well-written D-Bus services has to be written with paranoia in
mind and generally assume the other end is malicious / compromised.

Hence, you really don't want to use a programming language like bash(1)
for D-Bus services. Remember that there's an extremely good reason that
bash(1) refuses to honor the setuid bit on shell scripts, namely that
it's not a good idea to use this kind of programming language for
untrusted data; it's just way to easy to screw things up.

(FWIW, I actually enjoy writing bash shell scripts myself; shell syntax
is extremely loose and expressive and helps getting things done. It's
just the totally wrong choice for implementing D-Bus services.)

Hope this helps.

     David




More information about the dbus mailing list