app: ensure extra paths
All checks were successful
Tests / Go tests (push) Successful in 36s
Nix / NixOS tests (push) Successful in 3m37s

The primary use case for extra perms is app-specific state directories, which may or may not exist (first run of any app).

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2024-12-28 14:07:49 +09:00
parent 66ec0d882f
commit b9e2003d5b
3 changed files with 14 additions and 4 deletions

View File

@@ -81,6 +81,7 @@ type SandboxConfig struct {
}
type ExtraPermConfig struct {
Ensure bool `json:"ensure,omitempty"`
Path string `json:"path"`
Read bool `json:"r,omitempty"`
Write bool `json:"w,omitempty"`
@@ -88,8 +89,12 @@ type ExtraPermConfig struct {
}
func (e *ExtraPermConfig) String() string {
buf := make([]byte, 0, 4+len(e.Path))
buf = append(buf, '-', '-', '-', ':')
buf := make([]byte, 0, 5+len(e.Path))
buf = append(buf, '-', '-', '-')
if e.Ensure {
buf = append(buf, '+')
}
buf = append(buf, ':')
buf = append(buf, []byte(e.Path)...)
if e.Read {
buf[0] = 'r'