From 5d7fe96fd058d4b31dc9f77cf2911ff941a4ec78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20B=C3=A9lair?= Date: Thu, 17 Apr 2025 19:46:32 +0200 Subject: [PATCH] apparmor_parser: show attachment in --debug output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When showing the content of profiles with `apparmor_parser --debug`, the attachment path is now displayed within the 'Debugging built structures' section. Signed-off-by: Maxime Bélair --- parser/parser.h | 1 + parser/parser_regex.c | 2 +- parser/profile.h | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/parser/parser.h b/parser/parser.h index 3e0eb5ee9..56fae71f2 100644 --- a/parser/parser.h +++ b/parser/parser.h @@ -410,6 +410,7 @@ extern int process_policydb(Profile *prof); extern int process_policy_ents(Profile *prof); extern void filter_slashes(char *path); +extern const char *local_name(const char *name); /* parser_variable.c */ int expand_entry_variables(char **name); diff --git a/parser/parser_regex.c b/parser/parser_regex.c index 4a8018b65..6d61c61fb 100644 --- a/parser/parser_regex.c +++ b/parser/parser_regex.c @@ -433,7 +433,7 @@ out: return ptype; } -static const char *local_name(const char *name) +const char *local_name(const char *name) { const char *t; diff --git a/parser/profile.h b/parser/profile.h index d245a1376..207c9b57e 100644 --- a/parser/profile.h +++ b/parser/profile.h @@ -459,7 +459,12 @@ public: printf("Name:\t\t%s\n", name); else printf("Name:\t\t\n"); - + if (attachment) + printf("Attachment:\t%s\n", attachment); + else { + const char *local = local_name(name); + printf("Attachment:\t%s\n", local[0] == '/' ? local : ""); + } if (parent) printf("Local To:\t%s\n", parent->name); else