diff --git a/libraries/libapparmor/src/policy_cache.c b/libraries/libapparmor/src/policy_cache.c index f685f0a97..72c01763a 100644 --- a/libraries/libapparmor/src/policy_cache.c +++ b/libraries/libapparmor/src/policy_cache.c @@ -78,7 +78,7 @@ static int init_cache_features(aa_policy_cache *policy_cache, } else if (!aa_features_is_equal(policy_cache->features, kernel_features)) { if (!create) { - errno = ENOENT; + errno = EEXIST; return -1; } @@ -166,8 +166,10 @@ open: if (mkdirat(dirfd, path, 0700) == 0) goto open; PERROR("Can't create cache directory '%s': %m\n", path); - } else { + } else if (create) { PERROR("Can't update cache directory '%s': %m\n", path); + } else { + PDEBUG("Cache directory '%s' does not exist\n", path); } save = errno; diff --git a/parser/parser_main.c b/parser/parser_main.c index f274d007c..738acfc80 100644 --- a/parser/parser_main.c +++ b/parser/parser_main.c @@ -921,7 +921,7 @@ int main(int argc, char *argv[]) retval = aa_policy_cache_new(&policy_cache, features, AT_FDCWD, cacheloc, max_caches); if (retval) { - if (errno != ENOENT) { + if (errno != ENOENT && errno != EEXIST) { PERROR(_("Failed setting up policy cache (%s): %s\n"), cacheloc, strerror(errno)); return 1;