aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/state/state.go
blob: 81df9655cd9b5aa4bfc3135eb851d9313f0b875e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package state

import (
	"time"

	"git.ophivana.moe/security/fortify/internal/system"
)

type Store interface {
	// Do calls f exactly once and ensures store exclusivity until f returns.
	// Returns whether f is called and any errors during the locking process.
	// Backend provided to f becomes invalid as soon as f returns.
	Do(f func(b Backend)) (bool, error)

	// Close releases any resources held by Store.
	Close() error
}

// Backend provides access to the store
type Backend interface {
	Save(state *State) error
	Destroy(pid int) error
	Load() ([]*State, error)
	Len() (int, error)
}

// State is the on-disk format for a fortified process's state information
type State struct {
	// child process PID value
	PID int
	// command used to seal the app
	Command []string
	// capability enablements applied to child
	Capability system.Enablements

	// user switch method
	Method string
	// full argv whe launching
	Argv []string
	// process start time
	Time time.Time
}