Skip to contentSkip to conversation

make avc audit line only have one space

PATCH In review Steven Moreland 2 participants 2 messages Apr 1, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make avc audit line only have one space

From: smore-lore <[email protected]>

The kernel-based logs only have one space. So, many scripts need to parse 'avc: denied' and 'avc: denied'. Also, I frequently have developers missing denials because they grep for the single space version locally.

---
 libselinux/src/avc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/avc.c +1 -1
index 8d5983a2..8fdb2389 100644
@@ -711,7 +711,7 @@ void avc_audit(security_id_t ssid, security_id_t tsid,
 	/* prevent overlapping buffer writes */
 	avc_get_lock(avc_log_lock);
 	snprintf(avc_audit_buf, AVC_AUDIT_BUFSIZE,
-		 "%s:  %s ", avc_prefix, (denied || !requested) ? "denied" : "granted");
+		 "%s: %s ", avc_prefix, (denied || !requested) ? "denied" : "granted");
 	avc_dump_av(tclass, audited);
 	log_append(avc_audit_buf, " for ");
 
Signature · 1 line
2.40.0.348.gf938b09366-goog
#1 lore raw
Quoted 4 lines · Steven Moreland

From: smore-lore <[email protected]>

The kernel-based logs only have one space.

I don't think they have:

https://github.com/SELinuxProject/selinux-kernel/blob/dd43102acca0836f5e50746c47c258be1ef9060c/security/selinux/avc.c#L674

Quoted 26 lines

So, many scripts need to
parse 'avc: denied' and 'avc: denied'. Also, I frequently have developers missing denials because they grep for the single space version locally.

---
 libselinux/src/avc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/avc.c +1 -2
index 8d5983a2..8fdb2389 100644
@@ -711,7 +711,7 @@ void avc_audit(security_id_t ssid, security_id_t tsid,
        /* prevent overlapping buffer writes */
        avc_get_lock(avc_log_lock);
        snprintf(avc_audit_buf, AVC_AUDIT_BUFSIZE,
-                "%s:  %s ", avc_prefix, (denied || !requested) ? "denied" : "granted");
+                "%s: %s ", avc_prefix, (denied || !requested) ? "denied" : "granted");
        avc_dump_av(tclass, audited);
        log_append(avc_audit_buf, " for ");
 
--

2.40.0.348.gf938b09366-goog