build: update directives with the new interface.

This commit is contained in:
Alexandre Pujol 2024-03-25 22:40:25 +00:00
parent 38e9e5f08e
commit 08d4110c2a
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
9 changed files with 63 additions and 89 deletions

View file

@ -8,20 +8,22 @@ import (
"strings"
"github.com/roddhjav/apparmor.d/pkg/aa"
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
"golang.org/x/exp/slices"
)
type Exec struct {
DirectiveBase
cfg.Base
}
func init() {
Directives["exec"] = &Exec{
DirectiveBase: DirectiveBase{
message: "Exec directive applied",
usage: `#aa:exec [P|U|p|u|PU|pu|] profiles_name...`,
RegisterDirective(&Exec{
Base: cfg.Base{
Keyword: "exec",
Msg: "Exec directive applied",
Help: `#aa:exec [P|U|p|u|PU|pu|] profiles...`,
},
}
})
}
func (d Exec) Apply(opt *Option, profile string) string {
@ -35,7 +37,7 @@ func (d Exec) Apply(opt *Option, profile string) string {
p := &aa.AppArmorProfile{}
for name := range opt.ArgMap {
content, err := rootApparmord.Join(name).ReadFile()
content, err := cfg.RootApparmord.Join(name).ReadFile()
if err != nil {
panic(err)
}