DBus

From Mumble Wiki
Revision as of 14:08, 21 April 2009 by DD0T (Talk | contribs)

Jump to: navigation, search

What is DBus for Murmur

D-Bus is a free software project which offers a simple way for applications to communicate with one another.
It is developed by Red Hat as part of the freedesktop.org project. - Wikipedia

DBus can be used as an RPC method for controlling murmur from another application.

WARNING: The DBus interface for the server is deprecated and will not be extended any more. Use the ICE interface instead.

Configuring DBus for Murmur

Since point-to-point DBus connections don't work in Qt yet, you have two options to configure Murmur for dbus use.

A Windows machine

Since Murmur can't run without an active desktop on windows, you can safely ignore this setup. Just make sure your murmur.ini says

dbus=session

Your own machine with root access

If you own the box you're running murmur on, and you have only one murmur process, you'll want to use the system dbus. The first step is creating a new file called /etc/dbus-1/system.d/murmurd.conf

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

  <policy user="mumble">
    <allow own="net.sourceforge.mumble.murmur"/>
  </policy>
  <policy user="root">
    <allow own="net.sourceforge.mumble.murmur"/>
  </policy>

  <policy context="default">
    <allow send_destination="net.sourceforge.mumble.murmur"/>
    <allow receive_sender="net.sourceforge.mumble.murmur"/>
  </policy>
</busconfig>

Then restart the system dbus daemon. Please note that this configuration allows anyone with a user on your machine to control the murmur process, so you might want to tighten security slightly.

In your murmur.ini, make sure it says

dbus=system

A shared machine

First, we'll have to start a dbus daemon and place the session info somewhere.

dbus-launch --sh-syntax > ~/.dbus.sh
source ~/.dbus.sh

Make sure your murmur.ini has

dbus=session

Since there can be many session busses on a system, you'll always need to specify which one to use. So for every new shell you open, you should always

source ~/.dbus.sh

You should not put the above into your .bashrc or similar, as most X sessions will have their own and separate session dbus.

When using the session bus, only the userid who created the bus can use it. Hence, you have to make sure that any scripts you write run with the same user ID.

Making sure it works

Start murmur with the options -fg -v, which will run it in the foreground with full debugging. You should see the line "DBus registration succeeded".

If your distribution includes the full Qt4 tools package, you'll have a program called qdbus which can be used to inspect the dbus system. Try running

qdbus --system net.sourceforge.mumble.murmur /

or if you're using the session bus:

qdbus --session net.sourceforge.mumble.murmur /

You should see a long list of function names. You can actually use the simpler functions directly from qdbus. For example, you can set a new superuser password with

qdbus --system net.sourceforge.mumble.murmur / net.sourceforge.mumble.Meta.setSuperUserPassword 1 supahsecret

If you don't have qdbus, try this

dbus-send --system --dest=net.sourceforge.mumble.murmur --type=method_call --print-reply / org.freedesktop.DBus.Introspectable.Introspect

Documentation

You can use the Introspect method for receiving a list of all available commands. A simple script to create an output can look like this:

#!/usr/bin/python
import dbus

dbus_base = 'net.sourceforge.mumble.murmur'
bus = dbus.SystemBus()
proxy = bus.get_object(dbus_base, '/')
murmur = dbus.Interface(proxy, 'net.sourceforge.mumble.Meta')
print murmur.Introspect(dbus_interface='org.freedesktop.DBus.Introspectable')

For a documentation of all dbus methods have a look at DBus Methods.

Showing the list of users on a webpage

There is a small perl example called scripts/weblist.pl in the mumble distribution. It works as a CGI for most systems.

Using a PhpBB3 as authentication source

There is an extended example of how to use the authenticator called scripts/dbusauth.pl. You'll need to configure where your phpBB3 database resides, but once that is done you'll simply have to run the script after starting murmur to allow authentication to be done through the phpBB3 database.

Any group associations the user has on phpBB3 is copied to a temporary group on a root channel (and by default inherited to all subchannels). Please note that this is a temporary group membership and as such will not show up in the Edit ACL dialogs.

What DBus is for Mumble

The Mumble client itself can also be controlled over DBus. At the moment the following functionality is exposed:

  • Direct the client to a URLs
  • Mute/Deafen self