Hey everyone,
I am relatively new to snapcraft and I am trying to build the locationd example application provided here:
https://docs.ubuntu.com/core/en/stacks/location/location-service/docs/obtain-location
I first tried a simple snapcraft.yml with no plugs defined and had the following error:
ERROR:dbus.proxies:Introspect error on :1.132:/com/ubuntu/location/Service: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.168" (uid=1000 pid=2861 comm="/snap/gpssensorlog/x10/usr/bin/python3 /snap/gpsse") interface="org.freedesktop.DBus.Introspectable" member="Introspect" error name="(unset)" requested_reply="0" destination=":1.132" (uid=0 pid=26004 comm="/snap/locationd/163/bin/locationd run --bus=system")
Traceback (most recent call last):
File "/snap/gpssensorlog/x10/bin/publish_gps.py", line 22, in <module>
session_path = service.CreateSessionForCriteria(requirements)
File "/snap/gpssensorlog/x10/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__
return self._proxy_method(*args, **keywords)
File "/snap/gpssensorlog/x10/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
**keywords)
File "/snap/gpssensorlog/x10/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.168" (uid=1000 pid=2861 comm="/snap/gpssensorlog/x10/usr/bin/python3 /snap/gpsse") interface="com.ubuntu.location.Service" member="CreateSessionForCriteria" error name="(unset)" requested_reply="0" destination=":1.132" (uid=0 pid=26004 comm="/snap/locationd/163/bin/locationd run --bus=system")
I then added the following plugs:
plugs:
location-observe:
interface: location-observe
location-control:
interface: location-control
So my snapcraft.yml now looks like this:
name: gpssensorlog # you probably want to 'snapcraft register <name>'
version: '1.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Logs the gps sensor values to a file
description: |
This program captures the gps data and logs it to a file that can be shipped to the backend.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
apps:
publish:
command: bin/publish_gps.py
plugs: ["location-observe", "location-control"]
plugs:
location-observe: # name that is used with 'snap connect' on plugs side
interface: location-observe
location-control: # name that is used with 'snap connect' on plugs side
interface: location-control
parts:
files:
plugin: python
python-version: python3
source: .
stage-packages:
- python3-dbus
I then connected the 2 interfaces:
snap connect gpssensorlog:location-observe locationd:service-observe snap connect gpssensorlog:location-control locationd:service-control
Resulting in one less error and one other error:
ERROR:dbus.proxies:Introspect error on :1.132:/com/ubuntu/location/Service: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.175" (uid=1000 pid=3447 comm="/snap/gpssensorlog/x11/usr/bin/python3 /snap/gpsse") interface="org.freedesktop.DBus.Introspectable" member="Introspect" error name="(unset)" requested_reply="0" destination=":1.132" (uid=0 pid=26004 comm="/snap/locationd/163/bin/locationd run --bus=system")
Traceback (most recent call last):
File "/snap/gpssensorlog/x11/bin/publish_gps.py", line 22, in <module>
session_path = service.CreateSessionForCriteria(requirements)
File "/snap/gpssensorlog/x11/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__
return self._proxy_method(*args, **keywords)
File "/snap/gpssensorlog/x11/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
**keywords)
File "/snap/gpssensorlog/x11/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: Type of message, '(a{sb})', does not match expected type '(a{sv})'
I have no clue how to proceed with this maybe someone can help me out?
Kind Regards,
Stijn De Haes