feat(build): simplify some internal tooling.

This commit is contained in:
Alexandre Pujol 2024-04-02 17:48:03 +01:00
parent 791459e39a
commit 1915fa5175
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
14 changed files with 140 additions and 121 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/roddhjav/apparmor.d/pkg/aa"
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
"github.com/roddhjav/apparmor.d/pkg/util"
"golang.org/x/exp/slices"
)
@ -21,7 +22,7 @@ func init() {
Base: cfg.Base{
Keyword: "exec",
Msg: "Exec directive applied",
Help: `#aa:exec [P|U|p|u|PU|pu|] profiles...`,
Help: Keyword + `exec [P|U|p|u|PU|pu|] profiles...`,
},
})
}
@ -37,12 +38,7 @@ func (d Exec) Apply(opt *Option, profile string) string {
p := &aa.AppArmorProfile{}
for name := range opt.ArgMap {
content, err := cfg.RootApparmord.Join(name).ReadFile()
if err != nil {
panic(err)
}
profiletoTransition := string(content)
profiletoTransition := util.MustReadFile(cfg.RootApparmord.Join(name))
dstProfile := aa.DefaultTunables()
dstProfile.ParseVariables(profiletoTransition)
for _, variable := range dstProfile.Variables {