Supported interfaces

Thank you very much for explaining.

Might it be useful to add a note to explain this documentation only applies to Classic? I assumed from reading it that it applied to all operating systems equally.

This page should talk about the cups interface as the new interface to enable your snap to print. Iā€™m not sure if this is already supported on all distributions, though.

Thanks - and a great point. Iā€™ll look into it and make sure this page (and a corresponding CUPS interface page) is updated/created.

2 Likes

I think power-control interface is missing. cheers

Thanks for flagging this. Iā€™ve just done a quick audit and there are actually a few more missing too:

allegro-vcu
cups
dm-crypt
fpga
gconf
hugepages-control
ion-memory-control
kernel-crypto-api
media-control
microstack-support
power-control
ptp
qualcomm-ipc-router
snap-refresh-control
tee
vcio

Iā€™ll start adding these now.

Edit (15th Sept 2021): The above interface docs have now been added.

1 Like

It would be really helpful to explain the use case for snap-refresh-control in simple terms: it looks like it might be useful. thanks!

Is there a programmatic way to list all supported interfaces?

Thereā€™s GET /v2/connections in the Snapd REST API (basically the same as snap connections --all):

$ sudo curl -sS --unix-socket /run/snapd.socket http://localhost/v2/connections\?all \        ī‚² āœ” ī‚ŗ 11:30:02 ļ€— 
| jq
{
  "type": "sync",
  "status-code": 200,
  "status": "OK",
  "result": {
    "established": [
      {
        "slot": {
          "snap": "snapd",
          "slot": "audio-playback"
        },
        "plug": {
          "snap": "ardour",
          "plug": "audio-playback"
        },
        "interface": "audio-playback"
[...]

note that snap connections only shows connections in use while the deprecated snap interfaces shows all interfaces snapd knows ā€¦

filtering all duplicates and non-snapd (i.e. content) interfaces with snap interfaces:

$ snap interfaces 2>/dev/null | grep -v ^\- | cut -d' ' -f1 | sed 's/^://' | sort | uniq | grep -v : | wc -l 
137
$

doing the same for snap connections --all:

$ snap connections --all | cut -d' ' -f1 | sort | uniq | wc -l
77

we sadly never got a proper 1:1 replacement for snap interfaces when it got deprecated ā€¦

1 Like

Weird leading hyphen on line for ā€œkernel-module-loadā€

This list might not be complete, I can see in the source go files for polkit and scsi-generic interfaces which are not in this list, there might be others.

I might add, at the bottom, a URL to take readers to https://github.com/snapcore/snapd/tree/master/interfaces/builtin if they want to peruse the source code.

There is a bullet point paragraph describing the ā€œTransitional interfacesā€ column, but no such column exists, and there is no other mention of ā€œtransitionalā€ on the page. Should this bullet be removed now?

Thanks for mentioning this. There used to be a column for transitional interfaces, but this was removed some time ago. Iā€™ve removed the bullet, but also added transitional interfaces to our Glossary so that the information isnā€™t lost.

Hi @degville,

I have recently added two new interfaces. remoteproc and kernel-firmware-control interfaces. The PRs are available here. https://github.com/snapcore/snapd/pull/13533 https://github.com/snapcore/snapd/pull/13663

Both remoteproc and kernel-firmware-control are super-privileged interfaces. The remoteproc interface allows developers to interact with the remote-proc framework as described and defined here => https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-remoteproc

The kernel-firmware-control is currently only supports changing firmware search path as defined here => https://www.kernel.org/doc/html/v4.18/driver-api/firmware/fw_search_path.html

Let me know if you need more details on this.

1 Like

Hi @degville!

A new interface, nfs-mount, has been added to snapd 2.62 that allows users to mount NFS shares within writable areas of their Snap. You can find the associated PR here. The syntax is very straightforward, as you only need to add nfs-mount to your list of plugs, unlike other mounting interfaces which require additional rules. Additionally, the userspace binaries required to actually mount shares are not included in base snaps, so theyā€™ll have to be pulled in manually from the nfs-common package. Iā€™ve appended a barebones example below of a Snap that could be used to mount and unmount a share within $SNAP_COMMON.

Note: This interface only supports NFSv4, since other version of NFS require additional daemons to be present and running. This shouldnā€™t be an issue in practice, however, since NFSv3 and prior are extremely old at this point, and itā€™s unlikely that theyā€™re being used by the vast majority of people.

Snapcraft.yaml

name: nfs4-example
base: core22
version: '0.1'
summary: Example Snap showing off the new nfs-mount interface.
description: |
  This snap provides two commands: nfs-mount and nfs-unmount.
  Mount takes a single argument in the form of <hostname>:<nfs-share-name>.

grade: stable
confinement: strict

apps:
  nfs-mount:
    command: bin/nfs-mount.sh
    plugs: [nfs-mount]
  nfs-unmount:
    command: bin/nfs-unmount.sh
    plugs: [nfs-mount]

parts:
  scripts:
    plugin: dump
    source: ./src
    organize:
      '*': bin/
  packages:
    plugin: nil
    stage-packages: [nfs-common]

nfs-mount.sh

#!/bin/sh -eux

# If not argument is provided, print help and exit
[ -n "$1" ] || {
  printf '%s <hostname>:<nfs-share-path>\n' "$0"
  exit 1
}

# Ensure that the mount point has been created
[ -d "${SNAP_COMMON}/mnt" ] \
  || mkdir -p "${SNAP_COMMON}/mnt"

# Attempt to mount the share
mount.nfs4 "$1" "${SNAP_COMMON}/mnt"

nfs-unmount.sh

#!/bin/sh -eux

umount "${SNAP_COMMON}/mnt"
1 Like

Hello! Thanks so much for letting me know, and for this detailed description. Iā€™ll make sure this is added this week.

Update, 15th April 2024: Iā€™ve now added the documentation for this interface (The nfs-mount interface). Thanks again @jmbrock for such a detailed description, and in particular the example snapcraft.yaml. That really helps!

Shouldnā€™t the auto-connect note be against shared-memory, rather than serial-port?

Interface Description Categories Auto-connect
serial-port access serial port hardware System, Developer, Hardware no by default, yes with snaps from the same publisher
shared-memory enables two snaps to access the same shared memory Super privileged, IPC no

Hello! Thanks for flagging this, and youā€™re absolutely right yes. Now fixed.

Hello,

In https://snapcraft.io/docs/supported-interfaces media-hub is auto-connect: yes, but in https://snapcraft.io/docs/media-hub-interface detail page, it say auto-connect: no. Kind confused.