From 21060e802aa997fc7a1788fd9443f7e7be5ca1ed Mon Sep 17 00:00:00 2001 From: John Johansen Date: Fri, 9 Oct 2020 14:08:27 -0700 Subject: [PATCH] parser: Fix warning message when complain mode is forced when a profile is being forced to complain a variation of the following message is displayed Warning from /etc/apparmor.d/usr.sbin.sssd (/etc/apparmor.d/usr.sbin.sssd line 54): Warning failed to create cache: usr.sbin.sssd This is incorrect in that the parser doesn't even try to create the cache, it just can't cache force complain profiles. Output a warning message for this case that is correct. Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1899218 MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/649 Signed-off-by: John Johansen Acked-by: Steve Beattie Acked-by: Christian Boltz --- parser/parser_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/parser/parser_main.c b/parser/parser_main.c index 42bb7791d..a0f593acb 100644 --- a/parser/parser_main.c +++ b/parser/parser_main.c @@ -1159,9 +1159,11 @@ int process_profile(int option, aa_kernel_interface *kernel_interface, /* cache file generated by load_policy */ retval = load_policy(option, kernel_interface, cachetmp); if (retval == 0 && write_cache) { - if (cachetmp == -1) { + if (force_complain) { + pwarn(WARN_CACHE, "Caching disabled for: '%s' due to force complain\n", basename); + } else if (cachetmp == -1) { unlink(cachetmpname); - pwarn(WARN_CACHE, "Warning failed to create cache: %s\n", + pwarn(WARN_CACHE, "Failed to create cache: %s\n", basename); } else { install_cache(cachetmpname, writecachename);