Plugs and hooks

Hi all,

I am trying to add the home plug to my configure hook but snappy-debug persistently recommends that I add ‘home’ to plugs.

= AppArmor =
Time: Feb 23 07:27:27
Log: apparmor=“ALLOWED” operation=“open” profile=“snap.raven-client.hook.configure” name="/home/user/myconfig.yaml" pid=14869 comm=“python3” requested_mask=“r” denied_mask=“r” fsuid=0 ouid=1000
File: /home/user/myconfig.yaml (read)
Suggestion:

  • add ‘home’ to ‘plugs’

snapcraft.yaml:

name: raven-client
base: core18
version: ‘0.1’
summary: empty summary
description: |
client

grade: devel
confinement: devmode

parts:
internal-python:
plugin: python
python-version: python3
source: .
python-packages:
- protobuf
- pycryptodome
- python-gnupg
- pyyaml

hook-setup:
plugin: dump
source: hooks
organize:
configure: snap/hooks/configure
post-refresh: snap/hooks/post-refresh
install: snap/hooks/install

hooks:
configure:
plugs:
- home

apps:
run:
command: “$SNAP/run.sh”
plugs:
- network
- network-bind
- home

The syntax used in my snapcraft.yaml file seems to be in line with what is discussed in
Plugs in global position in snapcraft.yaml but I can’t seem to find any other documentation specifically regarding the use of plugs with hooks.

Any help is much appreciated!

Hooks run as root (uid 0) so the home plug will allow access to /root only. If you need to write to anybody’s home folder other than root you need to request and add support for home with read: all set:

plugs:
  home-all:
    interface: home
    read: all

hooks:
  configure:
    plugs:
    - home-all

Thanks for the help. I am a bit unclear how this home-all plug works with manual connection. Clearly, raven-client:home-all is the plug, but what would the slot be in this situation?

your slot is defined here:

Oh duh :slight_smile: , thanks the help