dbus

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 14 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 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 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) Bwrap

func (p *Proxy) Bwrap() []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 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