How can snap applications view the manual permissions they have been granted?

Is there a method for a Snap app to introspect its own permissions?

I’ve built an app that requires the raw-usb permission to flash firmware on microcontrollers. Without it, the app does not work and I would like to inform the user with a pop-up that they have to add the permissions. Is there a way that allows the app to explicitly check which permissions have been granted? I have not found any information in the meta folder of the snap app.

For the password-manager-service permission I currently check it via an error thrown by the password library.

You can use snapctl is-connected raw-usb (works for every interface and returns non-zero if the interface is not connected… note that snapctl is only available inside the snap environment)… you can use that inside a command-chain script to check and show a pop-up on startup…

There is no way to see if an interface was manually connected or any equivalent of snap connections... from inside a snap though… might be an interesting feature to have in snapd.

1 Like

Works great. There is just a typo in you command: snapctl is-connected raw-usb

As reference, to quickly test it use: snap run --shell <snap-name> to open a shell and access the env variables and snapctl from the view of the app.

1 Like