From e9a7cd526f4e5f0a8f7b18ad3682d2e3afbcb8ba Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 5 Apr 2025 23:51:39 +0900 Subject: app: improve shim process management This ensures a signal gets delivered to the process instead of relying on parent death behaviour. SIGCONT was chosen as it is the only signal an unprivileged process is allowed to send to processes with different credentials. A custom signal handler is installed because the Go runtime does not expose signal information other than which signal was received, and shim must check pid to ensure reasonable behaviour. Signed-off-by: Ophestra --- fst/app.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'fst/app.go') diff --git a/fst/app.go b/fst/app.go index 3e026391..51ff0d7a 100644 --- a/fst/app.go +++ b/fst/app.go @@ -2,6 +2,7 @@ package fst import ( + "syscall" "time" ) @@ -28,12 +29,21 @@ type RunState struct { // // Time is nil if no process was ever created. Time *time.Time - // ExitCode is the value returned by shim. - ExitCode int // RevertErr is stored by the deferred revert call. RevertErr error - // WaitErr is error returned by the underlying wait syscall. + // WaitErr is the generic error value created by the standard library. WaitErr error + + syscall.WaitStatus +} + +// SetStart stores the current time in [RunState] once. +func (rs *RunState) SetStart() { + if rs.Time != nil { + panic("attempted to store time twice") + } + now := time.Now().UTC() + rs.Time = &now } // Paths contains environment-dependent paths used by fortify. -- cgit v1.3.1