diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-27 00:46:15 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-27 00:46:15 +0900 |
| commit | 1d6ea8120552665072f5044a004128e7dbbf3a64 (patch) | |
| tree | 1ea0b9d2f687909cdd5fab3fbf50c473f942e7cf /internal/shim/payload.go | |
| parent | ae1a102882103221ef842176dfd8cb1090d5f591 (diff) | |
shim: user switcher process management struct
This change moves all user switcher and shim management to the shim package and withholds output while shim is alive. This also eliminated all exit scenarios where revert is skipped.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/shim/payload.go')
| -rw-r--r-- | internal/shim/payload.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/internal/shim/payload.go b/internal/shim/payload.go index 5d9552d4..ba39ec04 100644 --- a/internal/shim/payload.go +++ b/internal/shim/payload.go @@ -1,6 +1,13 @@ package shim -import "git.ophivana.moe/security/fortify/helper/bwrap" +import ( + "encoding/gob" + "errors" + "net" + + "git.ophivana.moe/security/fortify/helper/bwrap" + "git.ophivana.moe/security/fortify/internal/fmsg" +) const EnvShim = "FORTIFY_SHIM" @@ -17,3 +24,19 @@ type Payload struct { // verbosity pass through Verbose bool } + +func (p *Payload) serve(conn *net.UnixConn, wl *Wayland) error { + if err := gob.NewEncoder(conn).Encode(*p); err != nil { + return fmsg.WrapErrorSuffix(err, + "cannot stream shim payload:") + } + + if wl != nil { + if err := wl.WriteUnix(conn); err != nil { + return errors.Join(err, conn.Close()) + } + } + + return fmsg.WrapErrorSuffix(conn.Close(), + "cannot close setup connection:") +} |
