system

package
v0.2.18 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package system provides tools for safely interacting with the operating system.

Index

Constants

View Source
const (
	// User type is reverted at final launcher exit.
	User = Enablement(ELen)
	// Process type is unconditionally reverted on exit.
	Process = Enablement(ELen + 1)
)
View Source
const ELen = len(enablementString)

Variables

View Source
var (
	ErrDBusConfig = errors.New("dbus config not supplied")
)

Functions

func TypeString

func TypeString(e Enablement) string

TypeString returns the string representation of a type stored as an Enablement.

Types

type ACL

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

func (*ACL) Is

func (a *ACL) Is(o Op) bool

func (*ACL) Path

func (a *ACL) Path() string

func (*ACL) String

func (a *ACL) String() string

func (*ACL) Type

func (a *ACL) Type() Enablement

type Criteria

type Criteria struct {
	*Enablements
}

Criteria specifies types of Op to revert.

type DBus

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

func (*DBus) Is

func (d *DBus) Is(o Op) bool

func (*DBus) Path

func (d *DBus) Path() string

func (*DBus) String

func (d *DBus) String() string

func (*DBus) Type

func (d *DBus) Type() Enablement

type Enablement

type Enablement uint8

Enablement represents an optional system resource

const (
	EWayland Enablement = iota
	EX11
	EDBus
	EPulse
)

func (Enablement) Mask

func (e Enablement) Mask() Enablements

func (Enablement) String

func (e Enablement) String() string

type Enablements

type Enablements uint64

Enablements represents optional system resources to share

func (*Enablements) Has

func (es *Enablements) Has(e Enablement) bool

Has returns whether a feature is enabled

func (*Enablements) Set

func (es *Enablements) Set(e Enablement)

Set enables a feature

func (*Enablements) String

func (es *Enablements) String() string
type Hardlink struct {
	// contains filtered or unexported fields
}

func (*Hardlink) Is

func (l *Hardlink) Is(o Op) bool

func (*Hardlink) Path

func (l *Hardlink) Path() string

func (*Hardlink) String

func (l *Hardlink) String() string

func (*Hardlink) Type

func (l *Hardlink) Type() Enablement

type I

type I struct {
	IsVerbose func() bool
	Verbose   func(v ...any)
	Verbosef  func(format string, v ...any)
	WrapErr   func(err error, a ...any) error
	// contains filtered or unexported fields
}

An I provides indirect bulk operating system interaction. I must not be copied.

func New

func New(uid int) (sys *I)

New initialises sys with no-op verbose functions.

func (*I) ChangeHosts

func (sys *I) ChangeHosts(username string) *I

ChangeHosts appends an X11 ChangeHosts command Op.

func (*I) Commit

func (sys *I) Commit(ctx context.Context) error

Commit applies all Op held by I and reverts successful Op on first error encountered. Commit must not be called more than once.

func (*I) CopyFile

func (sys *I) CopyFile(payload *[]byte, src string, cap int, n int64) *I

CopyFile registers an Op that copies from src. A buffer is initialised with size cap and the Op faults if bytes read exceed n.

func (*I) Ensure

func (sys *I) Ensure(name string, perm os.FileMode) *I

Ensure the existence and mode of a directory.

func (*I) Ephemeral

func (sys *I) Ephemeral(et Enablement, name string, perm os.FileMode) *I

Ephemeral ensures the temporary existence and mode of a directory through the life of et.

func (*I) Equal

func (sys *I) Equal(v *I) bool

Equal returns whether all Op instances held by v is identical to that of sys.

func (sys *I) Link(oldname, newname string) *I

Link registers an Op that links dst to src.

func (*I) LinkFileType

func (sys *I) LinkFileType(et Enablement, oldname, newname string) *I

LinkFileType registers a file linking Op labelled with type et.

func (*I) MustProxyDBus

func (sys *I) MustProxyDBus(sessionPath string, session *dbus.Config, systemPath string, system *dbus.Config) *I

func (*I) ProxyDBus

func (sys *I) ProxyDBus(session, system *dbus.Config, sessionPath, systemPath string) (func(), error)

func (*I) Revert

func (sys *I) Revert(ec *Criteria) error

Revert reverts all Op meeting Criteria held by I.

func (*I) UID

func (sys *I) UID() int

func (*I) UpdatePerm

func (sys *I) UpdatePerm(path string, perms ...acl.Perm) *I

UpdatePerm appends an ephemeral acl update Op.

func (*I) UpdatePermType

func (sys *I) UpdatePermType(et Enablement, path string, perms ...acl.Perm) *I

UpdatePermType appends an acl update Op.

func (*I) Wayland

func (sys *I) Wayland(syncFd **os.File, dst, src, appID, instanceID string) *I

Wayland sets up a wayland socket with a security context attached.

type Mkdir

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

func (*Mkdir) Is

func (m *Mkdir) Is(o Op) bool

func (*Mkdir) Path

func (m *Mkdir) Path() string

func (*Mkdir) String

func (m *Mkdir) String() string

func (*Mkdir) Type

func (m *Mkdir) Type() Enablement

type Op

type Op interface {
	// Type returns Op's enablement type.
	Type() Enablement

	Is(o Op) bool
	Path() string
	String() string
	// contains filtered or unexported methods
}

Op is a reversible system operation.

type Tmpfile

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

func (*Tmpfile) Is

func (t *Tmpfile) Is(o Op) bool

func (*Tmpfile) Path

func (t *Tmpfile) Path() string

func (*Tmpfile) String

func (t *Tmpfile) String() string

func (*Tmpfile) Type

func (t *Tmpfile) Type() Enablement

type Wayland

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

func (*Wayland) Is

func (w *Wayland) Is(o Op) bool

func (*Wayland) Path

func (w *Wayland) Path() string

func (*Wayland) String

func (w *Wayland) String() string

func (*Wayland) Type

func (w *Wayland) Type() Enablement

type XHost

type XHost string

func (XHost) Is

func (x XHost) Is(o Op) bool

func (XHost) Path

func (x XHost) Path() string

func (XHost) String

func (x XHost) String() string

func (XHost) Type

func (x XHost) Type() Enablement

Directories

Path Synopsis
internal
xcb
Package xcb implements X11 ChangeHosts via libxcb.
Package xcb implements X11 ChangeHosts via libxcb.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