From Perl Stork, 3 Years ago, written in Plain Text.
Embed
  1. #!/bin/bash
  2. # Adapted from Void's AppArmor script
  3.  
  4. . /usr/lib/rc/functions
  5. . /etc/rc/apparmor.conf
  6.  
  7. case "$1" in
  8.     start)
  9.         stat_busy "Loading AppArmor profiles"
  10.         if [ ! -d /sys/kernel/security/apparmor ]; then
  11.             printhl "AppArmor module disabled - aborting"
  12.             stat_die apparmor
  13.         fi
  14.  
  15.  
  16.         if [[ "$APPARMOR" ]]; then
  17.             if [[ "$APPARMOR" != "complain" && "$APPARMOR" != "enforce" ]]; then
  18.                 printhl "Unknown AppArmor mode - ignoring profiles"
  19.                 stat_done apparmor
  20.             fi
  21.  
  22.             [ "$APPARMOR" = "complain" ] && AACOMPLAIN="-C"
  23.  
  24.             if [[ -d /etc/apparmor.d && -x /usr/bin/apparmor_parser ]]; then
  25.                 for profile in /etc/apparmor.d/*; do
  26.                     if [[ -f "$profile" ]]; then
  27.                         printf '* Load profile %s: %s\n' "$(APPARMOR)" "$profile"
  28.                         apparmor_parser -a "$AACOMPLAIN" "$profile"
  29.                     fi
  30.                 done
  31.             else
  32.                 printhl "AppArmor is not installed, aborting"
  33.                 stat_die apparmor
  34.             fi
  35.         fi
  36.  
  37.         rc=$?
  38.         (( rc || $? )) && stat_die
  39.         add_daemon apparmor
  40.         stat_done
  41.         ;;
  42.     *)
  43.         echo "usage: $0 {start}"
  44.         exit 1
  45.         ;;
  46. esac
  47.  
captcha