aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/shim/parent.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-20 22:54:47 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-21 18:46:06 +0900
commit380d1f45851b7dffb963c51da96a17ba41f3cfb8 (patch)
tree984c9b50d890157847e3f3bc942659e6431c03a9 /internal/shim/parent.go
parent133f23e0de77dc32de2753b23ed8173344a0e699 (diff)
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 <cat@ophivana.moe>
Diffstat (limited to 'internal/shim/parent.go')
-rw-r--r--internal/shim/parent.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/internal/shim/parent.go b/internal/shim/parent.go
index 9382db22..0e903838 100644
--- a/internal/shim/parent.go
+++ b/internal/shim/parent.go
@@ -14,19 +14,18 @@ import (
// called in the parent process
-func ServeConfig(socket string, uid int, payload *Payload, wl string, done chan struct{}) (*net.UnixConn, error) {
- var ws *net.UnixConn
+func ServeConfig(socket string, uid int, payload *Payload, wl *Wayland) error {
if payload.WL {
- if f, err := net.DialUnix("unix", nil, &net.UnixAddr{Name: wl, Net: "unix"}); err != nil {
- return nil, err
+ if f, err := net.DialUnix("unix", nil, &net.UnixAddr{Name: wl.Path, Net: "unix"}); err != nil {
+ return err
} else {
verbose.Println("connected to wayland at", wl)
- ws = f
+ wl.UnixConn = f
}
}
if c, err := net.ListenUnix("unix", &net.UnixAddr{Name: socket, Net: "unix"}); err != nil {
- return nil, err
+ return err
} else {
verbose.Println("configuring shim on socket", socket)
if err = acl.UpdatePerm(socket, uid, acl.Read, acl.Write, acl.Execute); err != nil {
@@ -47,7 +46,7 @@ func ServeConfig(socket string, uid int, payload *Payload, wl string, done chan
if payload.WL {
// get raw connection
var rc syscall.RawConn
- if rc, err = ws.SyscallConn(); err != nil {
+ if rc, err = wl.SyscallConn(); err != nil {
fmt.Println("fortify: cannot obtain raw wayland connection:", err)
return
} else {
@@ -61,7 +60,7 @@ func ServeConfig(socket string, uid int, payload *Payload, wl string, done chan
_ = conn.Close()
// block until shim exits
- <-done
+ <-wl.done
verbose.Println("releasing wayland connection")
}); err != nil {
fmt.Println("fortify: cannot obtain wayland connection fd:", err)
@@ -79,6 +78,6 @@ func ServeConfig(socket string, uid int, payload *Payload, wl string, done chan
fmt.Println("fortify: cannot remove dangling shim socket:", err)
}
}()
- return ws, nil
+ return nil
}
}