Merge lp:~cwayne/ubuntu-touch-customization-hooks/more-apparmor-copy into lp:ubuntu-touch-customization-hooks

Proposed by Chris Wayne
Status: Merged
Approved by: Scott Sweeny
Approved revision: 38
Merged at revision: 36
Proposed branch: lp:~cwayne/ubuntu-touch-customization-hooks/more-apparmor-copy
Merge into: lp:ubuntu-touch-customization-hooks
Diff against target: 24 lines (+12/-2)
1 file modified
etc/init/custom-apparmor-cache.conf (+12/-2)
To merge this branch: bzr merge lp:~cwayne/ubuntu-touch-customization-hooks/more-apparmor-copy
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Jamie Strandboge (community) Approve
Scott Sweeny (community) Approve
Review via email: mp+235519@code.launchpad.net

Commit message

Copy /custom/lib/apparmor/profiles /custom/lib/apparmor/clicks over as well, so that cache isnt re-compiled at first boot

Description of the change

Copy /custom/lib/apparmor/profiles /custom/lib/apparmor/clicks over as well, so that cache isnt re-compiled at first boot

To post a comment you must log in.
Revision history for this message
Chris Wayne (cwayne) wrote :

Tested by removing all relevant files from /var/lib/apparmor/[profiles,clicks], /var/cache/apparmor/, and removing /custom then installing the new upstart job and applying the new custom tarball that contains /custom/lib/apparmor/[profiles,clicks] and the bootup time was much quicker.

Revision history for this message
Chris Wayne (cwayne) wrote :

Also applied an older tarball with this branch (that does not contain the profiles/clicks) and verified that the cache's were recompiled, taking a lot longer to boot.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Sweeny (ssweeny) wrote :

LGTM

review: Approve
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Chris and I talked about this a bit. Policy can be recompiled when:
* the symlink in /var/lib/apparmor/clicks is newer than the profile in /var/lib/apparmor/profiles
* the profile in /var/lib/apparmor/profiles is newer than the cache file in /var/cache/apparmor

The click system hook upstart job adds the symlinks to /var/lib/apparmor/clicks and the click apparmor system hook then creates policy in /var/lib/apparmor/profiles based on this symlink. What was happening with previous attempts of the upstart job is that /var/lib/apparmor/clicks and /var/lib/apparmor/profiles were empty. This meant that even though this job copied the cache files into place correctly and at the right time, the click system hook machinery created newer symlinks and profiles than the cache, so the cache files were ignored. Previous job testing involved removing only the cache files in /var/cache/apparmor and rebooting, which left the already creating symlinks and profiles in place which is why it worked correctly on reboot.

I agree with the approach set out by this merge request. The script should probably also check for the existence of /var/lib/apparmor/clicks and /var/lib/apparmor/profiles. Also, '|| true' is not included in the other cp statements. Maybe something more like this (please include the comment):

# Ordering is important. mtimes for the following must be:
# click symlink < apparmor profile < apparmor cache
if [ -d /custom/lib/apparmor/clicks ] && [ -d /var/lib/apparmor/clicks ] ; then
    cp -Pnu /custom/lib/apparmor/clicks/* /var/lib/apparmor/clicks || true
fi
if [ -d /custom/lib/apparmor/profiles ] && [ -d /var/lib/apparmor/profiles ] ; then
    cp -nu /custom/lib/apparmor/profiles/* /var/lib/apparmor/profiles || true
fi
if [ -d /custom/cache/apparmor ] && [ -d /var/cache/apparmor ] ; then
    cp -nu /custom/cache/apparmor/* /var/cache/apparmor/ || true
fi

review: Needs Fixing
38. By Chris Wayne

Implement feedback from jdstrand

Revision history for this message
Scott Sweeny (ssweeny) wrote :

Still LGTM :)

review: Approve
Revision history for this message
Chris Wayne (cwayne) wrote :

Tested the update again by removing all traces of the clicks and /custom, then installing this package and then applying the tarball. The splash screen is only shown for 13 seconds in this case, and diff /custom/cache/apparmor/<some-click> /var/cache/apparmor/<same-click> shows no diff, so it's been correctly copied over

Revision history for this message
Jamie Strandboge (jdstrand) :
review: Needs Fixing
39. By Chris Wayne

Whitespace fixes

Revision history for this message
Jamie Strandboge (jdstrand) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'etc/init/custom-apparmor-cache.conf'
2--- etc/init/custom-apparmor-cache.conf 2014-09-18 16:38:57 +0000
3+++ etc/init/custom-apparmor-cache.conf 2014-09-22 20:09:22 +0000
4@@ -5,8 +5,18 @@
5 task
6
7 script
8- [ -d /custom/cache/apparmor ] && [ -d /var/cache/apparmor ] || exit 0
9- cp -nu /custom/cache/apparmor/* /var/cache/apparmor/ || true
10+ [ -d /custom/cache/apparmor ] && [ -d /custom/lib/apparmor/ ] || exit 0
11+ # Ordering is important. mtimes for the following must be:
12+ # click symlink < apparmor profile < apparmor cache
13+ if [ -d /custom/lib/apparmor/clicks ] && [ -d /var/lib/apparmor/clicks ] ; then
14+ cp -Pnu /custom/lib/apparmor/clicks/* /var/lib/apparmor/clicks || true
15+ fi
16+ if [ -d /custom/lib/apparmor/profiles ] && [ -d /var/lib/apparmor/profiles ] ; then
17+ cp -nu /custom/lib/apparmor/profiles/* /var/lib/apparmor/profiles || true
18+ fi
19+ if [ -d /custom/cache/apparmor ] && [ -d /var/cache/apparmor ] ; then
20+ cp -nu /custom/cache/apparmor/* /var/cache/apparmor/ || true
21+ fi
22 end script
23
24 # vim:syntax=upstart

Subscribers

People subscribed via source and target branches