dbus

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package dbus wraps xdg-dbus-proxy and implements configuration and sandboxing of the underlying helper process.

Index

Constants

View Source
const (
	SessionBusAddress = "DBUS_SESSION_BUS_ADDRESS"
	SystemBusAddress  = "DBUS_SYSTEM_BUS_ADDRESS"
)

Variables

View Source
var (
	ErrConfig = errors.New("no configuration to seal")
)
View Source
var ProxyName = "xdg-dbus-proxy"

ProxyName is the file name or path to the proxy program. Overriding ProxyName will only affect Proxy instance created after the change.

Functions

func Address

func Address() (session, system string)

Types

type AddrEntry added in v0.2.9

type AddrEntry struct {
	Method string      `json:"method"`
	Values [][2]string `json:"values"`
}

func Parse added in v0.2.9

func Parse(addr []byte) ([]AddrEntry, error)

Parse parses D-Bus address according to https://dbus.freedesktop.org/doc/dbus-specification.html#addresses

type BadAddressError added in v0.2.9

type BadAddressError struct {
	// error type
	Type ParseError

	// bad entry position
	EntryPos int
	// bad entry value
	EntryVal []byte

	// bad pair position
	PairPos int
	// bad pair value
	PairVal []byte
}

func (*BadAddressError) Error added in v0.2.9

func (a *BadAddressError) Error() string

func (*BadAddressError) Is added in v0.2.9

func (a *BadAddressError) Is(err error) bool

func (*BadAddressError) Unwrap added in v0.2.9

func (a *BadAddressError) Unwrap() error

type Config

type Config struct {
	// See set 'see' policy for NAME (--see=NAME)
	See []string `json:"see"`
	// Talk set 'talk' policy for NAME (--talk=NAME)
	Talk []string `json:"talk"`
	// Own set 'own' policy for NAME (--own=NAME)
	Own []string `json:"own"`

	// Call set RULE for calls on NAME (--call=NAME=RULE)
	Call map[string]string `json:"call"`
	// Broadcast set RULE for broadcasts from NAME (--broadcast=NAME=RULE)
	Broadcast map[string]string `json:"broadcast"`

	Log    bool `json:"log,omitempty"`
	Filter bool `json:"filter"`
}

func NewConfig

func NewConfig(id string, defaults, mpris bool) (c *Config)

NewConfig returns a reference to a Config struct with optional defaults. If id is an empty string own defaults are omitted.

func NewConfigFromFile

func NewConfigFromFile(path string) (*Config, error)

NewConfigFromFile opens the target config file at path and parses its contents into *Config.

func (*Config) Args

func (c *Config) Args(bus [2]string) (args []string)

func (*Config) Load

func (c *Config) Load(r io.Reader) error

type ParseError added in v0.2.9

type ParseError uint8
const (
	ErrNoColon ParseError
	ErrBadPairSep
	ErrBadPairKey
	ErrBadPairVal
	ErrBadValLength
	ErrBadValByte
	ErrBadValHexLength
	ErrBadValHexByte
)

func (ParseError) Error added in v0.2.9

func (e ParseError) Error() string

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy holds references to a xdg-dbus-proxy process, and should never be copied. Once sealed, configuration changes will no longer be possible and attempting to do so will result in a panic.

func New

func New(session, system [2]string) *Proxy

New returns a reference to a new unsealed Proxy.

func (*Proxy) BwrapStatic added in v0.2.11

func (p *Proxy) BwrapStatic() []string

func (*Proxy) Close

func (p *Proxy) Close() error

Close closes the status file descriptor passed to xdg-dbus-proxy, causing it to stop.

func (*Proxy) Seal

func (p *Proxy) Seal(session, system *Config) error

Seal seals the Proxy instance.

func (*Proxy) Sealed

func (p *Proxy) Sealed() bool

func (*Proxy) Session

func (p *Proxy) Session() [2]string

func (*Proxy) Start

func (p *Proxy) Start(ready chan error, output io.Writer, sandbox, seccomp bool) error

Start launches the D-Bus proxy and sets up the Wait method. ready should be buffered and must only be received from once.

func (*Proxy) String

func (p *Proxy) String() string

func (*Proxy) System

func (p *Proxy) System() [2]string

func (*Proxy) Wait

func (p *Proxy) Wait() error

Wait waits for xdg-dbus-proxy to exit or fault.

Jump to

Keyboard shortcuts

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