fix(aa): ineffective assignment

This commit is contained in:
Alexandre Pujol 2024-06-23 10:57:46 +01:00
parent ff5ff965cd
commit 228d3b653c
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
12 changed files with 39 additions and 20 deletions

View File

@ -26,7 +26,8 @@ func (r *All) Compare(other Rule) int {
func (r *All) Merge(other Rule) bool {
o, _ := other.(*All)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
func (r *All) String() string {

View File

@ -83,8 +83,10 @@ func (r RuleBase) Merge(other Rule) bool {
return false
}
func (r RuleBase) merge(other RuleBase) bool {
r.Comment += " " + other.Comment
func (r *RuleBase) merge(other RuleBase) bool {
if other.Comment != "" {
r.Comment += " " + other.Comment
}
return true
}

View File

@ -120,7 +120,8 @@ func (r *Dbus) Merge(other Rule) bool {
r.Interface == o.Interface && r.Member == o.Member &&
r.PeerName == o.PeerName && r.PeerLabel == o.PeerLabel {
r.Access = merge(r.Kind(), "access", r.Access, o.Access)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -138,7 +138,8 @@ func (r *File) Merge(other Rule) bool {
}
if r.Owner == o.Owner && r.Path == o.Path && r.Target == o.Target {
r.Access = merge(r.Kind(), "access", r.Access, o.Access)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -71,7 +71,8 @@ func (r *IOUring) Merge(other Rule) bool {
}
if r.Label == o.Label {
r.Access = merge(r.Kind(), "access", r.Access, o.Access)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -65,7 +65,7 @@ func (m MountConditions) Compare(other MountConditions) int {
return compare(m.Options, other.Options)
}
func (m MountConditions) Merge(other MountConditions) bool {
func (m *MountConditions) Merge(other MountConditions) bool {
if m.FsType == other.FsType {
m.Options = merge(MOUNT, "flags", m.Options, other.Options)
return true
@ -143,13 +143,15 @@ func (r *Mount) Compare(other Rule) int {
func (r *Mount) Merge(other Rule) bool {
o, _ := other.(*Mount)
mc := &r.MountConditions
if !r.Qualifier.Equal(o.Qualifier) {
return false
}
if r.Source == o.Source && r.MountPoint == o.MountPoint &&
r.MountConditions.Merge(o.MountConditions) {
return r.RuleBase.merge(o.RuleBase)
mc.Merge(o.MountConditions) {
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}
@ -220,12 +222,14 @@ func (r *Umount) Compare(other Rule) int {
func (r *Umount) Merge(other Rule) bool {
o, _ := other.(*Umount)
mc := &r.MountConditions
if !r.Qualifier.Equal(o.Qualifier) {
return false
}
if r.MountPoint == o.MountPoint && r.MountConditions.Merge(o.MountConditions) {
return r.RuleBase.merge(o.RuleBase)
if r.MountPoint == o.MountPoint && mc.Merge(o.MountConditions) {
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}
@ -297,12 +301,14 @@ func (r *Remount) Compare(other Rule) int {
func (r *Remount) Merge(other Rule) bool {
o, _ := other.(*Remount)
mc := &r.MountConditions
if !r.Qualifier.Equal(o.Qualifier) {
return false
}
if r.MountPoint == o.MountPoint && r.MountConditions.Merge(o.MountConditions) {
return r.RuleBase.merge(o.RuleBase)
if r.MountPoint == o.MountPoint && mc.Merge(o.MountConditions) {
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -105,7 +105,8 @@ func (r *Mqueue) Merge(other Rule) bool {
}
if r.Type == o.Type && r.Label == o.Label && r.Name == o.Name {
r.Access = merge(r.Kind(), "access", r.Access, o.Access)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -261,7 +261,8 @@ func (r *Variable) Merge(other Rule) bool {
if r.Name == o.Name && r.Define == o.Define {
r.Values = merge(r.Kind(), "access", r.Values, o.Values)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -62,7 +62,8 @@ func (r *Ptrace) Merge(other Rule) bool {
}
if r.Peer == o.Peer {
r.Access = merge(r.Kind(), "access", r.Access, o.Access)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -86,10 +86,12 @@ func (r *Signal) Merge(other Rule) bool {
switch {
case r.Peer == o.Peer && compare(r.Set, o.Set) == 0:
r.Access = merge(r.Kind(), "access", r.Access, o.Access)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
case r.Peer == o.Peer && compare(r.Access, o.Access) == 0:
r.Set = merge(r.Kind(), "set", r.Set, o.Set)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -119,7 +119,8 @@ func (r *Unix) Merge(other Rule) bool {
r.Label == o.Label && r.Attr == o.Attr && r.Opt == o.Opt &&
r.PeerLabel == o.PeerLabel && r.PeerAddr == o.PeerAddr {
r.Access = merge(r.Kind(), "access", r.Access, o.Access)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
return false
}

View File

@ -56,7 +56,8 @@ func (r *Userns) Compare(other Rule) int {
func (r *Userns) Merge(other Rule) bool {
o, _ := other.(*Userns)
return r.RuleBase.merge(o.RuleBase)
b := &r.RuleBase
return b.merge(o.RuleBase)
}
func (r *Userns) String() string {