system

package
v0.0.0-...-5f60744 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OSReleaseFile    = "/etc/os-release"
	OSReleaseFileNew = "/usr/lib/os-release"
	LSBReleaseFile   = "/etc/lsb-release"
	IssueFile        = "/etc/issue"
	IssueNetFile     = "/etc/issue.net"
)
View Source
const (
	OSShellAshExePath    = "/bin/ash"
	OSShellBourneExePath = "/bin/sh"
	OSShellKornExePath   = "/bin/ksh93"
	//usually a link to /bin/ksh93
	OSShellRestrictedKornExePath = "/bin/rksh93"
	//usually a link to /etc/alternatives/ksh
	//which links to /bin/ksh93
	OSShellKorn2ExePath = "/bin/ksh"
	OSShellBashExePath  = "/bin/bash"
	//usually a link to /bin/bash
	OSShellRestrictedBashExePath = "/bin/rbash"
	OSShellDashExePath           = "/bin/dash"
	OSShellZExePath              = "/bin/zsh"
	//usually a link to /bin/zsh
	OSShellZ2ExePath       = "/usr/bin/zsh"
	OSShellCExePath        = "/bin/csh"
	OSShellTCExePath       = "/bin/tcsh"
	OSShellFishExePath     = "/usr/bin/fish"
	OSShellElvishExePath   = "/usr/bin/elvish"
	OSShellXonshExePath    = "/usr/bin/xonsh"
	OSShellYashExePath     = "/usr/bin/yash"
	OSShellGitShellExePath = "/usr/bin/git-shell"
	OSShellScreenExePath   = "/usr/bin/screen"
	OSShellTmuxExePath     = "/usr/bin/tmux"
)

Common linux shell exe paths

View Source
const (
	SyscallX86MinNum      = 0
	SyscallX86UnknownNum  = -1
	SyscallX86UnknownName = "unknown_syscall"
)
View Source
const (
	SyscallArmUnknownNum  = -1
	SyscallArmUnknownName = "unknown_syscall"
	SyscallArmMinNum32    = 0
	SyscallArmMaxNum32    = 377
	SyscallArmLastName32  = "process_vm_writev"
)
View Source
const (
	SyscallArmUnknownNum64  = -1
	SyscallArmUnknownName64 = "unknown_syscall"
	SyscallArmMinNum64      = 0
	SyscallArmMaxNum64      = 294
	SyscallArmLastName64    = "kexec_file_load"
)
View Source
const (
	SyscallX86MaxNum32   = 435
	SyscallX86LastName32 = "clone3"
)
View Source
const (
	SyscallX86MaxNum64   = 435
	SyscallX86LastName64 = "clone3"
)
View Source
const (
	OSShellsFile = "/etc/shells"
)

Variables

View Source
var (
	ErrNotConfigured    = errors.New("feature is not configured")
	ErrNoConfigs        = errors.New("no kernel configs")
	ErrArchNotSupported = errors.New("unsupported architecture")
)
View Source
var ArmFamily32Arch = ArchInfo{
	Name:   ArchNameArm32,
	Family: ArchFamilyArm,
	Bits:   ArchBits32,
}
View Source
var ArmFamily64Arch = ArchInfo{
	Name:   ArchNameArm64,
	Family: ArchFamilyArm,
	Bits:   ArchBits64,
}
View Source
var DefaultKernelFeatures, _ = NewKernelFeatures()
View Source
var OSShells = map[string]OSShell{
	OSShellBourneExePath: {
		FullName:  "Bourne shell",
		ShortName: "sh",
		ExePath:   OSShellBourneExePath,
	},
	OSShellKornExePath: {
		FullName:  "Korn shell",
		ShortName: "ksh",
		ExePath:   OSShellKornExePath,
	},
	OSShellBashExePath: {
		FullName:  "Bash shell",
		ShortName: "bash",
		ExePath:   OSShellBashExePath,
	},
	OSShellDashExePath: {
		FullName:  "Dash shell",
		ShortName: "dash",
		ExePath:   OSShellDashExePath,
	},
	OSShellZExePath: {
		FullName:  "Z shell",
		ShortName: "zsh",
		ExePath:   OSShellZExePath,
	},
	OSShellCExePath: {
		FullName:  "C shell",
		ShortName: "csh",
		ExePath:   OSShellCExePath,
	},
	OSShellTCExePath: {
		FullName:  "TC shell",
		ShortName: "tcsh",
		ExePath:   OSShellTCExePath,
	},
	OSShellFishExePath: {
		FullName:  "Fish shell",
		ShortName: "fish",
		ExePath:   OSShellFishExePath,
	},
	OSShellElvishExePath: {
		FullName:  "Elvish shell",
		ShortName: "elvish",
		ExePath:   OSShellElvishExePath,
	},
	OSShellXonshExePath: {
		FullName:  "Xonsh shell",
		ShortName: "xonsh",
		ExePath:   OSShellXonshExePath,
	},
	OSShellYashExePath: {
		FullName:  "Yash shell",
		ShortName: "yash",
		ExePath:   OSShellYashExePath,
	},
	OSShellAshExePath: {
		FullName:  "Ash shell",
		ShortName: "ash",
		ExePath:   OSShellAshExePath,
	},

	OSShellGitShellExePath: {
		FullName:  "Git shell",
		ShortName: "git-shell",
		ExePath:   OSShellGitShellExePath,
	},
	OSShellScreenExePath: {
		FullName:  "Screen",
		ShortName: "screen",
		ExePath:   OSShellScreenExePath,
	},
	OSShellTmuxExePath: {
		FullName:  "Tmux",
		ShortName: "tmux",
		ExePath:   OSShellTmuxExePath,
	},
}

Functions

func CallFirstParam

