Skip to content

Commit

Permalink
snapcraft/hooks: Exec interface hooks outside of apparmor confinement
Browse files Browse the repository at this point in the history
Another error that couldn't be picked up by a local install with
snap install --dangerous

The hooks fail with the error:
- Run hook connect-plug-ceph-conf of snap "lxd" (run hook
  "connect-plug-ceph-conf": ln: failed to create symbolic link
'/etc/ceph': Permission denied)

So this commit adds a line that execs them outside the apparmor
confinement to get around the error, similar to the `configure` hook.

Signed-off-by: Max Asnaashari <[email protected]>
  • Loading branch information
masnax committed Sep 22, 2023
1 parent 7e8a259 commit 8bf6e04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions snapcraft/hooks/connect-plug-ceph-conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/sh
set -eu

# Re-exec outside of apparmor confinement
if [ -d /sys/kernel/security/apparmor ] && [ "$(cat /proc/self/attr/current)" != "unconfined" ]; then
exec aa-exec -p unconfined -- "$0" "$@"
fi

# Utility functions
get_bool() {
Expand Down
6 changes: 6 additions & 0 deletions snapcraft/hooks/disconnect-plug-ceph-conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/sh
set -eu

# Re-exec outside of apparmor confinement
if [ -d /sys/kernel/security/apparmor ] && [ "$(cat /proc/self/attr/current)" != "unconfined" ]; then
exec aa-exec -p unconfined -- "$0" "$@"
fi

# Utility functions
get_bool() {
Expand Down

0 comments on commit 8bf6e04

Please sign in to comment.