process

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package process inspects App Sandbox status and code-signing entitlements for the current process and for arbitrary PIDs.

It offers two complementary paths: a csops(2) syscall path (no Objective-C runtime, safe to call from any goroutine) used by the *Self helpers, and the Security framework's SecTask APIs for richer queries. Process lookups fall back to reading the executable's static signature (see package codesign).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPID is returned when a process identifier is not positive.
	ErrInvalidPID = errors.New("invalid pid")

	// ErrCSOps is returned when the csops(2) system call fails.
	ErrCSOps = errors.New("csops operation failed")
)

Functions

func CurrentEntitlementBoolSelf

func CurrentEntitlementBoolSelf(key string) (bool, error)

CurrentEntitlementBoolSelf reports whether the current process holds a Boolean entitlement, read via csops(2) (no Objective-C runtime). A missing entitlement returns (false, nil).

func CurrentTaskEntitlement

func CurrentTaskEntitlement(key string) (any, error)

CurrentTaskEntitlement returns the entitlement value for the current process.

func CurrentTaskEntitlements

func CurrentTaskEntitlements(keys []string) (map[string]any, error)

CurrentTaskEntitlements returns entitlement values for the given keys on the current process. Missing keys are omitted from the result map.

func HasCurrentTaskEntitlement

func HasCurrentTaskEntitlement(key string) (bool, error)

HasCurrentTaskEntitlement reports whether the current process holds a Boolean entitlement. A missing entitlement returns (false, nil).

func IsProcessSandboxed

func IsProcessSandboxed(pid int) (bool, error)

IsProcessSandboxed reports whether pid runs with App Sandbox enabled. A missing entitlement returns (false, nil).

func IsSandboxed

func IsSandboxed() (bool, error)

IsSandboxed reports whether the current process has App Sandbox enabled.

func IsSandboxedSelf

func IsSandboxedSelf() (bool, error)

IsSandboxedSelf reports whether the current process runs under the App Sandbox, determined from its code-signing entitlements via the csops(2) syscall.

Unlike IsSandboxed it does NOT use the Objective-C runtime (no SecTask, no main-thread dispatch). That makes it safe to call from code paths that themselves dispatch to the main thread — the SDK auto-dispatches @MainActor calls via dispatch_sync to the main queue, which would deadlock if the main thread is not draining it. A missing entitlement returns (false, nil).

func ProcessApplicationGroups

func ProcessApplicationGroups(pid int) ([]string, error)

ProcessApplicationGroups returns application group identifiers granted to pid.

func ProcessEntitlement

func ProcessEntitlement(pid int, key string) (any, error)

ProcessEntitlement returns one runtime entitlement value for pid.

func ProcessEntitlementBool

func ProcessEntitlementBool(pid int, key string) (bool, error)

ProcessEntitlementBool reports whether pid holds a Boolean entitlement. A missing entitlement returns (false, nil).

func ProcessEntitlementString

func ProcessEntitlementString(pid int, key string) (string, error)

ProcessEntitlementString coerces a string entitlement for pid when present.

func ProcessEntitlements

func ProcessEntitlements(pid int, keys []string) (map[string]any, error)

ProcessEntitlements returns runtime entitlement values for pid and keys. Missing keys are omitted from the result map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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