test apparmor profile parsing (see tdf#114915)
authorRene Engelhard <rene@debian.org>
Wed, 13 Jun 2018 19:37:12 +0000 (21:37 +0200)
committerRaspbian forward porter <root@raspbian.org>
Wed, 3 Oct 2018 02:27:03 +0000 (03:27 +0100)
idea taken from
https://salsa.debian.org/apparmor-team/apparmor-profiles-extra/commit/7fbcc4788d0e94764eeeff2f080796601241f986#546c1096cd506dbb01a47ed87a636a8e94d83b8c

Change-Id: I7e5bda9224d69530af4d30422c2fd3d60c9929d6

Gbp-Pq: Name test-apparmor-profiles.diff

sysui/desktop/share/apparmor.sh

index 253fe87cf78d0288e816a1313c4e0fcc05738726..c801f0f3b217b7fff1435dec1c9ace9a007ea642 100755 (executable)
@@ -19,16 +19,17 @@ INST_ROOT=$1  #Where libreoffice program folder can be found
 PROFILESFROM=$2  #Where the profile files are
 INSTALLTO=$3  #Where should the apparmor profiles (For manual use should be /etc/apparmor.d)
 RESTART=$4 #Should we restart apparmor using service?
+CHECK=$5 #Check parsing of the new profile?
 
 #Example uses:
 #Ubuntu 16.04 with stock LibreOffice:
-# sudo ./sysui/desktop/share/apparmor.sh /usr/lib/libreoffice/ sysui/desktop/apparmor/ /etc/apparmor.d/ true
+# sudo ./sysui/desktop/share/apparmor.sh /usr/lib/libreoffice/ sysui/desktop/apparmor/ /etc/apparmor.d/ true true
 
 #Ubuntu 16.04, with built debs from LibreOffice git
-# sudo ./sysui/desktop/share/apparmor.sh /opt/libreofficedev5.2/ sysui/desktop/apparmor/ /etc/apparmor.d/ true
+# sudo ./sysui/desktop/share/apparmor.sh /opt/libreofficedev5.2/ sysui/desktop/apparmor/ /etc/apparmor.d/ true true
 
 #Ubuntu 16.04, running from git!
-# sudo ./sysui/desktop/share/apparmor.sh /mnt/store/git/libo/instdir/ sysui/desktop/apparmor/ /etc/apparmor.d/ true
+# sudo ./sysui/desktop/share/apparmor.sh /mnt/store/git/libo/instdir/ sysui/desktop/apparmor/ /etc/apparmor.d/ true true
 
 #Need to convert / to . for profile names
 INST_ROOT_FORMAT=${INST_ROOT/\//}
@@ -43,7 +44,11 @@ do
     tourl=$INSTALLTO$INST_ROOT_FORMAT${filename##*/}
     sed "s/INSTDIR-/$INST_ROOT_SED/g" "$filename" > "$tourl"
     echo "$tourl"
-
+  if [ "$CHECK" = "true" ]; then
+    # check profile parsing
+    echo "Checking $tourl profile."
+    /sbin/apparmor_parser --add --skip-cache --skip-kernel-load $tourl
+  fi
 done
 
 if [ "$RESTART" = true ] ; then