@ogra Thanks for pulling my changes into the pulseaudio snap. It looks like the functionality we need is almost all in place. I am testing with the versions of bluez, pulseaudio, and core in the edge channel, and it is mostly working. However, I do still need to install both bluez and pulseaudio in devmode to avoid apparmor rejections. It may be that the 2.29 update to core fixed some but not all of the rejects. I also found that I need to modify /etc/dbus-1/system.d/snap.bluez.bluez.conf to get audio devices working.
When pulseaudio starts up and loads the module-bluetooth-discover module, it connects to bluez over dbus. There are numerous apparmor messages related to that.
Jan 04 20:36:42 localhost.localdomain audit[1579]: AVC apparmor="ALLOWED" operation="connect" profile="snap.pulseaudio.pulseaudio" name="/run/dbus/system_bus_socket" pid=1579 comm="pulseaudio" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0
Jan 04 20:36:42 localhost.localdomain audit[1579]: AVC apparmor="ALLOWED" operation="file_perm" profile="snap.pulseaudio.pulseaudio" name="/run/dbus/system_bus_socket" pid=1579 comm="pulseaudio" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" member="Hello" mask="send" name="org.freedesktop.DBus" pid=1579 label="snap.pulseaudio.pulseaudio" peer_label="unconfined"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" member="AddMatch" mask="send" name="org.freedesktop.DBus" pid=1579 label="snap.pulseaudio.pulseaudio" peer_label="unconfined"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=1579 label="snap.pulseaudio.pulseaudio" peer_pid=1583 peer_label="snap.bluez.bluez"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" name=":1.8" mask="receive" pid=1583 label="snap.bluez.bluez" peer_pid=1579 peer_label="snap.pulseaudio.pulseaudio"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" member="RequestName" mask="send" name="org.freedesktop.DBus" pid=1579 label="snap.pulseaudio.pulseaudio" peer_label="unconfined"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/org/bluez/hci0" interface="org.bluez.Media1" member="RegisterEndpoint" mask="send" name="org.bluez" pid=1579 label="snap.pulseaudio.pulseaudio" peer_pid=1583 peer_label="snap.bluez.bluez"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/org/bluez/hci0" interface="org.bluez.Media1" member="RegisterEndpoint" name=":1.8" mask="receive" pid=1583 label="snap.bluez.bluez" peer_pid=1579 peer_label="snap.pulseaudio.pulseaudio"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/org/bluez" interface="org.bluez.ProfileManager1" member="RegisterProfile" mask="send" name="org.bluez" pid=1579 label="snap.pulseaudio.pulseaudio" peer_pid=1583 peer_label="snap.bluez.bluez"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/org/bluez" interface="org.bluez.ProfileManager1" member="RegisterProfile" name=":1.8" mask="receive" pid=1583 label="snap.bluez.bluez" peer_pid=1579 peer_label="snap.pulseaudio.pulseaudio"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_signal" bus="system" path="/org/bluez/hci0" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" mask="send" name="org.freedesktop.DBus" pid=1583 label="snap.bluez.bluez" peer_pid=1579 peer_label="snap.pulseaudio.pulseaudio"
Jan 04 20:36:42 localhost.localdomain audit[1173]: USER_AVC pid=1173 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_signal" bus="system" path="/org/bluez/hci0" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.7" mask="receive" pid=1579 label="snap.pulseaudio.pulseaudio" peer_pid=1583 peer_label="snap.bluez.bluez"
Then there are a number of messages related to communication with the Bluetooth device.
Jan 04 19:50:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/MediaEndpoint/A2DPSource" interface="org.bluez.MediaEndpoint1" member="SelectConfiguration" mask="send" name=":1.11" pid=1772 label="snap.bluez.bluez" peer_pid=1758 peer_label="snap.pulseaudio.pulseaudio"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:50:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/MediaEndpoint/A2DPSource" interface="org.bluez.MediaEndpoint1" member="SelectConfiguration" name=":1.10" mask="receive" pid=1758 label="snap.pulseaudio.pulseaudio" peer_pid=1772 peer_label="snap.bluez.bluez"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:50:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_signal" bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="InterfacesAdded" mask="send" name="org.freedesktop.DBus" pid=1772 label="snap.bluez.bluez" peer_pid=1758 peer_label="snap.pulseaudio.pulseaudio"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:50:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_signal" bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="InterfacesAdded" name=":1.10" mask="receive" pid=1758 label="snap.pulseaudio.pulseaudio" peer_pid=1772 peer_label="snap.bluez.bluez"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:50:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/MediaEndpoint/A2DPSource" interface="org.bluez.MediaEndpoint1" member="SetConfiguration" mask="send" name=":1.11" pid=1772 label="snap.bluez.bluez" peer_pid=1758 peer_label="snap.pulseaudio.pulseaudio"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:50:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call" bus="system" path="/MediaEndpoint/A2DPSource" interface="org.bluez.MediaEndpoint1" member="SetConfiguration" name=":1.10" mask="receive" pid=1758 label="snap.pulseaudio.pulseaudio" peer_pid=1772 peer_label="snap.bluez.bluez"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:52:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_signal" bus="system" path="/org/bluez/hci0/dev_FC_58_FA_CF_57_09" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" mask="send" name="org.freedesktop.DBus" pid=1772 label="snap.bluez.bluez" peer_pid=1758 peer_label="snap.pulseaudio.pulseaudio"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:52:35 localhost.localdomain audit[1217]: USER_AVC pid=1217 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_signal" bus="system" path="/org/bluez/hci0/dev_FC_58_FA_CF_57_09" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.10" mask="receive" pid=1758 label="snap.pulseaudio.pulseaudio" peer_pid=1772 peer_label="snap.bluez.bluez"
exe="/usr/bin/dbus-daemon" sauid=100 hostname=? addr=? terminal=?'
Jan 04 19:54:40 localhost.localdomain audit[2586]: AVC apparmor="ALLOWED" operation="recvmsg" profile="snap.pulseaudio.pulseaudio" pid=2586 comm="bluetooth" family="bluetooth" sock_type="seqpacket" protocol=2 requested_mask="receive" denied_mask="receive"
Jan 04 19:54:40 localhost.localdomain audit[2586]: AVC apparmor="ALLOWED" operation="sendmsg" profile="snap.pulseaudio.pulseaudio" pid=2586 comm="bluetooth" family="bluetooth" sock_type="seqpacket" protocol=2 requested_mask="send" denied_mask="send"
Finally, I did need to edit “/etc/dbus-1/system.d/snap.bluez.bluez.conf” in order to get things working. I added the following two lines inside the first policy block.
<allow send_interface="org.bluez.MediaEndpoint1"/>
<allow send_interface="org.bluez.MediaPlayer1"/>
I noticed that these two lines are present on my Ubuntu Desktop workstation but not in Ubuntu Core and that the contents of this file are automatically generated on system boot. Are those dbus rules specified in the core snap or in the bluez snap?