91 lines
2.1 KiB
Go
Executable File
91 lines
2.1 KiB
Go
Executable File
//go:build !linux
|
|
|
|
// Package ebpf provides stubs for non-Linux platforms.
|
|
// eBPF is Linux-only; on other platforms all operations are no-ops.
|
|
package ebpf
|
|
|
|
import "errors"
|
|
|
|
type EnforceMode uint32
|
|
|
|
const (
|
|
ModePermissive EnforceMode = 0
|
|
ModeEnforcing EnforceMode = 1
|
|
)
|
|
|
|
type Violation struct {
|
|
PID uint32
|
|
TID uint32
|
|
UID uint32
|
|
GID uint32
|
|
PPID uint32
|
|
SyscallNr uint32
|
|
Comm string
|
|
Path string
|
|
AccessMask int32
|
|
}
|
|
|
|
type ViolationHandler func(Violation)
|
|
|
|
type EBPFEnforcer struct{}
|
|
|
|
func NewEnforcer() *EBPFEnforcer {
|
|
return &EBPFEnforcer{}
|
|
}
|
|
|
|
func (e *EBPFEnforcer) Load() error {
|
|
return errors.New("ebpf: not available on this platform (Linux >= 5.7 required)")
|
|
}
|
|
|
|
func (e *EBPFEnforcer) AttachCgroup(cgroupPath string) error {
|
|
return errors.New("ebpf: not available on this platform")
|
|
}
|
|
|
|
func (e *EBPFEnforcer) SetEnforceMode(mode EnforceMode) error {
|
|
return nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) GetEnforceMode() (EnforceMode, error) {
|
|
return ModePermissive, nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) SetTombPath(path string) error {
|
|
return nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) SetStatePath(path string) error {
|
|
return nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) AddTrustedPID(pid uint32) error {
|
|
return nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) RemoveTrustedPID(pid uint32) error {
|
|
return nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) AllowDevice(major, minor, access uint32) error {
|
|
return nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) AddNetworkRule(index uint32, ip, mask uint32, port uint16, protocol uint16) error {
|
|
return nil
|
|
}
|
|
|
|
func (e *EBPFEnforcer) WatchViolations(handler ViolationHandler) error {
|
|
return errors.New("ebpf: not available on this platform")
|
|
}
|
|
|
|
func (e *EBPFEnforcer) StopWatching() {}
|
|
|
|
func (e *EBPFEnforcer) Close() {}
|
|
|
|
func (e *EBPFEnforcer) IsLoaded() bool { return false }
|
|
func (e *EBPFEnforcer) IsCgroupAttached() bool { return false }
|
|
func (e *EBPFEnforcer) SelfTrustedPID() error { return nil }
|
|
func (e *EBPFEnforcer) Status() string { return "eBPF: not available (non-Linux)" }
|
|
|
|
func ProbeCapabilities() (lsm, cgroupDev, cgroupNet bool, err error) {
|
|
return false, false, false, nil
|
|
} |