aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/shim/parent.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/shim/parent.go')
-rw-r--r--internal/shim/parent.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/internal/shim/parent.go b/internal/shim/parent.go
index 0e903838..6c393c58 100644
--- a/internal/shim/parent.go
+++ b/internal/shim/parent.go
@@ -3,13 +3,12 @@ package shim
import (
"encoding/gob"
"errors"
- "fmt"
"net"
"os"
"syscall"
"git.ophivana.moe/security/fortify/acl"
- "git.ophivana.moe/security/fortify/internal/verbose"
+ "git.ophivana.moe/security/fortify/internal/fmsg"
)
// called in the parent process
@@ -19,7 +18,7 @@ func ServeConfig(socket string, uid int, payload *Payload, wl *Wayland) error {
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)
+ fmsg.VPrintf("connected to wayland at %q", wl.Path)
wl.UnixConn = f
}
}
@@ -27,18 +26,18 @@ func ServeConfig(socket string, uid int, payload *Payload, wl *Wayland) error {
if c, err := net.ListenUnix("unix", &net.UnixAddr{Name: socket, Net: "unix"}); err != nil {
return err
} else {
- verbose.Println("configuring shim on socket", socket)
+ fmsg.VPrintf("configuring shim on socket %q", socket)
if err = acl.UpdatePerm(socket, uid, acl.Read, acl.Write, acl.Execute); err != nil {
- fmt.Println("fortify: cannot change permissions of shim setup socket:", err)
+ fmsg.Println("cannot change permissions of shim setup socket:", err)
}
go func() {
var conn *net.UnixConn
if conn, err = c.AcceptUnix(); err != nil {
- fmt.Println("fortify: cannot accept connection from shim:", err)
+ fmsg.Println("cannot accept connection from shim:", err)
} else {
if err = gob.NewEncoder(conn).Encode(*payload); err != nil {
- fmt.Println("fortify: cannot stream shim payload:", err)
+ fmsg.Println("cannot stream shim payload:", err)
_ = os.Remove(socket)
return
}
@@ -47,23 +46,23 @@ func ServeConfig(socket string, uid int, payload *Payload, wl *Wayland) error {
// get raw connection
var rc syscall.RawConn
if rc, err = wl.SyscallConn(); err != nil {
- fmt.Println("fortify: cannot obtain raw wayland connection:", err)
+ fmsg.Println("cannot obtain raw wayland connection:", err)
return
} else {
go func() {
// pass wayland socket fd
if err = rc.Control(func(fd uintptr) {
if _, _, err = conn.WriteMsgUnix(nil, syscall.UnixRights(int(fd)), nil); err != nil {
- fmt.Println("fortify: cannot pass wayland connection to shim:", err)
+ fmsg.Println("cannot pass wayland connection to shim:", err)
return
}
_ = conn.Close()
// block until shim exits
<-wl.done
- verbose.Println("releasing wayland connection")
+ fmsg.VPrintln("releasing wayland connection")
}); err != nil {
- fmt.Println("fortify: cannot obtain wayland connection fd:", err)
+ fmsg.Println("cannot obtain wayland connection fd:", err)
}
}()
}
@@ -72,10 +71,10 @@ func ServeConfig(socket string, uid int, payload *Payload, wl *Wayland) error {
}
}
if err = c.Close(); err != nil {
- fmt.Println("fortify: cannot close shim socket:", err)
+ fmsg.Println("cannot close shim socket:", err)
}
if err = os.Remove(socket); err != nil && !errors.Is(err, os.ErrNotExist) {
- fmt.Println("fortify: cannot remove dangling shim socket:", err)
+ fmsg.Println("cannot remove dangling shim socket:", err)
}
}()
return nil