From b55e4c88f10d11a4d73b34f3a6751a09a880dc61 Mon Sep 17 00:00:00 2001 From: Bow Sineath Date: Mon, 27 Oct 2025 13:25:58 -0400 Subject: [PATCH] Update isApparmorProfileLoaded() to avoid audit logs in kernel versions >4.11 --- bundle/lib/source/DobbyConfig.cpp | 48 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/bundle/lib/source/DobbyConfig.cpp b/bundle/lib/source/DobbyConfig.cpp index 15db39f4b..6914222c2 100644 --- a/bundle/lib/source/DobbyConfig.cpp +++ b/bundle/lib/source/DobbyConfig.cpp @@ -791,31 +791,41 @@ bool DobbyConfig::updateBundleConfig(const ContainerId& id, std::shared_ptrd_name) >= (profile_len + 2)) { + if(!strncmp(cur_dir->d_name, profile, profile_len) && + cur_dir->d_name[profile_len] == '.' && + isdigit(cur_dir->d_name[profile_len + 1])) { + + status = true; + AI_LOG_INFO("AppArmor profile [%s] is loaded.", profile); + break; + } + } } - else - { - status = true; - AI_LOG_INFO("Apparmor profile [%s] is loaded", profile); + + if(!status) { + AI_LOG_INFO("AppArmor profile [%s] not found.", profile); } - close(fd); + if(!cur_dir && errno) { + AI_LOG_SYS_ERROR(errno, "readdir() failed on apparmorfs policy directory"); + } + + closedir(d); + return status; }