diff --git a/dbus/dbus.go b/dbus/dbus.go index a6bd1fd0..e105b932 100644 --- a/dbus/dbus.go +++ b/dbus/dbus.go @@ -86,16 +86,23 @@ type Conn struct { } // New establishes a connection to the system bus and authenticates. +// Callers should call Close() when done with the connection. func New() (*Conn, error) { return newConnection(dbus.SystemBusPrivate) } // NewUserConnection establishes a connection to the session bus and // authenticates. This can be used to connect to systemd user instances. +// Callers should call Close() when done with the connection. func NewUserConnection() (*Conn, error) { return newConnection(dbus.SessionBusPrivate) } +// Close closes an established connection +func (c *Conn) Close() { + c.sysconn.Close() +} + func newConnection(createBus func() (*dbus.Conn, error)) (*Conn, error) { sysconn, err := dbusConnection(createBus) if err != nil {