# Author: Jamie Strandboge <jamie@canonical.com>
#include <tunables/global>
/usr/bin/ubuntu-core-launcher (attach_disconnected) {
# We run privileged, so be fanatical about what we include and don't use
# any abstractions
/etc/ld.so.cache r,
/lib/@{multiarch}/ld-*.so mr,
# libc, you are funny
/lib/@{multiarch}/libc{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libpthread{,-[0-9]*}.so* mr,
/lib/@{multiarch}/librt{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libgcc_s.so* mr,
# normal libs in order
/lib/@{multiarch}/libapparmor.so* mr,
/lib/@{multiarch}/libudev.so* mr,
/usr/lib/@{multiarch}/libseccomp.so* mr,
/lib/@{multiarch}/libseccomp.so* mr,
/usr/bin/ubuntu-core-launcher r,
/dev/null rw,
/dev/full rw,
/dev/zero rw,
# cgroups
capability sys_admin,
capability dac_override,
/sys/fs/cgroup/devices/snappy.*/ w,
/sys/fs/cgroup/devices/snappy.*/tasks w,
/sys/fs/cgroup/devices/snappy.*/devices.{allow,deny} w,
# querying udev
/etc/udev/udev.conf r,
/sys/devices/**/uevent r,
/lib/udev/snappy-app-dev ixr, # drop
/run/udev/** rw,
# priv dropping
capability setuid,
capability setgid,
# changing profile
@{PROC}/[0-9]*/attr/exec w,
change_profile -> [^u/]**,
change_profile -> [^u/][^n]**,
change_profile -> [^u/][^n][^c]**,
change_profile -> [^u/][^n][^c][^o]**,
change_profile -> [^u/][^n][^c][^o][^n]**,
change_profile -> [^u/][^n][^c][^o][^n][^f]**,
change_profile -> [^u/][^n][^c][^o][^n][^f][^i]**,
change_profile -> [^u/][^n][^c][^o][^n][^f][^i][^n]**,
change_profile -> [^u/][^n][^c][^o][^n][^f][^i][^n][^e]**,
change_profile -> [^u/][^n][^c][^o][^n][^f][^i][^n][^e][^d]**,
# LP: #1446794 - when this bug is fixed, change the above to:
# deny change_profile -> {unconfined,/**},
# change_profile -> **,
# reading seccomp filters
/var/lib/snappy/seccomp/profiles/* r,
# read apparmor to figure out if we need cgroups
/var/lib/apparmor/clicks/* r,
# set up snap-specific private /tmp dir
capability chown,
/tmp/ w,
/tmp/snap.*/ w,
/tmp/snap.*/tmp/ w,
mount options=(rw private) -> /tmp/,
mount options=(rw bind) /tmp/snap.*/tmp/ -> /tmp/,
# for running snaps on ubuntu
mount options=(rw rslave) -> /,
/snaps/ r,
/snaps/** r,
mount options=(rw bind) /snaps/ubuntu-core*/*/bin/ -> /bin/,
mount options=(rw bind) /snaps/ubuntu-core*/*/sbin/ -> /sbin/,
mount options=(rw bind) /snaps/ubuntu-core*/*/lib/ -> /lib/,
mount options=(rw bind) /snaps/ubuntu-core*/*/lib64/ -> /lib64/,
mount options=(rw bind) /snaps/ubuntu-core*/*/usr/ -> /usr/,
# for creating the user data directories: ~/snaps, ~/snaps/<name> and
# ~/snaps/<name>/<version>
/ r,
@{HOMEDIRS}/ r,
# These should both have 'owner' match but due to LP: #1466234, we can't
# yet
@{HOME}/ r,
@{HOME}/snaps/{,*/,*/*/} rw,
# for creating the user shared memory directories
/{dev,run}/{,shm/} r,
# This should both have 'owner' match but due to LP: #1466234, we can't yet
/{dev,run}/shm/{,*/,*/*/} rw,
}