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/app.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'internal/app/app.go') diff --git a/internal/app/app.go b/internal/app/app.go index 0055dd76..de2c461f 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -3,6 +3,8 @@ package app import ( "os/exec" "sync" + + "git.ophivana.moe/security/fortify/internal" ) type App interface { @@ -22,6 +24,8 @@ type App interface { type app struct { // application unique identifier id *ID + // operating system interface + os internal.System // underlying user switcher process cmd *exec.Cmd // shim setup abort reason and completion @@ -61,8 +65,9 @@ func (a *app) WaitErr() error { return a.waitErr } -func New() (App, error) { +func New(os internal.System) (App, error) { a := new(app) a.id = new(ID) + a.os = os return a, newAppID(a.id) } -- cgit v1.3.1