diff options
| author | Ophestra <cat@gensokyo.uk> | 2024-12-28 11:12:35 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2024-12-28 11:12:35 +0900 |
| commit | 0107620d8c174dcf9237c16d4b4b7b2f6955a214 (patch) | |
| tree | 3b082eafad73eaa971a59baf762260c89917831b /internal/app/share.display.go | |
| parent | fc26659ea11fea8f41fc2551d6d39d30fe3a49e7 (diff) | |
app: merge share methods
This significantly increases readability and makes order of ops more obvious.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/share.display.go')
| -rw-r--r-- | internal/app/share.display.go | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/internal/app/share.display.go b/internal/app/share.display.go deleted file mode 100644 index f09efe61..00000000 --- a/internal/app/share.display.go +++ /dev/null @@ -1,81 +0,0 @@ -package app - -import ( - "errors" - "path" - - "git.gensokyo.uk/security/fortify/acl" - "git.gensokyo.uk/security/fortify/internal/fmsg" - "git.gensokyo.uk/security/fortify/internal/linux" - "git.gensokyo.uk/security/fortify/internal/system" -) - -const ( - term = "TERM" - display = "DISPLAY" - - // https://manpages.debian.org/experimental/libwayland-doc/wl_display_connect.3.en.html - waylandDisplay = "WAYLAND_DISPLAY" -) - -var ( - ErrWayland = errors.New(waylandDisplay + " unset") - ErrXDisplay = errors.New(display + " unset") -) - -func (seal *appSeal) shareDisplay(os linux.System) error { - // pass $TERM to launcher - if t, ok := os.LookupEnv(term); ok { - seal.sys.bwrap.SetEnv[term] = t - } - - // set up wayland - if seal.et.Has(system.EWayland) { - var wp string - if wd, ok := os.LookupEnv(waylandDisplay); !ok { - return fmsg.WrapError(ErrWayland, - "WAYLAND_DISPLAY is not set") - } else { - wp = path.Join(seal.RuntimePath, wd) - } - - w := path.Join(seal.sys.runtime, "wayland-0") - seal.sys.bwrap.SetEnv[waylandDisplay] = w - - if seal.directWayland { - // hardlink wayland socket - wpi := path.Join(seal.shareLocal, "wayland") - seal.sys.Link(wp, wpi) - seal.sys.bwrap.Bind(wpi, w) - - // ensure Wayland socket ACL (e.g. `/run/user/%d/wayland-%d`) - seal.sys.UpdatePermType(system.EWayland, wp, acl.Read, acl.Write, acl.Execute) - } else { - wc := path.Join(seal.SharePath, "wayland") - wt := path.Join(wc, seal.id) - seal.sys.Ensure(wc, 0711) - appID := seal.fid - if appID == "" { - // use instance ID in case app id is not set - appID = "moe.ophivana.fortify." + seal.id - } - seal.sys.Wayland(wt, wp, appID, seal.id) - seal.sys.bwrap.Bind(wt, w) - } - } - - // set up X11 - if seal.et.Has(system.EX11) { - // discover X11 and grant user permission via the `ChangeHosts` command - if d, ok := os.LookupEnv(display); !ok { - return fmsg.WrapError(ErrXDisplay, - "DISPLAY is not set") - } else { - seal.sys.ChangeHosts("#" + seal.sys.user.us) - seal.sys.bwrap.SetEnv[display] = d - seal.sys.bwrap.Bind("/tmp/.X11-unix", "/tmp/.X11-unix") - } - } - - return nil -} |
