Documentation
¶
Overview ¶
Package daemonlifecycle provides the small cross-platform primitives shared by CLI daemons: owner-only state paths and advisory file locking.
It deliberately does not own a daemon's state machine, process launching, or recovery policy. Those remain product decisions. This package only keeps the security- and OS-sensitive mechanics identical across CLI implementations.
Index ¶
- func Lock(ctx context.Context, file *os.File, interval time.Duration) error
- func ProtectOwnerOnly(path string) error
- func ProtectOwnerOnlyFile(file *os.File) error
- func TryLock(file *os.File) (bool, error)
- func Unlock(file *os.File) error
- func ValidateOwnerOnly(path string) error
- func ValidateOwnerOnlyFile(file *os.File) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Lock ¶
Lock waits for an exclusive advisory lock, polling at interval until ctx is cancelled. A non-positive interval uses 25 milliseconds.
func ProtectOwnerOnly ¶
ProtectOwnerOnly replaces path's access policy with one granting access only to the current user. Directories keep inheritable permissions for children.
func ProtectOwnerOnlyFile ¶
ProtectOwnerOnlyFile replaces an already-open file's access policy with one granting access only to the current user. Using the handle avoids changing a different path if an attacker replaces a directory entry after it is opened.
func ValidateOwnerOnly ¶
ValidateOwnerOnly verifies that path is a regular file or directory whose effective access policy grants access only to the current user.
func ValidateOwnerOnlyFile ¶
ValidateOwnerOnlyFile verifies the effective policy of an already-open regular file. Consumers that make security decisions after opening a lock or state file should prefer this handle-based form.
Types ¶
This section is empty.