forked from security/hakurei
app: embed appSeal in app struct
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func New(os sys.State) (fst.App, error) {
|
||||
a := new(app)
|
||||
a.os = os
|
||||
a.sys = os
|
||||
|
||||
id := new(fst.ID)
|
||||
err := fst.NewAppID(id)
|
||||
@@ -24,13 +24,12 @@ type app struct {
|
||||
// application unique identifier
|
||||
id *stringPair[fst.ID]
|
||||
// operating system interface
|
||||
os sys.State
|
||||
sys sys.State
|
||||
// shim process manager
|
||||
shim *shim.Shim
|
||||
// child process related information
|
||||
seal *appSeal
|
||||
|
||||
lock sync.RWMutex
|
||||
mu sync.RWMutex
|
||||
*appSeal
|
||||
}
|
||||
|
||||
func (a *app) ID() fst.ID { return a.id.unwrap() }
|
||||
@@ -40,18 +39,18 @@ func (a *app) String() string {
|
||||
return "(invalid app)"
|
||||
}
|
||||
|
||||
a.lock.RLock()
|
||||
defer a.lock.RUnlock()
|
||||
a.mu.RLock()
|
||||
defer a.mu.RUnlock()
|
||||
|
||||
if a.shim != nil {
|
||||
return a.shim.String()
|
||||
}
|
||||
|
||||
if a.seal != nil {
|
||||
if a.seal.sys.user.uid == nil {
|
||||
if a.appSeal != nil {
|
||||
if a.appSeal.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 fmt.Sprintf("(sealed app %s as uid %s)", a.id, a.appSeal.sys.user.uid)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("(unsealed app %s)", a.id)
|
||||
|
||||
Reference in New Issue
Block a user