app: extra acl entries from configuration

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2024-12-28 13:23:27 +09:00
parent c70f0612ad
commit 847b667489
4 changed files with 134 additions and 59 deletions

View File

@@ -35,6 +35,8 @@ type ConfinementConfig struct {
Outer string `json:"home"`
// bwrap sandbox confinement configuration
Sandbox *SandboxConfig `json:"sandbox"`
// extra acl entries to append
ExtraPerms []*ExtraPermConfig `json:"extra_perms,omitempty"`
// reference to a system D-Bus proxy configuration,
// nil value disables system bus proxy
@@ -78,6 +80,29 @@ type SandboxConfig struct {
Override []string `json:"override"`
}
type ExtraPermConfig struct {
Path string `json:"path"`
Read bool `json:"r,omitempty"`
Write bool `json:"w,omitempty"`
Execute bool `json:"x,omitempty"`
}
func (e *ExtraPermConfig) String() string {
buf := make([]byte, 0, 4+len(e.Path))
buf = append(buf, '-', '-', '-', ':')
buf = append(buf, []byte(e.Path)...)
if e.Read {
buf[0] = 'r'
}
if e.Write {
buf[1] = 'w'
}
if e.Execute {
buf[2] = 'x'
}
return string(buf)
}
type FilesystemConfig struct {
// mount point in sandbox, same as src if empty
Dst string `json:"dst,omitempty"`