I'm trying to connect to DBus from a PHP program.
When I run the program from command-line, it works, but when it is run by the Apache webserver (running as user apache
) it cannot connect to the bus.
I tried both calling qdbus
with system
and calling a Python script using python-dbus, but it doesn't work in either way. Also, I cannot manage to compile this PHP extension, but I don't think that it will solve my problem.
I think that the problem is that the DBus daemon that provides the session bus is running as my user (the system bus one is running as messagebus
), but PHP runs as apache
.
How can I do to connect to the other user's bus?
(This is not working for me.)
First of all, do you have a dbus method you are trying to call? Dbus is merely the transportation layer, you need a program that hosts a dbus method and a program that calls a dbus method. I'll assume you have a dbus method you want to call from your php program.
How is apache trying to call your dbus method? If you are using a system() method or similar from php to call qdbus, that will fail. PHP is run by apache, apache does not have an autologin dbus process like your user does and no X11 access. This means in order for your apache to have dbus, you have to use:
eval 'dbus-launch --auto-syntax' [command]
when using PHP's system(). That is not optimal though.
Some solutions are: