Greetings,
I’m attempting to interact with DBUS from a Go application. I’m using the godbus library to handle the communication. I’m unable to connect to the system bus. I receive the following error:
2018/01/29 18:29:26 Unable to connect to systembus: dial unix unix:path=/host/run/dbus/system_bus_socket: connect: no such file or directory
Here is a snippet of the code:
// get a bus connection connection, err := dbus.SystemBus() if err != nil { log.Fatalf("Unable to connect to systembus: %v", err) }
In my DOCKERFILE, I have:
FROM resin/%%RESIN_MACHINE_NAME%%-golang:slim
ENV INITSYSTEM on
ENV DBUS_SYSTEM_BUS_ADDRESS unix:path=/host/run/dbus/system_bus_socketRUN apt-get update && apt-get install -yq dbus
RUN go get GitHub - godbus/dbus: Native Go bindings for D-Bus
… application specific stuff
I have verified via printenv | grep dbus that the environment variable is properly set. To be triply sure, I’ve exported the environment variable in my container before running the Go script that connects to dbus. I’ve also checked the directory /host/run/dbus/ and have verified a socket file entitled system_bus_socket.
To further debug, I installed the dbus package in my container and ran a sample command to see if things would work:
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
dbus-send
–system
–print-reply
–reply-timeout=2000
–type=method_call
–dest=org.freedesktop.timedate1
/org/freedesktop/timedate1
org.freedesktop.DBus.Properties.GetAll
string:“org.freedesktop.timedate1”
I received a response back that matched what was expressed in “Container Runtime” resin page (having trouble linking…).
I’m pretty sure it’s a valid test case because of the BUS_ADDRESS export, but I’m not super experienced with dbus to know for sure.
System Information
Host OS: Resin OS 2.7.8+rev1 (dev)
Supervisor: 6.4.2
Any help is appreciated.
Thanks!