[apparmor] [PATCH v2 40/42] parser: Lift globals from create_cache()
John Johansen
john.johansen at canonical.com
Thu Mar 12 12:10:44 UTC 2015
On 03/06/2015 01:48 PM, Tyler Hicks wrote:
> With create_cache() headed for libapparmor, we can't use the show_cache
> or write_cache globals.
>
> Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
Acked-by: John Johansen <john.johansen at canonical.com>
> ---
> parser/parser_main.c | 4 ++++
> parser/policy_cache.c | 20 ++++++--------------
> 2 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/parser/parser_main.c b/parser/parser_main.c
> index 8fb7394..2cbe987 100644
> --- a/parser/parser_main.c
> +++ b/parser/parser_main.c
> @@ -939,6 +939,10 @@ int main(int argc, char *argv[])
> } else if (!aa_policy_cache_is_valid(policy_cache)) {
> if (write_cache && cond_clear_cache &&
> aa_policy_cache_create(policy_cache)) {
> + if (show_cache)
> + PERROR("Cache write disabled: Cannot create cache '%s': %m\n",
> + cacheloc);
> + write_cache = 0;
> skip_read_cache = 1;
> } else if (!write_cache || !cond_clear_cache) {
> if (show_cache)
> diff --git a/parser/policy_cache.c b/parser/policy_cache.c
> index 35dc235..c28a981 100644
> --- a/parser/policy_cache.c
> +++ b/parser/policy_cache.c
> @@ -129,24 +129,16 @@ error:
> if (stat(policy_cache->path, &stat_file) == -1) {
> if (mkdir(policy_cache->path, 0700) == 0)
> goto create_file;
> - if (show_cache)
> - PERROR("Can't create cache directory: %s\n",
> - policy_cache->path);
> + PERROR("Can't create cache directory: %s\n",
> + policy_cache->path);
> } else if (!S_ISDIR(stat_file.st_mode)) {
> - if (show_cache)
> - PERROR("File in cache directory location: %s\n",
> - policy_cache->path);
> + PERROR("File in cache directory location: %s\n",
> + policy_cache->path);
> } else {
> - if (show_cache)
> - PERROR("Can't update cache directory: %s\n",
> - policy_cache->path);
> + PERROR("Can't update cache directory: %s\n",
> + policy_cache->path);
> }
>
> - if (show_cache)
> - PERROR("Cache write disabled: cannot create %s\n",
> - policy_cache->features_path);
> - write_cache = 0;
> -
> return -1;
> }
>
>
More information about the AppArmor
mailing list