dbusmgr

package
v1.29.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Code in this package is heavily adapted from https://github.com/opencontainers/runc/blob/7362fa2d282feffb9b19911150e01e390a23899d/libcontainer/cgroups/systemd Credit goes to the runc authors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectUID

func DetectUID() (int, error)

DetectUID detects UID from the OwnerUID field of `busctl --user status` if running in userNS. The value corresponds to sd_bus_creds_get_owner_uid(3) .

Otherwise returns os.Getuid() .

func DetectUserDbusSessionBusAddress

func DetectUserDbusSessionBusAddress() (string, error)

DetectUserDbusSessionBusAddress returns $DBUS_SESSION_BUS_ADDRESS if set. Otherwise returns "unix:path=$XDG_RUNTIME_DIR/bus" if $XDG_RUNTIME_DIR/bus exists. Otherwise parses the value from `systemctl --user show-environment` .

Types

type DbusConnManager

type DbusConnManager struct{}

func NewDbusConnManager

func NewDbusConnManager(rootless bool) *DbusConnManager

NewDbusConnManager initializes systemd dbus connection manager.

func (*DbusConnManager) GetConnection

func (d *DbusConnManager) GetConnection() (*systemdDbus.Conn, error)

getConnection lazily initializes and returns systemd dbus connection.

func (*DbusConnManager) RetryOnDisconnect

func (d *DbusConnManager) RetryOnDisconnect(op func(*systemdDbus.Conn) error) error

RetryOnDisconnect calls op, and if the error it returns is about closed dbus connection, the connection is re-established and the op is retried. This helps with the situation when dbus is restarted and we have a stale connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL