diff options
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:") +} |
