Documentation
¶
Overview ¶
Package snapdtool exposes version and related information, supports re-execution and inter-tool lookup/execution across all snapd tools.
Index ¶
- Variables
- func CommandFromSystemSnap(name string, cmdArgs ...string) (*exec.Cmd, error)
- func DistroSupportsReExec() bool
- func ExecInSnapdOrCoreSnap()
- func InternalToolPath(tool string) (string, error)
- func IsReexecEnabled() bool
- func IsReexecExplicitlyEnabled() bool
- func IsReexecd() (bool, error)
- func MaybeSetupFIPS() error
- func MockOsReadlink(f func(string) (string, error)) func()
- func MockVersion(version string) (restore func())
- func ParseInfoFile(f io.Reader, whence string) (version string, flags map[string]string, err error)
- func SnapdVersionFromInfoFile(dir string) (version string, flags map[string]string, err error)
Constants ¶
This section is empty.
Variables ¶
var Version = "unknown"
Version will be overwritten at build-time via mkversion.sh
Functions ¶
func CommandFromSystemSnap ¶
CommandFromSystemSnap runs a command from the snapd/core snap using the proper interpreter and library paths if needed.
Files from core need this hack. Files from snapd are executed normally unless the snapd snap is not mounted under /snap.
At the moment it can only run ELF files, expects a standard ld.so interpreter, and can't handle RPATH.
func DistroSupportsReExec ¶
func DistroSupportsReExec() bool
DistroSupportsReExec returns true if the distribution we are running on can use re-exec.
This is true by default except for a "core/all" snap system where it makes no sense and in certain distributions that we don't want to enable re-exec yet because of missing validation or other issues.
func ExecInSnapdOrCoreSnap ¶
func ExecInSnapdOrCoreSnap()
ExecInSnapdOrCoreSnap makes sure you're executing the binary that ships in the snapd/core snap.
func InternalToolPath ¶
InternalToolPath returns the path of an internal snapd tool. The tool *must* be located inside the same tree as the current binary.
The return value is either the path of the tool in the current distribution or in the core/snapd snap (or the ubuntu-core snap) if the current binary is ran from that location.
func IsReexecEnabled ¶
func IsReexecEnabled() bool
IsReexecEnabled checks the environment and configuration to assert whether reexec has been explicitly enabled/disabled.
func IsReexecExplicitlyEnabled ¶
func IsReexecExplicitlyEnabled() bool
IsReexecExplicitlyEnabled is a stronger check than IsReexecEnabled as it really expects the relevant environment variable to be set.
func MaybeSetupFIPS ¶
func MaybeSetupFIPS() error
MaybeSetupFIPS checks whether a system-wide FIPS mode is enabled and if so sets up an environment such that the current process is able to use libraries that are required for FIPS compliance and reexecs.
func MockOsReadlink ¶
MockOsReadlink is for use in tests
func MockVersion ¶
func MockVersion(version string) (restore func())
func ParseInfoFile ¶
ParseInfoFile parses the "info" file provided via an io.Reader. It returns the snapd version read from the info file, as well as any other key/value pairs/flags in the file. whence is used to construct error messages as "... info file %s". The format of the "info" file are lines with "KEY=VALUE" with the typical key being just VERSION. The file is produced by mkversion.sh and normally installed along snapd binary in /usr/lib/snapd. Other typical keys in this file include SNAPD_APPARMOR_REEXEC, which indicates whether or not the snapd-apparmor binary installed via the traditional linux package of snapd supports re-exec into the version in the snapd or core snaps.
func SnapdVersionFromInfoFile ¶
SnapdVersionFromInfoFile returns the snapd version read from the info file in the given dir, as well as any other key/value pairs/flags in the file. See ParseInfoFile for more format details.
Types ¶
This section is empty.