Our organisation has a customised core20 image deployed across two different models of NUC. I want to amend our config snap to identify the device name by querying /sys/devices/virtual/dmi/id/product_name, so I’ve included the following couple of lines in the snap’s configure hook:
deviceModel=$(cat /sys/devices/virtual/dmi/id/product_name)
snapctl set device.model="$deviceModel"
which works as expected running in devmode, but not when confined.
I then followed @ogra’s advice from here (Interface for sys dmi info) which suggests that either fwupd or browser_support are the interfaces to provide access to this location; however I can’t get either to work. As an example I’m specifying the plugs to use like so:
plugs:
...
fwupd:
When I install the snap, as expected it doesn’t automatically connect the fwupd plug:
but when I try to manually connect it I get this response:
$ snap connect my-config:fwupd
error: snap "snapd" has no "fwupd" interface slots
By contrast using browser_support doesn’t error out and appears to connect the interface correctly using the above approach - but it doesn’t seem to give the access I need to /sys/devices/virtual/dmi/id/product_name. Can anyone shed any light on what I’m doing wrong?
well, using either fwupd (while not using fwupd) or browser-support (while not being a browser) are rather hacks/workarounds … the proper solution would really be to add the two lines from:
into the hardware-observe interface and have your app actually use this interface … (i have moved your post to the snapd category, so the snapd team sees this (and hopefully adds these two lines for us)
regarding the “why does it not work ?” … did you explicitly add the plugs to the configure hook in your snapcraft.yaml ?
Thanks for the response - your suggestion that those lines are added to hardware-observe sounds sensible to me!
I didn’t previously add either plug explicitly to the configure hook (just at the top level in my snapcraft.yml, as I’ve done previously with a couple of other plugs that I’m using in the configure hook). Anyhow, I’ve just tried your suggestion using browser-support, but unfortunately it still doesn’t work - it just sets my snap’s device.model value to “”.
actually returns something if you run it just from the shell ?
(it looks like the interface connection is fine with browser-support connected if you don’t get an error or any apparmor denials in the journal output)
To be clear, the fwupd interface is not implicit, so it is not provided by the snapd / core snaps, and you would need to connect the fwupd plug you have in your snap to some other snap which is providing the fwupd slot.
The browser-support interface is implicit however, so the plug can always be connected to the snapd / core snap slots. However to get the sys/devices/virtual/dmi/id/product_name access through the browser-support interface, you need to use the allow-sandbox: true attribute with the plug declaration in your snap as in :