github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/cmd/snap-confine/spread-tests/main/mount-profiles-rw-mount/task.yaml (about)

     1  summary: Check that read-write bind mounts can be created
     2  # This is blacklisted on debian because we first have to get the dpkg-vendor patches
     3  systems: [-debian-8]
     4  prepare: |
     5      echo "Having installed the snapd-hacker-toolbelt snap"
     6      snap install snapd-hacker-toolbelt
     7      echo "We can connect it to the mount-observe slot from the core"
     8      snap connect snapd-hacker-toolbelt:mount-observe ubuntu-core:mount-observe
     9      echo "We can change its mount profile externally to create a read-only bind-mount"
    10      echo "/snap/snapd-hacker-toolbelt/current/src -> /snap/snapd-hacker-toolbelt/current/dst"
    11      mkdir -p /var/lib/snapd/mount
    12      echo "/snap/snapd-hacker-toolbelt/current/src /snap/snapd-hacker-toolbelt/current/dst none bind,rw 0 0" > /var/lib/snapd/mount/snap.snapd-hacker-toolbelt.busybox.fstab
    13  execute: |
    14      cd /
    15      echo "We can now look at the .id file in the destination directory"
    16      [ "$(/snap/bin/snapd-hacker-toolbelt.busybox cat /snap/snapd-hacker-toolbelt/current/dst/.id)" = "source" ]
    17      echo "As well as the current mount points"
    18      # FIXME: this doesn't show 'rw', bind mounts confuse most tools and it
    19      # seems that busybox is not any different here.
    20      /snap/bin/snapd-hacker-toolbelt.busybox mount | grep snapd-hacker-toolbelt
    21  restore: |
    22      snap remove --purge snapd-hacker-toolbelt
    23      rm -rf /var/snap/snapd-hacker-toolbelt
    24      rm -f /var/lib/snapd/mount/snap.snapd-hacker-toolbelt.busybox.fstab