From 584732f80ab91afb349720cfb8e9979ed2ba173e Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Sat, 2 Nov 2024 03:03:44 +0900 Subject: cmd: shim and init into separate binaries This change also fixes a deadlock when shim fails to connect and complete the setup. Signed-off-by: Ophestra Umiker --- internal/shim/payload.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 internal/shim/payload.go (limited to 'internal/shim/payload.go') diff --git a/internal/shim/payload.go b/internal/shim/payload.go deleted file mode 100644 index ba39ec04..00000000 --- a/internal/shim/payload.go +++ /dev/null @@ -1,42 +0,0 @@ -package shim - -import ( - "encoding/gob" - "errors" - "net" - - "git.ophivana.moe/security/fortify/helper/bwrap" - "git.ophivana.moe/security/fortify/internal/fmsg" -) - -const EnvShim = "FORTIFY_SHIM" - -type Payload struct { - // child full argv - Argv []string - // fortify, bwrap, target full exec path - Exec [3]string - // bwrap config - Bwrap *bwrap.Config - // whether to pass wayland fd - WL bool - - // 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:") -} -- cgit v1.3.1