summary: Check that mount profiles cannot be used to mount tmpfs
# This is blacklisted on debian because we first have to get the dpkg-vendor patches
systems: [-debian-8]
restore: |
    snap remove --purge snapd-hacker-toolbelt
    rm -rf /var/snap/snapd-hacker-toolbelt
    rm -f /var/lib/snapd/mount/snap.snapd-hacker-toolbelt.busybox.fstab
execute: |
    echo "Having installed the snapd-hacker-toolbelt snap"
    snap list | grep -q snapd-hacker-toolbelt || snap install snapd-hacker-toolbelt

    echo "We can change its mount profile externally to mount tmpfs at /var/snap/snapd-hacker-toolbelt/mnt"
    mkdir -p /var/lib/snapd/mount
    echo "none /var/snap/snapd-hacker-toolbelt/common/mnt tmpfs rw 0 0" > /var/lib/snapd/mount/snap.snapd-hacker-toolbelt.busybox.fstab
    
    echo "We can now create the test mount directory"
    mkdir -p /var/snap/snapd-hacker-toolbelt/common/mnt
    
    echo "We can now run busybox.true and expect it to fail"
    ( cd / && ! /snap/bin/snapd-hacker-toolbelt.busybox true )
