~ubuntu-branches/ubuntu/wily/apparmor/wily

« back to all changes in this revision

Viewing changes to debian/apparmor.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# see: dh_installdeb(1)
5
5
set -e
6
6
 
 
7
. /usr/share/debconf/confmodule
 
8
 
7
9
# summary of how this script can be called:
8
10
#        * <postinst> `configure' <most-recently-configured-version>
9
11
#        * <old-postinst> `abort-upgrade' <new version>
16
18
# for details, see http://www.debian.org/doc/debian-policy/ or
17
19
# the debian-policy package
18
20
 
19
 
# On kernel upgrade, the apparmor init script loses its mind because the
20
 
# apparmor modules haven't been loaded.  Ignore this, so that package
21
 
# upgrades or uninstalls don't fail.
22
 
ignore_apparmor_init_failure()
23
 
{
24
 
    echo ""
25
 
    echo "  The apparmor init script failed.  Perhaps the apparmor modules"
26
 
    echo "  need to be installed?  Try the following:"
27
 
    echo "    apt-get install apparmor-modules-source"
28
 
    echo "    m-a -v -t prepare"
29
 
    echo "    m-a -v -t -f build apparmor-modules"
30
 
    echo "    m-a -v -t -f install apparmor-modules"
31
 
    echo ""
32
 
    true
33
 
}
 
21
case "$1" in
 
22
    configure|abort-remove|abort-deconfigure)
 
23
 
 
24
        # Try to determine values for apparmor/homedirs if the administrator
 
25
        # hasn't already.
 
26
        if dpkg --compare-versions "$2" lt-nl "2.5~pre+bzr1362-0ubuntu2"; then
 
27
            db_get apparmor/homedirs
 
28
            if [ -z "$RET" ]; then
 
29
                # Get unique dirnames for uids between 1000 and 30000, then
 
30
                # format them appropriately for AppArmor
 
31
                dirs=`awk -F: '$3 >= 1000 && $3 < 30000 {printf "%s\n", $6}' /etc/passwd | xargs -d '\n' -n 1 dirname | grep -v '^/home$' | sed -e 's#\(.*\)#\\1/#g' | sed -e '/ / { s#\(.*\)#"\\1"#g }' | sort -u | tr '\n' ' '`
 
32
                if [ -n "$dirs" ]; then
 
33
                    db_set apparmor/homedirs "$dirs"
 
34
                fi
 
35
            fi
 
36
        fi
 
37
 
 
38
        db_get apparmor/homedirs
 
39
        tmp=`mktemp`
 
40
        cat > "$tmp" <<EOM
 
41
# This file is auto-generated. It is recommended you update it using:
 
42
# $ sudo dpkg-reconfigure apparmor
 
43
#
 
44
# The following is a space-separated list of where additional user home
 
45
# directories are stored, each must have a trailing '/'. Directories added
 
46
# here are appended to @{HOMEDIRS}.  See tunables/home for details.
 
47
EOM
 
48
        if [ -n "$RET" ]; then
 
49
            cat >> "$tmp" <<EOM
 
50
@{HOMEDIRS}+=$RET
 
51
EOM
 
52
        else
 
53
            cat >> "$tmp" <<EOM
 
54
#@{HOMEDIRS}+=
 
55
EOM
 
56
        fi
 
57
        mkdir -p /etc/apparmor.d/tunables/home.d 2>/dev/null || true
 
58
        mv -f "$tmp" /etc/apparmor.d/tunables/home.d/ubuntu
 
59
        chmod 644 /etc/apparmor.d/tunables/home.d/ubuntu
 
60
        ;;
 
61
 
 
62
    abort-upgrade)
 
63
        # Nothing to do
 
64
        ;;
 
65
 
 
66
    *)
 
67
        echo "postinst called with unknown argument \`$1'" >&2
 
68
        exit 1
 
69
    ;;
 
70
esac
 
71
 
 
72
# drop old scripts that were incorrectly installed as conffiles
 
73
if dpkg-maintscript-helper supports rm_conffile; then
 
74
    dpkg-maintscript-helper rm_conffile /etc/apparmor/functions 2.5.1-0ubuntu4 -- "$@"
 
75
    dpkg-maintscript-helper rm_conffile /etc/apparmor/rc.apparmor.functions 2.5.1-0ubuntu4 -- "$@"
 
76
fi
34
77
 
35
78
# dh_installdeb will replace this with shell code automatically
36
79
# generated by other debhelper scripts.
37
80
 
38
81
#DEBHELPER#
39
82
 
 
83
# Now that AppArmor is started, attempt to reload profiles in the
 
84
# case of upgrades (since dh_installinit has been forced not to unload
 
85
# the profiles in the case of an upgrade).
 
86
case "$1" in
 
87
    configure)
 
88
        if [ -x "/etc/init.d/apparmor" ]; then
 
89
            if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
 
90
                invoke-rc.d apparmor reload || true
 
91
            else
 
92
                /etc/init.d/apparmor reload || true
 
93
            fi
 
94
        fi
 
95
        ;;
 
96
esac
 
97
 
40
98
exit 0