Comment 3 for bug 1804006

Revision history for this message
Ian Johnson (anonymouse67) wrote :

Yes the hooks themselves are installed into the right place in the snap, but the associated confinement, i.e. AppArmor profiles, don't include the policies listed in the root level plugs like the apps do. This is a problem if you need your configure hook to access the network, or home folder, etc. You can fix it by manually also declaring all the plugs in the hooks section in the snapcraft.yaml, but I'm saying that if you use the root level plugs (and hence all apps), you shouldn't have to also declare it for all the hooks you have in the snap.

Re the yaml snippet in snap.yaml, that's generated when you specify it in the root level snapcraft.yaml like so:

```yaml
name: test-snapcraft-root-plugs
version: '0.1'
summary: test of snapcraft.yaml root level plugs and hooks
description: test root level plugs in snapcraft.yaml
grade: devel
confinement: devmode

plugs:
  home: {}
  removable-media: {}
  network: {}
  network-bind: {}

apps:
  test-snapcraft-root-plugs:
    command: echo "hello"

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: nil

hooks:
  configure:
    plugs: [home]
```

which generates the following snap.yaml:

```yaml
name: test-snapcraft-root-plugs
version: '0.1'
summary: test of snapcraft.yaml root level plugs and hooks
description: test root level plugs in snapcraft.yaml
architectures:
- amd64
confinement: devmode
grade: devel
plugs:
  home: {}
  network: {}
  network-bind: {}
  removable-media: {}
hooks:
  configure:
    plugs:
    - home
apps:
  test-snapcraft-root-plugs:
    command: command-test-snapcraft-root-plugs.wrapper

```