system

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_USER_AGENT_PREFIX = "syver/"
View Source
const USER_AGENT_HEADER_PREFIX = "user-agent:"

Variables

View Source
var (
	ErrNullPackage            = errors.New("could not detect Package type on this system, please use --package flag to explicitly set it")
	ErrPackageVersionNotFound = errors.New("package version not found")
)
View Source
var ErrFileOwnershipUnsupported = errors.New("file mode/owner/group is not supported on this platform")

ErrFileOwnershipUnsupported is returned by Mode, Owner, Uid, Group and Gid on Windows (system/file_windows.go) -- there is no POSIX mode/owner/group concept to report there. Following the sentinel-error idiom already used by registry (ErrRegistryUnsupported) and package (ErrNullPackage): a named, comparable error rather than a fabricated zero value with a nil error.

View Source
var ErrKernelParamUnsupported = errors.New("kernel-param is not supported on this platform (no /proc/sys); on Windows use registry: instead")

ErrKernelParamUnsupported is returned by Exists when the host has no /proc/sys filesystem to query at all -- most notably Windows, which has no procfs concept, but any other host missing procfs hits the same path.

sysctl.Get is a single os.ReadFile(DefaultPath+key) call, so a missing individual key and a missing /proc/sys tree both surface as the identical os.ErrNotExist -- there is no way to distinguish "this key does not exist on a real Linux host" from "there is no procfs at all here" from that one error alone (system/kernel_param.go's Trap 1 in FEAT-010). Instead of inspecting the leaf error, Exists checks whether the base directory itself is present: if it is not, nothing was actually learned about the specific key, and that must not be reported as false, nil. See SW-5.

View Source
var ErrMountUnsupported = errors.New("mount: not supported on this platform")

ErrMountUnsupported is returned when the platform has no mount lookup at all, as distinct from a lookup that ran and found nothing. Following the sentinel-error idiom already used by registry (ErrRegistryUnsupported), package (ErrNullPackage) and file (ErrFileOwnershipUnsupported).

WHY THIS EXISTS RATHER THAN A REORDER. setup() calls getMount before the platform getUsage, and on Windows the vendored mountinfo returns an EMPTY TABLE rather than an error -- its own comment says "Do NOT return an error!" -- which getMount converts to ErrMountpointNotFound. So every Windows mount check blamed the operator's mountpoint for what is actually a missing implementation, and mount_windows.go's honest error was unreachable. FEAT-010 SW-7 recorded that and deferred it; FEAT-011 W2-12(a) scheduled it.

The obvious fix is to run getUsage first. It was rejected: getMount and getUsage are shared by every OS, and reordering them changes which error a non-existent path produces on Linux and macOS, where mount: is fully supported and heavily used. A platform capability check placed BEFORE both is a no-op everywhere the platform is supported, so Linux and macOS behaviour is unchanged by construction rather than by inspection.

View Source
var ErrMountpointNotFound = errors.New("mountpoint not found")

ErrMountpointNotFound is returned by getMount (and therefore by Exists) when the platform lookup ran and genuinely found no such mountpoint -- the common, everyday case for a path that simply isn't a separate mount. Exported (was errMountpointNotFound) so resource/mount.go's `add` path can distinguish this expected outcome from a genuine lookup failure (e.g. a timeout) rather than propagating both identically as a hard error. See FEAT-010 SW-10 / Trap 1's reasoning, applied here.

View Source
var ErrRegistryUnsupported = errors.New("registry resource is only supported on Windows")
View Source
var ErrServiceNotFound = errors.New("service not found")

ErrServiceNotFound is returned by Enabled and Running on Windows (system/service_windows.go) when the named service does not exist, instead of folding "does not exist" into "exists but is disabled/not running" -- the two used to be indistinguishable, so `service: TypoedName: {enabled: false}` passed. See FEAT-010 SW-4.

View Source
var ErrServiceRunLevelsUnsupported = errors.New("service runlevels is not supported on this platform")

ErrServiceRunLevelsUnsupported is returned by RunLevels on Windows (system/service_windows.go), which has no SysV/systemd-style runlevel concept. RunLevels previously returned (nil, nil) there, so a spec ported from Linux that sets `runlevels:` got a ContainElements failure against a nil slice with no indication Windows was the reason. See FEAT-010 S-5.

Functions

func DNSlookup

func DNSlookup(host string, server string, qtype string, timeout int) ([]string, error)

func DetectDistro

func DetectDistro() string

DetectDistro attempts to detect which Linux distribution this computer is using. One of "ubuntu", "redhat" (including Centos), "alpine", "arch", or "debian". If it can't decide, it returns an empty string.

func DetectPackageManager

func DetectPackageManager() string

DetectPackageManager attempts to detect whether or not the system is using "dpkg", "rpm", "apk", or "pacman" package managers. It first attempts to detect the distro. If that fails, it falls back to finding package manager executables. If that fails, it returns the empty string.

func DetectService

func DetectService() string

DetectService attempts to detect what kind of service management the system is using, "systemd", "upstart", "alpineinit", or "init". It looks for systemctl command to detect systemd, and falls back on DetectDistro otherwise. If it can't decide, it returns "init".

func GetPorts

func GetPorts() (map[string][]net.ConnectionStat, error)

GetPorts returns the set of listening TCP/UDP ports known to the OS's connection-table backend. Failures from individual protocol lookups are joined and returned rather than silently discarded: a missing/unreadable /proc/net/{tcp,udp}{,6} file is treated as "no ports" with no error, but a file that's readable yet contains a line that can't be parsed (e.g. an unexpected IP/port encoding) does return an error, which would otherwise present as every port on that protocol simply not listening. Each protocol is queried separately (rather than via a single "all" call) specifically to preserve this per-protocol error isolation.

func GetProcs

func GetProcs() (map[string][]*process.Process, error)

func HasCommand

func HasCommand(cmd string) bool

HasCommand returns whether or not an executable by this name is on the PATH.

func HeaderToArray

func HeaderToArray(header http.Header) (res []string)

func IsSupportedPackageManager

func IsSupportedPackageManager(p string) bool

IsSupportedPackageManager determines if p is a supported package manager

func LookupA

func LookupA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

A record lookup

func LookupAAAA

func LookupAAAA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

AAAA (IPv6) record lookup

func LookupCAA

func LookupCAA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

CAA record lookup

func LookupCNAME

func LookupCNAME(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

CNAME record lookup

func LookupHost

func LookupHost(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

A and AAAA record lookup - similar to net.LookupHost

func LookupMX

func LookupMX(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

MX record lookup

func LookupNS

func LookupNS(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

NS record lookup

func LookupPTR

func LookupPTR(addr string, server string, c *dns.Client, m *dns.Msg) (name []string, err error)

PTR record lookup

func LookupSRV

func LookupSRV(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

SRV record lookup

func LookupTXT

func LookupTXT(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error)

TXT record lookup

func SupportedPackageManagers

func SupportedPackageManagers() []string

SupportedPackageManagers is a list of package managers we support

Types

type Addr

type Addr interface {
	Address() string
	Exists() (bool, error)
	Reachable() (bool, error)
}

func NewDefAddr

func NewDefAddr(_ context.Context, address string, system *System, config util.Config) Addr

type AlpinePackage

type AlpinePackage struct {
	// contains filtered or unexported fields
}

func (*AlpinePackage) Exists

func (p *AlpinePackage) Exists() (bool, error)

func (*AlpinePackage) Installed

func (p *AlpinePackage) Installed() (bool, error)

func (*AlpinePackage) Name

func (p *AlpinePackage) Name() string

func (*AlpinePackage) Versions

func (p *AlpinePackage) Versions() ([]string, error)

type Command

type Command interface {
	Command() string
	Exists() (bool, error)
	ExitStatus() (int, error)
	Stdout() (io.Reader, error)
	Stderr() (io.Reader, error)
}

func NewDefCommand

func NewDefCommand(ctx context.Context, command string, system *System, config util.Config) Command

type DNS

type DNS interface {
	Host() string
	Addrs() ([]string, error)
	Resolvable() (bool, error)
	Exists() (bool, error)
	Server() string
	Qtype() string
}

func NewDefDNS

func NewDefDNS(_ context.Context, host string, system *System, config util.Config) DNS

type DebPackage

type DebPackage struct {
	// contains filtered or unexported fields
}

func (*DebPackage) Exists

func (p *DebPackage) Exists() (bool, error)

func (*DebPackage) Installed

func (p *DebPackage) Installed() (bool, error)

func (*DebPackage) Name

func (p *DebPackage) Name() string

func (*DebPackage) Versions

func (p *DebPackage) Versions() ([]string, error)

type DefAddr

type DefAddr struct {
	LocalAddress string
	Timeout      int
	// contains filtered or unexported fields
}

func (*DefAddr) Address

func (a *DefAddr) Address() string

func (*DefAddr) Exists

func (a *DefAddr) Exists() (bool, error)

func (*DefAddr) ID

func (a *DefAddr) ID() string

func (*DefAddr) Reachable

func (a *DefAddr) Reachable() (bool, error)

type DefCommand

type DefCommand struct {
	Ctx context.Context

	Timeout int
	// contains filtered or unexported fields
}

func (*DefCommand) Command

func (c *DefCommand) Command() string

func (*DefCommand) Exists

func (c *DefCommand) Exists() (bool, error)

Stub out

func (*DefCommand) ExitStatus

func (c *DefCommand) ExitStatus() (int, error)

func (*DefCommand) Stderr

func (c *DefCommand) Stderr() (io.Reader, error)

func (*DefCommand) Stdout

func (c *DefCommand) Stdout() (io.Reader, error)

type DefDNS

type DefDNS struct {
	Timeout int
	// contains filtered or unexported fields
}

func (*DefDNS) Addrs

func (d *DefDNS) Addrs() ([]string, error)

func (*DefDNS) Exists

func (d *DefDNS) Exists() (bool, error)

Stub out

func (*DefDNS) Host

func (d *DefDNS) Host() string

func (*DefDNS) Qtype

func (d *DefDNS) Qtype() string

func (*DefDNS) Resolvable

func (d *DefDNS) Resolvable() (bool, error)

func (*DefDNS) Server

func (d *DefDNS) Server() string

type DefFile

type DefFile struct {
	// contains filtered or unexported fields
}

func (*DefFile) Contents

func (f *DefFile) Contents() (io.Reader, error)

func (*DefFile) Exists

func (f *DefFile) Exists() (bool, error)

func (*DefFile) Filetype

func (f *DefFile) Filetype() (string, error)

func (*DefFile) Gid

func (f *DefFile) Gid() (int, error)

func (*DefFile) Group

func (f *DefFile) Group() (string, error)

func (*DefFile) LinkedTo

func (f *DefFile) LinkedTo() (string, error)

func (*DefFile) Md5

func (f *DefFile) Md5() (string, error)

func (*DefFile) Mode

func (f *DefFile) Mode() (string, error)

func (*DefFile) Owner

func (f *DefFile) Owner() (string, error)

func (*DefFile) Path

func (f *DefFile) Path() string

func (*DefFile) Sha256

func (f *DefFile) Sha256() (string, error)

func (*DefFile) Sha512

func (f *DefFile) Sha512() (string, error)

func (*DefFile) Size

func (f *DefFile) Size() (int, error)

func (*DefFile) Uid

func (f *DefFile) Uid() (int, error)

type DefGroup

type DefGroup struct {
	// contains filtered or unexported fields
}

func (*DefGroup) Exists

func (u *DefGroup) Exists() (bool, error)

Exists distinguishes "user.LookupGroup ran and genuinely found no such group" (groupLookupFoundNothing -- false, nil, unchanged) from every other failure (false, err), for the same reason as DefUser.Exists. See FEAT-010 SW-9 / Trap 1.

func (*DefGroup) GID

func (u *DefGroup) GID() (int, error)

func (*DefGroup) Groupname

func (u *DefGroup) Groupname() string

type DefHTTP

type DefHTTP struct {
	RequestHeader      http.Header
	RequestQueryParams map[string][]string
	RequestBody        string
	Timeout            int

	Username string
	Password string
	CAFile   string
	CertFile string
	KeyFile  string
	Method   string
	Proxy    string
	// contains filtered or unexported fields
}

func (*DefHTTP) Body

func (u *DefHTTP) Body() (io.Reader, error)

func (*DefHTTP) Close

func (u *DefHTTP) Close() error

func (*DefHTTP) Exists

func (u *DefHTTP) Exists() (bool, error)

func (*DefHTTP) HTTP

func (u *DefHTTP) HTTP() string

func (*DefHTTP) Headers

func (u *DefHTTP) Headers() (io.Reader, error)

func (*DefHTTP) ID

func (u *DefHTTP) ID() string

func (*DefHTTP) SetAllowInsecure

func (u *DefHTTP) SetAllowInsecure(t bool)

func (*DefHTTP) SetNoFollowRedirects

func (u *DefHTTP) SetNoFollowRedirects(t bool)

func (*DefHTTP) Status

func (u *DefHTTP) Status() (int, error)

type DefInterface

type DefInterface struct {
	// contains filtered or unexported fields
}

func (*DefInterface) Addrs

func (i *DefInterface) Addrs() ([]string, error)

func (*DefInterface) Exists

func (i *DefInterface) Exists() (bool, error)

func (*DefInterface) ID

func (i *DefInterface) ID() string

func (*DefInterface) MTU

func (i *DefInterface) MTU() (int, error)

func (*DefInterface) Name

func (i *DefInterface) Name() string

type DefKernelParam

type DefKernelParam struct {
	// contains filtered or unexported fields
}

func (*DefKernelParam) Exists

func (k *DefKernelParam) Exists() (bool, error)

func (*DefKernelParam) ID

func (k *DefKernelParam) ID() string

func (*DefKernelParam) Key

func (k *DefKernelParam) Key() string

func (*DefKernelParam) Value

func (k *DefKernelParam) Value() (string, error)

type DefMount

type DefMount struct {
	Timeout int
	// contains filtered or unexported fields
}

func (*DefMount) Exists

func (m *DefMount) Exists() (bool, error)

func (*DefMount) Filesystem

func (m *DefMount) Filesystem() (string, error)

func (*DefMount) ID

func (m *DefMount) ID() string

func (*DefMount) MountPoint

func (m *DefMount) MountPoint() string

func (*DefMount) Opts

func (m *DefMount) Opts() ([]string, error)

func (*DefMount) Source

func (m *DefMount) Source() (string, error)

func (*DefMount) Usage

func (m *DefMount) Usage() (int, error)

func (*DefMount) VfsOpts

func (m *DefMount) VfsOpts() ([]string, error)

type DefPort

type DefPort struct {
	// contains filtered or unexported fields
}

func (*DefPort) Exists

func (p *DefPort) Exists() (bool, error)

func (*DefPort) IP

func (p *DefPort) IP() ([]string, error)

func (*DefPort) Listening

func (p *DefPort) Listening() (bool, error)

func (*DefPort) PID

func (p *DefPort) PID() ([]int, error)

PID returns the owning PID of every connection bound to this port. A PID of 0 means gopsutil couldn't resolve an owner (e.g. insufficient permissions to map the socket inode to a process) and is omitted rather than reported as a spurious "pid: 0".

func (*DefPort) Port

func (p *DefPort) Port() string

type DefProcess

type DefProcess struct {
	// contains filtered or unexported fields
}

func (*DefProcess) Executable

func (p *DefProcess) Executable() string

func (*DefProcess) Exists

func (p *DefProcess) Exists() (bool, error)

func (*DefProcess) Pids

func (p *DefProcess) Pids() ([]int, error)

func (*DefProcess) Running

func (p *DefProcess) Running() (bool, error)

func (*DefProcess) Status

func (p *DefProcess) Status() ([]string, error)

Status returns the distinct process states (e.g. "running", "zombie") seen across every PID matching this executable. A process that disappears or can't be read between the snapshot and this call is skipped rather than failing the whole result, same as GetProcs -- except when every one of them fails. See collectPerProcess.

func (*DefProcess) User

func (p *DefProcess) User() ([]string, error)

User returns the distinct usernames owning every PID matching this executable. Same all-or-nothing rule as Status; see collectPerProcess.

type DefSyverfile

type DefSyverfile struct {
	// contains filtered or unexported fields
}

func (*DefSyverfile) Exists

func (g *DefSyverfile) Exists() (bool, error)

Stub out

func (*DefSyverfile) Path

func (g *DefSyverfile) Path() string

type DefUser

type DefUser struct {
	// contains filtered or unexported fields
}

func (*DefUser) Exists

func (u *DefUser) Exists() (bool, error)

Exists distinguishes "user.Lookup ran and genuinely found no such user" (userLookupFoundNothing -- false, nil, unchanged) from every other failure (false, err). The distinction matters most on a domain-joined host with an unreachable domain controller: previously EVERY error, including a transport failure that learned nothing, was folded into "does not exist". See FEAT-010 SW-9 / Trap 1.

func (*DefUser) GID

func (u *DefUser) GID() (int, error)

func (*DefUser) Groups

func (u *DefUser) Groups() ([]string, error)

func (*DefUser) Home

func (u *DefUser) Home() (string, error)

func (*DefUser) Shell

func (u *DefUser) Shell() (string, error)

func (*DefUser) UID

func (u *DefUser) UID() (int, error)

func (*DefUser) Username

func (u *DefUser) Username() string

type File

type File interface {
	Path() string
	Exists() (bool, error)
	Contents() (io.Reader, error)
	Mode() (string, error)
	Size() (int, error)
	Filetype() (string, error)
	Owner() (string, error)
	Uid() (int, error)
	Group() (string, error)
	Gid() (int, error)
	LinkedTo() (string, error)
	Md5() (string, error)
	Sha256() (string, error)
	Sha512() (string, error)
}

func NewDefFile

func NewDefFile(ctx context.Context, path string, system *System, config util.Config) File

type Group

type Group interface {
	Groupname() string
	Exists() (bool, error)
	GID() (int, error)
}

func NewDefGroup

func NewDefGroup(_ context.Context, groupname string, system *System, config util.Config) Group

type HTTP

type HTTP interface {
	HTTP() string
	Status() (int, error)
	Headers() (io.Reader, error)
	Body() (io.Reader, error)
	Exists() (bool, error)
	SetAllowInsecure(bool)
	SetNoFollowRedirects(bool)
	Close() error
}

func NewDefHTTP

func NewDefHTTP(_ context.Context, httpStr string, system *System, config util.Config) HTTP

type Interface

type Interface interface {
	Name() string
	Exists() (bool, error)
	Addrs() ([]string, error)
	MTU() (int, error)
}

func NewDefInterface

func NewDefInterface(_ context.Context, name string, systei *System, config util.Config) Interface

type KernelParam

type KernelParam interface {
	Key() string
	Exists() (bool, error)
	Value() (string, error)
}

func NewDefKernelParam

func NewDefKernelParam(_ context.Context, key string, system *System, config util.Config) KernelParam

type Mount

type Mount interface {
	MountPoint() string
	Exists() (bool, error)
	Opts() ([]string, error)
	VfsOpts() ([]string, error)
	Source() (string, error)
	Filesystem() (string, error)
	Usage() (int, error)
}

func NewDefMount

func NewDefMount(_ context.Context, mountPoint string, system *System, config util.Config) Mount

type NullPackage

type NullPackage struct {
	// contains filtered or unexported fields
}

func (*NullPackage) Exists

func (p *NullPackage) Exists() (bool, error)

func (*NullPackage) Installed

func (p *NullPackage) Installed() (bool, error)

func (*NullPackage) Name

func (p *NullPackage) Name() string

func (*NullPackage) Versions

func (p *NullPackage) Versions() ([]string, error)

type Package

type Package interface {
	Name() string
	Exists() (bool, error)
	Installed() (bool, error)
	Versions() ([]string, error)
}

func NewAlpinePackage

func NewAlpinePackage(ctx context.Context, name string, system *System, config util.Config) Package

func NewDebPackage

func NewDebPackage(ctx context.Context, name string, system *System, config util.Config) Package

func NewNullPackage

func NewNullPackage(_ context.Context, name string, system *System, config util.Config) Package

func NewPacmanPackage

func NewPacmanPackage(ctx context.Context, name string, system *System, config util.Config) Package

func NewRpmPackage

func NewRpmPackage(ctx context.Context, name string, system *System, config util.Config) Package

type PacmanPackage

type PacmanPackage struct {
	// contains filtered or unexported fields
}

func (*PacmanPackage) Exists

func (p *PacmanPackage) Exists() (bool, error)

func (*PacmanPackage) Installed

func (p *PacmanPackage) Installed() (bool, error)

func (*PacmanPackage) Name

func (p *PacmanPackage) Name() string

func (*PacmanPackage) Versions

func (p *PacmanPackage) Versions() ([]string, error)

type Port

type Port interface {
	Port() string
	Exists() (bool, error)
	Listening() (bool, error)
	IP() ([]string, error)
	PID() ([]int, error)
}

func NewDefPort

func NewDefPort(_ context.Context, port string, system *System, config util.Config) Port

type Process

type Process interface {
	Executable() string
	Exists() (bool, error)
	Running() (bool, error)
	Pids() ([]int, error)
	Status() ([]string, error)
	User() ([]string, error)
}

func NewDefProcess

func NewDefProcess(_ context.Context, executable string, system *System, config util.Config) Process

type Registry

type Registry interface {
	Key() string
	Exists() (bool, error)
	Value() (string, error)
	Type() (string, error)
	// SetView selects the WOW64 registry view this resource reads. It is part
	// of the interface rather than a constructor argument because the view is
	// per-resource spec syntax, while the constructor is shared with every
	// other resource type and takes only global config.
	//
	// An unusable view is recorded and surfaces from Exists, Value and Type
	// rather than being returned here, so that a bad `view:` fails the check
	// that used it instead of disappearing into a constructor nobody checks.
	SetView(view string) error
}

func NewDefRegistry

func NewDefRegistry(_ context.Context, key string, system *System, config util.Config) Registry

type RegistryView added in v0.12.0

type RegistryView int

RegistryView is the WOW64 view a registry read is performed against.

On 64-bit Windows some keys exist twice: 64-bit programs see one copy and 32-bit programs, redirected through WOW64, see another under Wow6432Node. A spec that does not say which it means gets whichever the running binary happens to be, which for syver is always 64-bit. Compliance work needs to be able to assert against either.

const (
	// RegistryViewNative is the default and MUST behave exactly as the code did
	// before views existed: no view flag is added to the access mask, so the
	// answer is whatever the OS gives a 64-bit process. Any change here is a
	// silent change to every existing gossfile.
	RegistryViewNative RegistryView = iota
	RegistryView32
	RegistryView64
)

func ParseRegistryView added in v0.12.0

func ParseRegistryView(view string) (RegistryView, error)

ParseRegistryView turns the spec's `view:` string into a RegistryView.

It lives in this untagged file, not in registry_windows.go, so that its tests run on Linux. The grammar is a user-facing contract and does not need a Windows host to be wrong.

func (RegistryView) String added in v0.12.0

func (v RegistryView) String() string

type Resource

type Resource interface {
	Exists() (bool, error)
}

type RpmPackage

type RpmPackage struct {
	// contains filtered or unexported fields
}

func (*RpmPackage) Exists

func (p *RpmPackage) Exists() (bool, error)

func (*RpmPackage) Installed

func (p *RpmPackage) Installed() (bool, error)

func (*RpmPackage) Name

func (p *RpmPackage) Name() string

func (*RpmPackage) Versions

func (p *RpmPackage) Versions() ([]string, error)

type Service

type Service interface {
	Service() string
	Exists() (bool, error)
	Enabled() (bool, error)
	Running() (bool, error)
	RunLevels() ([]string, error)
}

func NewAlpineServiceInit

func NewAlpineServiceInit(ctx context.Context, service string, system *System, config util.Config) Service

func NewServiceInit

func NewServiceInit(ctx context.Context, service string, system *System, config util.Config) Service

func NewServiceSystemd

func NewServiceSystemd(ctx context.Context, service string, system *System, config util.Config) Service

func NewServiceSystemdLegacy

func NewServiceSystemdLegacy(ctx context.Context, service string, system *System, config util.Config) Service

func NewServiceUpstart

func NewServiceUpstart(ctx context.Context, service string, system *System, config util.Config) Service

func NewServiceWindows

func NewServiceWindows(ctx context.Context, service string, system *System, config util.Config) Service

NewServiceWindows stub for non Windows platforms. This is needed for compilation and should never be called since DetectService() only returns "windows" on Windows platforms.

type ServiceInit

type ServiceInit struct {
	// contains filtered or unexported fields
}

func (*ServiceInit) Enabled

func (s *ServiceInit) Enabled() (bool, error)

func (*ServiceInit) Exists

func (s *ServiceInit) Exists() (bool, error)

func (*ServiceInit) RunLevels

func (s *ServiceInit) RunLevels() ([]string, error)

func (*ServiceInit) Running

func (s *ServiceInit) Running() (bool, error)

func (*ServiceInit) Service

func (s *ServiceInit) Service() string

type ServiceSystemd

type ServiceSystemd struct {
	// contains filtered or unexported fields
}

func (*ServiceSystemd) Enabled

func (s *ServiceSystemd) Enabled() (bool, error)

func (*ServiceSystemd) Exists

func (s *ServiceSystemd) Exists() (bool, error)

func (*ServiceSystemd) RunLevels

func (s *ServiceSystemd) RunLevels() ([]string, error)

func (*ServiceSystemd) Running

func (s *ServiceSystemd) Running() (bool, error)

func (*ServiceSystemd) Service

func (s *ServiceSystemd) Service() string

type ServiceUpstart

type ServiceUpstart struct {
	// contains filtered or unexported fields
}

func (*ServiceUpstart) Enabled

func (s *ServiceUpstart) Enabled() (bool, error)

func (*ServiceUpstart) Exists

func (s *ServiceUpstart) Exists() (bool, error)

func (*ServiceUpstart) RunLevels

func (s *ServiceUpstart) RunLevels() ([]string, error)

func (*ServiceUpstart) Running

func (s *ServiceUpstart) Running() (bool, error)

func (*ServiceUpstart) Service

func (s *ServiceUpstart) Service() string

type System

type System struct {
	NewPackage     func(context.Context, string, *System, util2.Config) Package
	NewFile        func(context.Context, string, *System, util2.Config) File
	NewAddr        func(context.Context, string, *System, util2.Config) Addr
	NewPort        func(context.Context, string, *System, util2.Config) Port
	NewService     func(context.Context, string, *System, util2.Config) Service
	NewUser        func(context.Context, string, *System, util2.Config) User
	NewGroup       func(context.Context, string, *System, util2.Config) Group
	NewCommand     func(context.Context, string, *System, util2.Config) Command
	NewDNS         func(context.Context, string, *System, util2.Config) DNS
	NewProcess     func(context.Context, string, *System, util2.Config) Process
	NewSyverfile   func(context.Context, string, *System, util2.Config) Syverfile
	NewKernelParam func(context.Context, string, *System, util2.Config) KernelParam
	NewMount       func(context.Context, string, *System, util2.Config) Mount
	NewInterface   func(context.Context, string, *System, util2.Config) Interface
	NewHTTP        func(context.Context, string, *System, util2.Config) HTTP
	NewRegistry    func(context.Context, string, *System, util2.Config) Registry
	// contains filtered or unexported fields
}

func New

func New(packageManager string) *System

func (*System) Ports

func (s *System) Ports() (map[string][]net.ConnectionStat, error)

func (*System) ProcMap

func (s *System) ProcMap() (map[string][]*process.Process, error)

type Syverfile

type Syverfile interface {
	Path() string
	Exists() (bool, error)
}

func NewDefSyverfile

func NewDefSyverfile(_ context.Context, path string, system *System, config util.Config) Syverfile

type User

type User interface {
	Username() string
	Exists() (bool, error)
	UID() (int, error)
	GID() (int, error)
	Groups() ([]string, error)
	Home() (string, error)
	Shell() (string, error)
}

func NewDefUser

func NewDefUser(_ context.Context, username string, system *System, config util.Config) User

Jump to

Keyboard shortcuts

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