apparmor.d/pkg/aa/pivot_root.go

63 lines
1.3 KiB
Go
Raw Normal View History

// apparmor.d - Full set of apparmor profiles
// Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
// SPDX-License-Identifier: GPL-2.0-only
package aa
2024-05-30 21:56:53 +02:00
const PIVOTROOT Kind = "pivot_root"
type PivotRoot struct {
RuleBase
Qualifier
OldRoot string
NewRoot string
TargetProfile string
}
func newPivotRootFromLog(log map[string]string) Rule {
return &PivotRoot{
RuleBase: newRuleFromLog(log),
2024-04-15 00:58:34 +02:00
Qualifier: newQualifierFromLog(log),
OldRoot: log["srcname"],
NewRoot: log["name"],
TargetProfile: "",
}
}
func (r *PivotRoot) Validate() error {
return nil
}
func (r *PivotRoot) Less(other any) bool {
o, _ := other.(*PivotRoot)
2024-04-15 00:58:34 +02:00
if r.OldRoot != o.OldRoot {
return r.OldRoot < o.OldRoot
}
2024-04-15 00:58:34 +02:00
if r.NewRoot != o.NewRoot {
return r.NewRoot < o.NewRoot
}
if r.TargetProfile != o.TargetProfile {
return r.TargetProfile < o.TargetProfile
}
return r.Qualifier.Less(o.Qualifier)
}
func (r *PivotRoot) Equals(other any) bool {
o, _ := other.(*PivotRoot)
return r.OldRoot == o.OldRoot && r.NewRoot == o.NewRoot &&
r.TargetProfile == o.TargetProfile &&
r.Qualifier.Equals(o.Qualifier)
}
func (r *PivotRoot) String() string {
return renderTemplate(r.Kind(), r)
}
func (r *PivotRoot) Constraint() constraint {
return blockKind
}
func (r *PivotRoot) Kind() Kind {
return PIVOTROOT
}