diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-19 00:25:00 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-19 00:25:00 +0900 |
| commit | a748d40745611b471ee2a8dd79656aaa174eb03c (patch) | |
| tree | 6734d036b37ebd40798578a60cf54c2527515a60 /internal/app/app.go | |
| parent | 648e1d641a8b0ae7c5bc4899f84b884d4335c97f (diff) | |
app: store values with string representation
Improves code readability without changing memory layout.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/app.go')
| -rw-r--r-- | internal/app/app.go | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/internal/app/app.go b/internal/app/app.go index cf21ac71..aa798af6 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -1,6 +1,7 @@ package app import ( + "fmt" "sync" "git.gensokyo.uk/security/fortify/fst" @@ -10,14 +11,18 @@ import ( func New(os sys.State) (fst.App, error) { a := new(app) - a.id = new(fst.ID) a.os = os - return a, fst.NewAppID(a.id) + + id := new(fst.ID) + err := fst.NewAppID(id) + a.id = newID(id) + + return a, err } type app struct { // application unique identifier - id *fst.ID + id *stringPair[fst.ID] // operating system interface os sys.State // shim process manager @@ -28,13 +33,11 @@ type app struct { lock sync.RWMutex } -func (a *app) ID() fst.ID { - return *a.id -} +func (a *app) ID() fst.ID { return a.id.unwrap() } func (a *app) String() string { if a == nil { - return "(invalid fortified app)" + return "(invalid app)" } a.lock.RLock() @@ -45,8 +48,11 @@ func (a *app) String() string { } if a.seal != nil { - return "(sealed fortified app as uid " + a.seal.sys.user.us + ")" + if a.seal.sys.user.uid == nil { + return fmt.Sprintf("(sealed app %s with invalid uid)", a.id) + } + return fmt.Sprintf("(sealed app %s as uid %s)", a.id, a.seal.sys.user.uid) } - return "(unsealed fortified app)" + return fmt.Sprintf("(unsealed app %s)", a.id) } |
