Documentation
¶
Index ¶
- Constants
- Variables
- func ExpectSystemdAbsent()
- func ReadFileAsRoot(ctx context.Context, fn string, allowPrompt bool) ([]byte, error)
- func RemoveFileAsRoot(ctx context.Context, fn string) error
- func RenameFileAsRoot(ctx context.Context, oldFn, newFn string) error
- func StartDaemon(ctx context.Context, name string, path string, args []string, ...) error
- func SudoReader(ctx context.Context, fn string, allowPrompt bool) (*sudoReader, error)
- func SudoReaderIfNecessary(ctx context.Context, fn string, allowPrompt bool) (io.ReadCloser, error)
- func SystemdUserConn(ctx context.Context) (_ *dbus.Conn, finalErr error)
- func WriteFileAsRoot(ctx context.Context, fn string, content io.Reader, mode os.FileMode) error
- type Isolator
Constants ¶
const FallbackLogFileEnv = "__FALLBACK_LOG_FILE"
FallbackLogFileEnv is an environment variable that can be set to provide a fallback log file path for daemons started without systemd support.
This will not be passed to the actual daemon.
TODO: this is ugly
Variables ¶
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.
var GetIsolator func() (Isolator, error)
GetIsolator is initialized in platform-specific files, and should generally be the result of sync.OnceValues.
Functions ¶
func ExpectSystemdAbsent ¶ added in v0.12.0
func ExpectSystemdAbsent()
ExpectSystemdAbsent can be called from apps that know they are running in an environment where the systemd user instance is not expected to be available. It will not prevent attempting to use it, but it will suppress warnings if it is absent.
func ReadFileAsRoot ¶
func RenameFileAsRoot ¶ added in v0.7.0
func StartDaemon ¶
func SudoReader ¶
func SudoReaderIfNecessary ¶
func SystemdUserConn ¶ added in v0.9.0
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.