mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-29 13:28:19 +00:00
Fix caching when used with a newer kernel with the feature directory
On newer kernels the features directory causes the creation of a cache/.feature file that contains newline characters. This causes the feature comparison to fail, because get_flags_string() uses fgets which stop reading in the feature file after the first newline. This caches the features comparision to compare a single line of the file against the full kernel feature directory resulting in caching failure. Worse this also means the cache won't get updated as the parser doesn't change what set gets caches after the .feature file gets created. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-By: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
parent
b0b2bde160
commit
3876299fa0
@ -844,6 +844,7 @@ out:
|
|||||||
static void get_flags_string(char **flags, char *flags_file) {
|
static void get_flags_string(char **flags, char *flags_file) {
|
||||||
char *pos;
|
char *pos;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
/* abort if missing or already set */
|
/* abort if missing or already set */
|
||||||
if (!flags || *flags)
|
if (!flags || *flags)
|
||||||
@ -857,8 +858,10 @@ static void get_flags_string(char **flags, char *flags_file) {
|
|||||||
if (!*flags)
|
if (!*flags)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!fgets(*flags, FLAGS_STRING_SIZE, f))
|
size = fread(*flags, 1, FLAGS_STRING_SIZE - 1, f);
|
||||||
|
if (!size || ferror(f))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
(*flags)[size] = 0;
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
pos = strstr(*flags, "change_hat=");
|
pos = strstr(*flags, "change_hat=");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user