sys

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWrongNamespace = fmt.Errorf("systemd instance is in a different namespace")
)

in some container environments we may be able to talk to the "host" systemd user instance, but we don't want to _use_ it in that case because it won't see our paths/etc.

View Source
var GetIsolator func() (Isolator, error)

GetIsolator is initialized in platform-specific files, and should generally be the result of sync.OnceValues.

Functions

func ReadFileAsRoot

func ReadFileAsRoot(ctx context.Context, fn string, allowPrompt bool) ([]byte, error)

func RemoveFileAsRoot added in v0.7.0

func RemoveFileAsRoot(ctx context.Context, fn string) error

func RenameFileAsRoot added in v0.7.0

func RenameFileAsRoot(ctx context.Context, oldFn, newFn string) error

func StartDaemon

func StartDaemon(
	ctx context.Context,
	name string,
	path string,
	args []string,
	env map[string]string,
) error

func SudoReader

func SudoReader(ctx context.Context, fn string, allowPrompt bool) (*sudoReader, error)

func SudoReaderIfNecessary

func SudoReaderIfNecessary(ctx context.Context, fn string, allowPrompt bool) (io.ReadCloser, error)

func SystemdUserConn added in v0.9.0

func SystemdUserConn(ctx context.Context) (_ *dbus.Conn, finalErr error)

SystemdUserConn wraps dbus.NewUserConnectionContext but verifies that the connection is to a systemd instance in the same namespace.

If the systemd instance is in a different namespace, or it runs into errors attemping the verification, then it will return an error wrapping ErrWrongNamespace.

func WriteFileAsRoot

func WriteFileAsRoot(ctx context.Context, fn string, content io.Reader, mode os.FileMode) error

Types

type Isolator added in v0.9.0

type Isolator interface {
	Isolate(
		ctx context.Context,
		name string,
		process *os.Process,
	) (group string, err error)
	Cleanup(
		ctx context.Context,
		group string,
	) error
}

Jump to

Keyboard shortcuts

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