Calling dbus from Apache and getting the X11 initialization error.

Mike MacHenry dskippy at ccs.neu.edu
Sun Dec 27 22:04:48 PST 2009


I am looking for a work around to the "Autolaunch error: X11
initialization failed." that it seems a lot of forums have discussions
about. There have been suggests to solve this problem by setting the
DISPLAY environment variable, but this does not work for me. I think
because that trick works for cron jobs but not Apache processes.
Here's the simple description of my problem:

I have a DBus server process running. It has an interface with one
method, skip_ahead, which has no arguments. I run the following Python
code from a normal user's account:

import dbus
bus = dbus.SessionBus()
remote_object = bus.get_object("org.roundware.StreamScript", "/foo")
iface = dbus.Interface(remote_object, "org.roundware.StreamScriptInterface")
remote_object.skip_ahead(dbus_interface = "org.roundware.StreamScriptInterface")

The result is that my DBus server gets the message as planned. Running
that same script from the web as a CGI script gives me "Autolaunch
error: X11 initialization failed." Running the script when I change to
the Apache user, www-data also gives me that error. Solutions I have
tried:

Runnng the script with DISPLAY=:0.0
Putting os.putenv('DISPLAY',':0.0') in the script as the first line.
Running the script with setuid and using subprocess.Popen (with both
shell true and false) and setting the DISPLAY env var.

None of these work. Running it as root works, however. Which confuses
me. Here's the script's permissions:
-rwsr-sr-x 1 root root 375 2009-12-28 00:48 /usr/local/bin/streamscriptctl

Does anyone know how I can use dbus from Apache? Thanks for your help.

-mike


More information about the dbus mailing list