~jamesodhunt/ubuntu/vivid/upstart/bug-1447756

« back to all changes in this revision

Viewing changes to debian/apparmor-profile-load

  • Committer: Didier Roche
  • Date: 2015-04-03 12:11:32 UTC
  • Revision ID: didrocks@ubuntu.com-20150403121132-5rxn7pq63ob0zt4g
Tags: 1.13.2-0ubuntu11
releasing package upstart version 1.13.2-0ubuntu11

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# apparmor-profile-load
3
 
#
4
 
# Helper for loading an AppArmor profile in pre-start scripts.
5
 
 
6
 
[ -z "$1" ]                  && exit 1 # require a profile name
7
 
 
8
 
# do not load in a container
9
 
[ -x /bin/running-in-container ] && /bin/running-in-container >/dev/null 2>&1 && exit 0
10
 
 
11
 
[ -d /rofs/etc/apparmor.d ]  && exit 0 # do not load if running liveCD
12
 
 
13
 
profile=/etc/apparmor.d/"$1"
14
 
[ -e "$profile" ]            || exit 0 # skip when missing profile
15
 
 
16
 
module=/sys/module/apparmor
17
 
[ -d $module ]               || exit 0 # do not load without AppArmor in kernel
18
 
 
19
 
[ -x /sbin/apparmor_parser ] || exit 0 # do not load without parser
20
 
 
21
 
aafs=/sys/kernel/security/apparmor
22
 
[ -d $aafs ]                 || exit 0 # do not load if unmounted
23
 
[ -w $aafs/.load ]           || exit 1 # fail if cannot load profiles
24
 
 
25
 
params=$module/parameters
26
 
[ -r $params/enabled ]       || exit 0 # do not load if missing
27
 
read enabled < $params/enabled || exit 1 # if this fails, something went wrong
28
 
[ "$enabled" = "Y" ]         || exit 0 # do not load if disabled
29
 
 
30
 
/sbin/apparmor_parser -r -W "$profile" || exit 0 # LP: #1058356