func CallFirstParam(regs syscall.PtraceRegs) uint64

func CallFourthParam

func CallFourthParam(regs syscall.PtraceRegs) uint64

func CallNumber

func CallNumber(regs syscall.PtraceRegs) uint64

func CallReturnValue

func CallReturnValue(regs syscall.PtraceRegs) uint64

func CallSecondParam

func CallSecondParam(regs syscall.PtraceRegs) uint64

func CallThirdParam

func CallThirdParam(regs syscall.PtraceRegs) uint64

func IsOSReleaseFile

func IsOSReleaseFile(name string) bool

func IsOSShellsFile

func IsOSShellsFile(name string) bool

func IsShellExePath

func IsShellExePath(name string) bool

func LookupCallName

func LookupCallName(num uint32) string

func LookupCallNumber

func LookupCallNumber(name string) (uint32, bool)

func ResolveGroup

func ResolveGroup(identity string) (uint32, error)

func ResolveUser

func ResolveUser(identity string) (uid uint32, gid uint32, home string, err error)

Types

type ArchBits

type ArchBits uint8
const (
	ArchBits32 ArchBits = 32
	ArchBits64 ArchBits = 64
)

type ArchFamily

type ArchFamily string
const (
	ArchFamilyX86   ArchFamily = "x86"
	ArchFamilyArm   ArchFamily = "arm"
	ArchFamilyArm64 ArchFamily = "arm64"
)

type ArchInfo

type ArchInfo struct {
	Name   ArchName
	Family ArchFamily
	Bits   ArchBits
}

func MachineToArch

func MachineToArch(mtype string) *ArchInfo

type ArchName

type ArchName string
const (
	ArchNameUnknown     ArchName = "unknown"
	ArchNameUnsupported ArchName = "unsupported"
	ArchName386         ArchName = "386"
	ArchNameAmd64       ArchName = "amd64"
	ArchNameArm32       ArchName = "armhf"
	ArchNameArm64       ArchName = "aarch64"
)

func MachineToArchName

func MachineToArchName(mtype string) ArchName

type DistroInfo

type DistroInfo struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	DisplayName string `json:"display_name"`
}

type KernelFeatures

type KernelFeatures struct {
	Raw   map[string]string
	Error string
}

func NewKernelFeatures

func NewKernelFeatures() (KernelFeatures, error)

func NewKernelFeaturesWithProps

func NewKernelFeaturesWithProps(location string) (KernelFeatures, error)

func (*KernelFeatures) IsCompiled

func (p *KernelFeatures) IsCompiled(name string) (bool, error)

func (*KernelFeatures) IsConfigured

func (p *KernelFeatures) IsConfigured(name string) bool

func (*KernelFeatures) IsFlag

func (p *KernelFeatures) IsFlag(name string) (bool, error)

func (*KernelFeatures) IsLoadable

func (p *KernelFeatures) IsLoadable(name string) (bool, error)

func (*KernelFeatures) RawValue

func (p *KernelFeatures) RawValue(name string) (string, error)

type MachineName

type MachineName string
const (
	MachineNameNamei386   MachineName = "i386"
	MachineNameNamei586   MachineName = "i586"
	MachineNameNamei686   MachineName = "i686"
	MachineNameNamex86_64 MachineName = "x86_64"
	MachineNameNameArm    MachineName = "armv7l"
	MachineNameNameArm64  MachineName = "aarch64"
)

type NameResolverFunc

type NameResolverFunc func(string) (uint32, bool)

func CallNameResolver

func CallNameResolver(arch ArchName) NameResolverFunc

type NumberResolverFunc

type NumberResolverFunc func(uint32) string

func CallNumberResolver

func CallNumberResolver(arch ArchName) NumberResolverFunc

type OSShell

type OSShell struct {
	FullName  string `json:"full_name"`
	ShortName string `json:"short_name,omitempty"`
	ExePath   string `json:"exe_path"`
	LinkPath  string `json:"link_path,omitempty"`
	Reference string `json:"reference,omitempty"`
	Verified  bool   `json:"verified,omitempty"`
}

func LookupShellByExePath

func LookupShellByExePath(name string) *OSShell

func NewOSShells

func NewOSShells(verify bool) ([]*OSShell, error)

func NewOSShellsFromData

func NewOSShellsFromData(raw []byte) ([]*OSShell, error)

func ParseOSShells

func ParseOSShells(raw []byte) []*OSShell

type OsRelease

type OsRelease struct {
	AnsiColor    string `osr:"ANSI_COLOR"`
	Name         string `osr:"NAME"`
	Version      string `osr:"VERSION"`
	Variant      string `osr:"VARIANT"`
	VariantID    string `osr:"VARIANT_ID"`
	ID           string `osr:"ID"`
	IDLike       string `osr:"ID_LIKE"`
	PrettyName   string `osr:"PRETTY_NAME"`
	VersionID    string `osr:"VERSION_ID"`
	HomeURL      string `osr:"HOME_URL"`
	SupportURL   string `osr:"SUPPORT_URL"`
	BugReportURL string `osr:"BUG_REPORT_URL"`
}

OsRelease reflects values in /etc/os-release Values in this struct must always be string or the reflection will not work properly.

func NewOsRelease

func NewOsRelease(contents []byte) (*OsRelease, error)

func (*OsRelease) ParseOsRelease

func (osr *OsRelease) ParseOsRelease(osReleaseContents []byte) error

type SystemInfo

type SystemInfo struct {
	Sysname    string
	Nodename   string
	Release    string
	Version    string
	Machine    string
	Domainname string
	OsBuild    string
	Distro     DistroInfo
}

func GetSystemInfo

func GetSystemInfo() SystemInfo

Jump to

Keyboard shortcuts

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