lxc-test-apparmor-mount revision 3a5495cf2f6c1806f5a91d699448b15b510f146e
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# apparmor_mount: test proper handling of apparmor in kernels
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# without mount features
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# These require the ubuntu lxc package to be installed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This program is free software; you can redistribute it and/or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# modify it under the terms of the GNU Lesser General Public
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# License as published by the Free Software Foundation; either
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# version 2.1 of the License, or (at your option) any later version.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This library is distributed in the hope that it will be useful,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# but WITHOUT ANY WARRANTY; without even the implied warranty of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Lesser General Public License for more details.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# You should have received a copy of the GNU Lesser General Public
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# License along with this library; if not, write to the Free Software
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This test assumes an Ubuntu host
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default_profile="lxc-container-default-cgns (enforce)"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default_profile="lxc-container-default (enforce)"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte env http_proxy=${http_proxy:-} https_proxy=${https_proxy:-} \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteKNOWN_RELEASES="precise trusty xenial yakkety zesty"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMOUNTSR=/sys/kernel/security/apparmor/features/mount
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sed -i '/lxcunpriv/d' /run/lxc/nics /etc/lxc/lxc-usernet
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if [ $DONE -eq 0 ]; then
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# Only run on a normally configured ubuntu lxc system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "lxcbr0 is not configured."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte echo "ERROR: Must run as root."
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# This would be much simpler if we could run it as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# root. However, in order to not have the bind mount
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# of an empty directory over the securitfs 'mount' directory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# be removed, we need to do this as non-root.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewhich newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2; exit 1; }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte# create a test user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteecho "$TUSER veth lxcbr0 2" >> /etc/lxc/lxc-usernet
cd $HDIR
echo "FAIL: confined container was in profile $profile"
echo "FAIL: unconfined container was in profile $profile"
echo "masking $MOUNTSR"
echo "pid was $pid"
echo "FAIL: confined container was in profile $profile"
echo "FAIL: confined container was in profile $profile"