build: automatically include bus/own-* abstraction when required.

This commit is contained in:
Alexandre Pujol 2025-03-23 12:31:43 +01:00
parent 9ab321d146
commit 1f55c07692
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
2 changed files with 9 additions and 2 deletions

View file

@ -110,6 +110,9 @@ func (d Dbus) own(rules map[string]string) aa.Rules {
interfaces := getInterfaces(rules)
res := aa.Rules{
&aa.Include{
IsMagic: true, Path: "abstractions/bus/own-" + rules["bus"],
},
&aa.Dbus{
Access: []string{"bind"}, Bus: rules["bus"], Name: rules["name"],
},

View file

@ -8,7 +8,9 @@ import (
"testing"
)
const dbusOwnSystemd1 = ` dbus bind bus=system name=org.freedesktop.systemd1{,.*},
const dbusOwnSystemd1 = ` include <abstractions/bus/own-system>
dbus bind bus=system name=org.freedesktop.systemd1{,.*},
dbus receive bus=system path=/org/freedesktop/systemd1{,/**}
interface=org.freedesktop.systemd1{,.*}
peer=(name="@{busname}"),
@ -71,7 +73,9 @@ func TestDbus_Apply(t *testing.T) {
Raw: " #aa:dbus own bus=session name=com.rastersoft.ding interface+=org.gtk.Actions",
},
profile: " #aa:dbus own bus=session name=com.rastersoft.ding interface+=org.gtk.Actions",
want: ` dbus bind bus=session name=com.rastersoft.ding{,.*},
want: ` include <abstractions/bus/own-session>
dbus bind bus=session name=com.rastersoft.ding{,.*},
dbus receive bus=session path=/com/rastersoft/ding{,/**}
interface=com.rastersoft.ding{,.*}
peer=(name="@{busname}"),