Move the cache to /var/cache

Let's not store a bunch of automatically generated binary files in /etc.
AppArmor 3.0 will store the cache in /var/cache and most distros
(openSUSE, Debian, and soon Ubuntu) moved it there already.

Bug-Debian: https://bugs.debian.org/904637
(cherry picked from commit 3d21cf0e32)
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
intrigeri 2018-07-26 08:20:13 +00:00 committed by John Johansen
parent 6f5c61e6af
commit affc7a9fb4
3 changed files with 8 additions and 7 deletions

View file

@ -247,7 +247,7 @@ If a cache directory name needs to have a comma as part of the name, it
can be specified by using a backslash to escape the comma character in
the directory name.
If not specified the cache location defaults to /etc/apparmor.d/cache.d
If not specified the cache location defaults to /var/cache/apparmor
=item --print-cache-dir

View file

@ -1272,12 +1272,7 @@ int main(int argc, char *argv[])
uint16_t max_caches = write_cache && cond_clear_cache ? (uint16_t) (-1) : 0;
if (!cacheloc[0]) {
char *tmp;
if (asprintf(&tmp, "%s/cache.d", basedir) == -1) {
PERROR(_("Memory allocation error."));
return 1;
}
char *tmp = "/var/cache/apparmor";
cacheloc[0] = tmp;
cacheloc_n = 1;
}

View file

@ -75,6 +75,12 @@ class AAParserCachingCommon(testlib.AATestTemplate):
if not self.is_apparmorfs_mounted():
self.cmd_prefix += ['-M', './features_files/features.all']
# Otherwise get_cache_dir() will try to create /var/cache/apparmor
# and will fail when the test suite is run as non-root.
self.cmd_prefix += [
'--cache-loc', os.path.join(self.tmp_dir, 'cache')
]
# create directory for cached blobs
# NOTE: get_cache_dir() requires cmd_prefix to be fully initialized
self.cache_dir = self.get_cache_dir(create=True)