diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-21 21:23:56 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-21 21:23:56 +0900 |
| commit | cafed5f23468daf2765655325ebe7d879acdde24 (patch) | |
| tree | 10c7977d389dea008e34074f070cf5075898d098 /internal/app | |
| parent | 42e0b168e3d75389dfb968aebf9f5629d64782f9 (diff) | |
shim: abort setup on failed start and process exit
Shim setup listens on a socket in the process share, if shim setup hasn't happened on exit revert will fail. This change makes sure shim setup is aborted on a doomed launch.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/app')
| -rw-r--r-- | internal/app/app.go | 2 | ||||
| -rw-r--r-- | internal/app/start.go | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/internal/app/app.go b/internal/app/app.go index 5c5e3452..0055dd76 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -24,6 +24,8 @@ type app struct { id *ID // underlying user switcher process cmd *exec.Cmd + // shim setup abort reason and completion + abort chan error // child process related information seal *appSeal // error returned waiting for process diff --git a/internal/app/start.go b/internal/app/start.go index b6c94041..464d23df 100644 --- a/internal/app/start.go +++ b/internal/app/start.go @@ -63,7 +63,8 @@ func (a *app) Start() error { a.cmd.Stdin, a.cmd.Stdout, a.cmd.Stderr = os.Stdin, os.Stdout, os.Stderr a.cmd.Dir = a.seal.RunDirPath - if err := shim.ServeConfig(confSockPath, a.seal.sys.UID(), &shim.Payload{ + a.abort = make(chan error) + if err := shim.ServeConfig(confSockPath, a.abort, a.seal.sys.UID(), &shim.Payload{ Argv: a.seal.command, Exec: shimExec, Bwrap: a.seal.sys.bwrap, @@ -71,6 +72,8 @@ func (a *app) Start() error { Verbose: fmsg.Verbose(), }, a.seal.wl); err != nil { + a.abort <- err + <-a.abort return fmsg.WrapErrorSuffix(err, "cannot serve shim setup:") } @@ -232,6 +235,8 @@ func (a *app) Wait() (int, error) { } } + a.abort <- errors.New("shim exited") + <-a.abort if err := a.seal.sys.Revert(ec); err != nil { return err.(RevertCompoundError) } |
