feat(aa): add implementation of the new rule methods.

This commit is contained in:
Alexandre Pujol 2024-06-29 22:27:39 +01:00
parent 8b24f3521d
commit 0e0f87611a
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
19 changed files with 380 additions and 2 deletions

View file

@ -73,6 +73,21 @@ func (m *MountConditions) Merge(other MountConditions) bool {
return false
}
func (m MountConditions) getLenFsType() int {
return length("fstype=", m.FsType)
}
func (m MountConditions) getLenOptions() int {
return length("options=", m.Options)
}
func (m MountConditions) setPaddings(max []int) []string {
return setPaddings(max,
[]string{"fstype=", "options="},
[]any{m.FsType, m.Options},
)
}
type Mount struct {
Base
Qualifier
@ -168,6 +183,24 @@ func (r *Mount) Merge(other Rule) bool {
return false
}
func (r *Mount) Lengths() []int {
return []int{
r.Qualifier.getLenAudit(),
r.Qualifier.getLenAccess(),
r.MountConditions.getLenFsType(),
r.MountConditions.getLenOptions(),
length("", r.Source),
length("", r.MountPoint),
}
}
func (r *Mount) setPaddings(max []int) {
r.Paddings = append(r.Qualifier.setPaddings(max[:2]), r.MountConditions.setPaddings(max[2:4])...)
r.Paddings = append(r.Paddings,
setPaddings(max[4:], []string{"", ""}, []any{r.Source, r.MountPoint})...,
)
}
type Umount struct {
Base
Qualifier
@ -246,6 +279,23 @@ func (r *Umount) Merge(other Rule) bool {
return false
}
func (r *Umount) Lengths() []int {
return []int{
r.Qualifier.getLenAudit(),
r.Qualifier.getLenAccess(),
r.MountConditions.getLenFsType(),
r.MountConditions.getLenOptions(),
length("", r.MountPoint),
}
}
func (r *Umount) setPaddings(max []int) {
r.Paddings = append(r.Qualifier.setPaddings(max[:2]), r.MountConditions.setPaddings(max[2:4])...)
r.Paddings = append(r.Paddings,
setPaddings(max[4:], []string{""}, []any{r.MountPoint})...,
)
}
type Remount struct {
Base
Qualifier
@ -324,3 +374,20 @@ func (r *Remount) Merge(other Rule) bool {
}
return false
}
func (r *Remount) Lengths() []int {
return []int{
r.Qualifier.getLenAudit(),
r.Qualifier.getLenAccess(),
r.MountConditions.getLenFsType(),
r.MountConditions.getLenOptions(),
length("", r.MountPoint),
}
}
func (r *Remount) setPaddings(max []int) {
r.Paddings = append(r.Qualifier.setPaddings(max[:2]), r.MountConditions.setPaddings(max[2:4])...)
r.Paddings = append(r.Paddings,
setPaddings(max[4:], []string{""}, []any{r.MountPoint})...,
)
}