mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 22:05:27 +00:00
parser: Move policy cache functionality into policy_cache.c
Signed-off-by: John Johansen <john.johansen@canonical.com> [tyhicks: Fixed build failures] [tyhicks: Fixed bug where a warning was being printed when it shouldn't] [tyhicks: Forward ported to trunk] Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
This commit is contained in:
committed by
Tyler Hicks
parent
4970d40e0d
commit
2a082ee543
@@ -42,7 +42,7 @@
|
||||
#define SD_STR_LEN (sizeof(u16))
|
||||
|
||||
|
||||
int __sd_serialize_profile(int option, Profile *prof);
|
||||
int __sd_serialize_profile(int option, Profile *prof, int cache_fd);
|
||||
|
||||
static void print_error(int error)
|
||||
{
|
||||
@@ -83,13 +83,13 @@ static void print_error(int error)
|
||||
}
|
||||
}
|
||||
|
||||
int load_profile(int option, Profile *prof)
|
||||
int load_profile(int option, Profile *prof, int cache_fd)
|
||||
{
|
||||
int retval = 0;
|
||||
int error = 0;
|
||||
|
||||
PDEBUG("Serializing policy for %s.\n", prof->name);
|
||||
retval = __sd_serialize_profile(option, prof);
|
||||
retval = __sd_serialize_profile(option, prof, cache_fd);
|
||||
|
||||
if (retval < 0) {
|
||||
error = retval; /* yeah, we'll just report the last error */
|
||||
@@ -475,8 +475,7 @@ void sd_serialize_top_profile(std::ostringstream &buf, Profile *profile)
|
||||
sd_serialize_profile(buf, profile, profile->parent ? 1 : 0);
|
||||
}
|
||||
|
||||
int cache_fd = -1;
|
||||
int __sd_serialize_profile(int option, Profile *prof)
|
||||
int __sd_serialize_profile(int option, Profile *prof, int cache_fd)
|
||||
{
|
||||
autoclose int fd = -1;
|
||||
int error = -ENOMEM, size, wsize;
|
||||
@@ -555,7 +554,7 @@ int __sd_serialize_profile(int option, Profile *prof)
|
||||
}
|
||||
|
||||
if (!prof->hat_table.empty() && option != OPTION_REMOVE) {
|
||||
if (load_flattened_hats(prof, option) == 0)
|
||||
if (load_flattened_hats(prof, option, cache_fd) == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user