feat(aa): add file kind.
This commit is contained in:
parent
157c365b26
commit
107820975d
1 changed files with 27 additions and 0 deletions
|
|
@ -5,12 +5,39 @@
|
|||
package aa
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/roddhjav/apparmor.d/pkg/paths"
|
||||
)
|
||||
|
||||
// MagicRoot is the default Apparmor magic directory: /etc/apparmor.d/.
|
||||
var MagicRoot = paths.New("/etc/apparmor.d")
|
||||
|
||||
// FileKind represents an AppArmor file kind.
|
||||
type FileKind uint8
|
||||
|
||||
const (
|
||||
ProfileKind FileKind = iota
|
||||
AbstractionKind
|
||||
TunableKind
|
||||
)
|
||||
|
||||
func KindFromPath(file *paths.Path) FileKind {
|
||||
dirname := file.Parent().String()
|
||||
switch {
|
||||
case strings.Contains(dirname, "abstractions"):
|
||||
return AbstractionKind
|
||||
case strings.Contains(dirname, "tunables"):
|
||||
return TunableKind
|
||||
case strings.Contains(dirname, "local"):
|
||||
return AbstractionKind
|
||||
case strings.Contains(dirname, "mappings"):
|
||||
return AbstractionKind
|
||||
default:
|
||||
return ProfileKind
|
||||
}
|
||||
}
|
||||
|
||||
// AppArmorProfileFiles represents a full set of apparmor profiles
|
||||
type AppArmorProfileFiles map[string]*AppArmorProfileFile
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue