2024-09-24 16:11:08 +09:00
|
|
|
/*
|
|
|
|
Package helper runs external helpers and manages their status and args FDs.
|
|
|
|
*/
|
|
|
|
package helper
|
2024-09-25 01:16:06 +09:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrStatusFault = errors.New("generic status pipe fault")
|
|
|
|
ErrStatusRead = errors.New("unexpected status response")
|
|
|
|
)
|
|
|
|
|
2024-09-29 14:40:01 +09:00
|
|
|
const (
|
2024-10-07 12:48:20 +09:00
|
|
|
// FortifyHelper is set for the process launched by Helper.
|
2024-09-29 14:40:01 +09:00
|
|
|
FortifyHelper = "FORTIFY_HELPER"
|
2024-10-07 12:48:20 +09:00
|
|
|
// FortifyStatus is 1 when sync fd is enabled and 0 otherwise.
|
2024-09-29 14:40:01 +09:00
|
|
|
FortifyStatus = "FORTIFY_STATUS"
|
|
|
|
)
|
|
|
|
|
2024-10-07 15:37:52 +09:00
|
|
|
type Helper interface {
|
|
|
|
// StartNotify starts the helper process.
|
|
|
|
// A status pipe is passed to the helper if ready is not nil.
|
|
|
|
StartNotify(ready chan error) error
|
|
|
|
// Start starts the helper process.
|
|
|
|
Start() error
|
|
|
|
// Close closes the status pipe.
|
|
|
|
// If helper is started without the status pipe, Close panics.
|
|
|
|
Close() error
|
|
|
|
// Wait calls wait on the child process and cleans up pipes.
|
|
|
|
Wait() error
|
|
|
|
// Unwrap returns the underlying exec.Cmd instance.
|
|
|
|
Unwrap() *exec.Cmd
|
2024-09-25 01:16:06 +09:00
|
|
|
}
|
|
|
|
|
2024-09-29 14:40:01 +09:00
|
|
|
var execCommand = exec.Command
|