<div dir="ltr"><font face="courier new, monospace">I'm using a Raspberry Pi, running Raspian.</font><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">I am trying to build a simple service in Python using dbus, this service talks to a battery monitor using SPI and can return the voltage as well as turn off power to the system.</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">I have a Python program that correctly registers on the system bus, and another Python program that can connect over the bus and do RPC to read the values of the battery and send the off command. This all works when I start the programs from the terminal window.</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">However, I have created a .service file for it, and made it accessible by adding a services directory in /etc/dbus-1/system-local.conf. The service file has a proper name, path, and user (the user is the system default user "pi")</font></div>
<div><font face="courier new, monospace">When I start the client application, and it tries to activate the service over the bus, I get an execption that the environment could not be set up.</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.FailedToSetup: Failed to setup environment correctly<br clear="all"></font><div><div dir="ltr"><font face="courier new, monospace"><br>
</font></div><div dir="ltr"><font face="courier new, monospace">When reading the source of the activation helper, there seems to be four cases that generate this error, having to do with getting the user pwent, and setting up the user group. There are four separate error details, but as you can see, those details are not plumbed through to the client so I can't read them. Nothing helpful is found in syslog:</font></div>
<div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace"><div dir="ltr">Aug 3 15:11:01 raspberrypi dbus[3143]: [system] Activating service name='net.watte.robots.voltmon' (using servicehelper)</div>
<div dir="ltr">Aug 3 15:11:01 raspberrypi dbus[3143]: [system] Activated service 'net.watte.robots.voltmon' failed: Failed to setup environment correctly</div><div><br></div><div><br></div><div>The .service file is available here:</div>
<div><a href="https://gist.github.com/jwatte/32d7ef77f9738dd11c54">https://gist.github.com/jwatte/32d7ef77f9738dd11c54</a><br></div></font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr">
<font face="courier new, monospace">The server program is here:</font></div><div dir="ltr"><font face="courier new, monospace"><a href="https://gist.github.com/jwatte/2e412dac849a3404186d">https://gist.github.com/jwatte/2e412dac849a3404186d</a><br>
</font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace">The client module is here:</font></div><div dir="ltr"><font face="courier new, monospace"><a href="https://gist.github.com/jwatte/57ed2069d2287d4abc3b">https://gist.github.com/jwatte/57ed2069d2287d4abc3b</a><br>
</font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace">I have also created /etc/dbus-1/system.d/net.watte.robots.voltmin.conf, although I don't know whether this is required or not:</font></div>
<div dir="ltr"><font face="courier new, monospace"><a href="https://gist.github.com/jwatte/950296c8a3fdbe01c13a">https://gist.github.com/jwatte/950296c8a3fdbe01c13a</a></font></div><div dir="ltr"><font face="courier new, monospace"><br>
</font></div><div dir="ltr"><font face="courier new, monospace">And, finally, here is my system-local.conf:</font></div><div dir="ltr"><font face="courier new, monospace"><a href="https://gist.github.com/jwatte/c218ee21683faa371e8c">https://gist.github.com/jwatte/c218ee21683faa371e8c</a></font></div>
<div dir="ltr"><font face="courier new, monospace"><br><br>Using dbus-monitor, I cannot actually see the call tho activate this service; I can just see some name changed signals. I have edited system.conf to allow root to eavesdrop on anything, not just signals. </font></div>
<div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace"><br>I have two questions:</font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div>
<div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace">1) How can I read the additional error information about this activation failure? I want to know which of the four error cases it's actually hitting, for further debugging.</font></div>
<div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">2) Is there something obvious I'm doing wrong here? Can I use the "pi" user for this service on the system bus, for example, or is that a problem? In desperation, I tried adding the "pi" user to the "messagebus" group, but that didn't help.</font></div>
<div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace"><br><font>Sincerely,</font><br><br>
<font>Jon Watte</font><br><br><br>--<br>"<span style="color:rgb(0,0,0)">I find that the harder I work, the more luck I seem to have." -- Thomas Jefferson</span></font></div>
</div>
</div></div>