Documentation
¶
Index ¶
- Variables
- func AppArmorKernelFeatures() ([]string, error)
- func AppArmorParserFeatures() ([]string, error)
- func AppArmorParserMtime() int64
- func AppArmorSummary() string
- func DistroLike(distros ...string) bool
- func MockAppArmorFeatures(kernelFeatures []string, kernelError error, parserFeatures []string, ...) (restore func())
- func MockAppArmorLevel(level AppArmorLevelType) (restore func())
- func MockForcedDevmode(isDevmode bool) (restore func())
- func MockOnClassic(onClassic bool) (restore func())
- func MockReleaseInfo(osRelease *OS) (restore func())
- func MockSELinuxIsEnabled(isEnabled func() (bool, error)) (restore func())
- func MockSecCompActions(actions []string) (restore func())
- func SELinuxSummary() string
- func SecCompActions() []string
- func SecCompSupportsAction(action string) bool
- type AppArmorLevelType
- type OS
- type SELinuxLevelType
Constants ¶
This section is empty.
Variables ¶
var OnClassic bool
OnClassic states whether the process is running inside a classic Ubuntu system or a native Ubuntu Core image.
var OnWSL bool
OnWSL states whether the process is running inside the Windows Subsystem for Linux
var Series = "16"
Series holds the Ubuntu Core series for snapd to use.
Functions ¶
func AppArmorKernelFeatures ¶
AppArmorKernelFeatures returns a sorted list of apparmor features like []string{"dbus", "network"}. The result is cached internally.
func AppArmorParserFeatures ¶
AppArmorParserFeatures returns a sorted list of apparmor parser features like []string{"unsafe", ...}. The computation is costly to perform. The result is cached internally.
func AppArmorParserMtime ¶
func AppArmorParserMtime() int64
AppArmorParserMtime returns the mtime of the parser, else 0.
func AppArmorSummary ¶
func AppArmorSummary() string
AppArmorSummary describes how well apparmor is supported on the current kernel. The computation is costly to perform. The result is cached internally.
func DistroLike ¶
DistroLike checks if the distribution ID or ID_LIKE matches one of the given names.
func MockAppArmorFeatures ¶
func MockAppArmorFeatures(kernelFeatures []string, kernelError error, parserFeatures []string, parserError error) (restore func())
MockAppArmorFeatures makes the system believe it has certain kernel and parser features.
AppArmor level and summary are automatically re-assessed as needed on both the change and the restore process. Use this function to observe real assessment of arbitrary features.
func MockAppArmorLevel ¶
func MockAppArmorLevel(level AppArmorLevelType) (restore func())
MockAppArmorLevel makes the system believe it has certain level of apparmor support.
AppArmor kernel and parser features are set to unrealistic values that do not match the requested level. Use this function to observe behavior that relies solely on the apparmor level value.
func MockForcedDevmode ¶
func MockForcedDevmode(isDevmode bool) (restore func())
MockForcedDevmode fake the system to believe its in a distro that is in ForcedDevmode
func MockOnClassic ¶
func MockOnClassic(onClassic bool) (restore func())
MockOnClassic forces the process to appear inside a classic Ubuntu system or a native image for testing purposes.
func MockReleaseInfo ¶
func MockReleaseInfo(osRelease *OS) (restore func())
MockReleaseInfo fakes a given information to appear in ReleaseInfo, as if it was read /etc/os-release on startup.
func MockSELinuxIsEnabled ¶
MockSELinuxIsEnabled makes the system believe a certain SELinux state is currently true
func MockSecCompActions ¶
func MockSecCompActions(actions []string) (restore func())
func SecCompActions ¶
func SecCompActions() []string
SecCompActions returns a sorted list of seccomp actions like []string{"allow", "errno", "kill", "log", "trace", "trap"}.
func SecCompSupportsAction ¶
Types ¶
type AppArmorLevelType ¶
type AppArmorLevelType int
AppArmorLevelType encodes the kind of support for apparmor found on this system.
const ( // UnknownAppArmor indicates that apparmor was not probed yet. UnknownAppArmor AppArmorLevelType = iota // NoAppArmor indicates that apparmor is not enabled. NoAppArmor // UnusableAppArmor indicates that apparmor is enabled but cannot be used. UnusableAppArmor // PartialAppArmor indicates that apparmor is enabled but some // features are missing. PartialAppArmor // FullAppArmor indicates that all features are supported. FullAppArmor )
func AppArmorLevel ¶
func AppArmorLevel() AppArmorLevelType
AppArmorLevel quantifies how well apparmor is supported on the current kernel. The computation is costly to perform. The result is cached internally.
func (AppArmorLevelType) String ¶
func (level AppArmorLevelType) String() string
type OS ¶
type OS struct { ID string `json:"id"` IDLike []string `json:"-"` VersionID string `json:"version-id,omitempty"` }
OS contains information about the system extracted from /etc/os-release.
var ReleaseInfo OS
ReleaseInfo contains data loaded from /etc/os-release on startup.
func (*OS) ForceDevMode ¶
ForceDevMode returns true if the distribution doesn't implement required security features for confinement and devmode is forced.
type SELinuxLevelType ¶
type SELinuxLevelType int
SELinuxLevelType encodes the state of SELinux support found on this system.
const ( // NoSELinux indicates that SELinux is not enabled NoSELinux SELinuxLevelType = iota // SELinux is supported and in permissive mode SELinuxPermissive // SELinux is supported and in enforcing mode SELinuxEnforcing )
func SELinuxLevel ¶
func SELinuxLevel() SELinuxLevelType
SELinuxLevel tells what level of SELinux enforcement is currently used
func SELinuxStatus ¶
func SELinuxStatus() (level SELinuxLevelType, summary string)
SELinuxStatus returns the current level of SELinux support and a descriptive summary