From f1a566ec6b9fb803fc6a301a975cc3fbb7e7b272 Mon Sep 17 00:00:00 2001 From: John Johansen Date: Sun, 29 Sep 2013 01:52:39 -0700 Subject: [PATCH] The feature file is not being written to the proper location if the parameter --cache-loc= is specified. This results in using the .features file from /etc/apparmor.d/cache or always recompiling policy. The former case is particularly bad as the .features file in /etc/apparmor.d/cache/ may not correspond to the file in the specified cache location. bug: launchpad.net/bugs/1229393 Signed-off-by: John Johansen Acked-by: Tyler Hicks --- parser/parser_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/parser/parser_main.c b/parser/parser_main.c index 4b0887e45..5ed684503 100644 --- a/parser/parser_main.c +++ b/parser/parser_main.c @@ -1201,6 +1201,7 @@ static void setup_flags(void) { char *cache_features_path = NULL; char *cache_flags = NULL; + int rc; /* Get the match string to determine type of regex support needed */ get_match_string(); @@ -1227,7 +1228,11 @@ static void setup_flags(void) * - If cache/.features exists, and does not match flags_string, * force cache reading/writing off. */ - if (asprintf(&cache_features_path, "%s/cache/.features", basedir) == -1) { + if (cacheloc) + rc = asprintf(&cache_features_path, "%s/.features", cacheloc); + else + rc = asprintf(&cache_features_path, "%s/cache/.features", basedir); + if (rc == -1) { perror("asprintf"); exit(1); }