From 380d1f45851b7dffb963c51da96a17ba41f3cfb8 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Sun, 20 Oct 2024 22:54:47 +0900 Subject: app: move wayland mediation to shim package Values used in the Wayland mediation implementation is stored in various struct fields strewn across multiple app structs and checks are messy and confusing. This commit unifies them into a single struct and access it using much better looking methods. Signed-off-by: Ophestra Umiker --- internal/app/start.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'internal/app/start.go') diff --git a/internal/app/start.go b/internal/app/start.go index 6d301028..3106a1e8 100644 --- a/internal/app/start.go +++ b/internal/app/start.go @@ -62,23 +62,19 @@ func (a *app) Start() error { confSockPath := path.Join(a.seal.share, "shim") a.cmd = exec.Command(a.seal.toolPath, commandBuilder(shim.EnvShim+"="+confSockPath)...) a.cmd.Env = []string{} - a.cmd.Stdin = os.Stdin - a.cmd.Stdout = os.Stdout - a.cmd.Stderr = os.Stderr + a.cmd.Stdin, a.cmd.Stdout, a.cmd.Stderr = os.Stdin, os.Stdout, os.Stderr a.cmd.Dir = a.seal.RunDirPath - if wls, err := shim.ServeConfig(confSockPath, a.seal.sys.UID(), &shim.Payload{ + if err := shim.ServeConfig(confSockPath, a.seal.sys.UID(), &shim.Payload{ Argv: a.seal.command, Exec: shimExec, Bwrap: a.seal.sys.bwrap, - WL: a.seal.wlDone != nil, + WL: a.seal.wl != nil, Verbose: verbose.Get(), - }, a.seal.wl, a.seal.wlDone); err != nil { + }, a.seal.wl); err != nil { return fmsg.WrapErrorSuffix(err, - "cannot listen on shim socket:") - } else { - a.wayland = wls + "cannot serve shim setup:") } // start shim @@ -185,9 +181,8 @@ func (a *app) Wait() (int, error) { verbose.Println("process", strconv.Itoa(a.cmd.Process.Pid), "exited with exit code", r) // close wayland connection - if a.wayland != nil { - close(a.seal.wlDone) - if err := a.wayland.Close(); err != nil { + if a.seal.wl != nil { + if err := a.seal.wl.Close(); err != nil { fmt.Println("fortify: cannot close wayland connection:", err) } } -- cgit v1.3.1