From 6bc5be7e5a2334274adf2945ad6d29d063a7086b Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Wed, 23 Oct 2024 21:46:21 +0900 Subject: internal: wrap calls to os standard library functions This change helps tests stub out and simulate OS behaviour during the sealing process. This also removes dependency on XDG_RUNTIME_DIR as the internal.System implementation provided to App provides a compat directory inside the tmpdir-based share when XDG_RUNTIME_DIR is unavailable. Signed-off-by: Ophestra Umiker --- internal/app/system.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'internal/app/system.go') diff --git a/internal/app/system.go b/internal/app/system.go index 2fc413e7..7ccc2eeb 100644 --- a/internal/app/system.go +++ b/internal/app/system.go @@ -5,6 +5,7 @@ import ( "git.ophivana.moe/security/fortify/dbus" "git.ophivana.moe/security/fortify/helper/bwrap" + "git.ophivana.moe/security/fortify/internal" "git.ophivana.moe/security/fortify/internal/system" ) @@ -27,7 +28,7 @@ type appSealSys struct { } // shareAll calls all share methods in sequence -func (seal *appSeal) shareAll(bus [2]*dbus.Config) error { +func (seal *appSeal) shareAll(bus [2]*dbus.Config, os internal.System) error { if seal.shared { panic("seal shared twice") } @@ -35,11 +36,11 @@ func (seal *appSeal) shareAll(bus [2]*dbus.Config) error { seal.shareSystem() seal.shareRuntime() - seal.sharePasswd() - if err := seal.shareDisplay(); err != nil { + seal.sharePasswd(os) + if err := seal.shareDisplay(os); err != nil { return err } - if err := seal.sharePulse(); err != nil { + if err := seal.sharePulse(os); err != nil { return err } -- cgit v1.3.1