3e5111
From c71f920357ffb17cd13aaf9a12e8d77d1b29b08c Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <c71f920357ffb17cd13aaf9a12e8d77d1b29b08c@dist-git>
3e5111
From: Martin Kletzander <mkletzan@redhat.com>
3e5111
Date: Mon, 5 Jun 2017 17:02:03 +0200
3e5111
Subject: [PATCH] audit: Fix the output message for shmem
3e5111
3e5111
After some discussion on and off the linux-audit mailing list, we
3e5111
should use different fields for the audit messages.
3e5111
3e5111
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603
3e5111
3e5111
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
3e5111
(cherry picked from commit 6d12a1cb2fb0e0152a19518423dceafa7cf088fb)
3e5111
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/conf/domain_audit.c | 24 +++++++++++++-----------
3e5111
 1 file changed, 13 insertions(+), 11 deletions(-)
3e5111
3e5111
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
3e5111
index 2d9ff5e3ff..1e667af73c 100644
3e5111
--- a/src/conf/domain_audit.c
3e5111
+++ b/src/conf/domain_audit.c
3e5111
@@ -983,15 +983,13 @@ virDomainAuditShmem(virDomainObjPtr vm,
3e5111
     char uuidstr[VIR_UUID_STRING_BUFLEN];
3e5111
     char *vmname = virAuditEncode("vm", vm->def->name);
3e5111
     const char *srcpath = virDomainAuditChardevPath(&def->server.chr);
3e5111
-    char *src = virAuditEncode("server", VIR_AUDIT_STR(srcpath));
3e5111
-    char *shmem = virAuditEncode("shmem", VIR_AUDIT_STR(def->name));
3e5111
     const char *virt = virDomainVirtTypeToString(vm->def->virtType);
3e5111
-    char *size = NULL;
3e5111
+    char *shmpath = NULL;
3e5111
 
3e5111
     virUUIDFormat(vm->def->uuid, uuidstr);
3e5111
 
3e5111
-    if (!vmname || !src || !shmem ||
3e5111
-        virAsprintfQuiet(&size, "%llu", def->size) < 0) {
3e5111
+    if (!vmname ||
3e5111
+        virAsprintfQuiet(&shmpath, "/dev/shm/%s", def->name) < 0) {
3e5111
         VIR_WARN("OOM while encoding audit message");
3e5111
         goto cleanup;
3e5111
     }
3e5111
@@ -1002,14 +1000,18 @@ virDomainAuditShmem(virDomainObjPtr vm,
3e5111
         virt = "?";
3e5111
     }
3e5111
 
3e5111
-    VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
3e5111
-              "virt=%s resrc=shmem reason=%s %s uuid=%s size=%s %s %s",
3e5111
-              virt, reason, vmname, uuidstr, size, shmem, src);
3e5111
+    if (def->server.enabled) {
3e5111
+        VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
3e5111
+                  "virt=%s resrc=ivshmem-socket reason=%s %s uuid=%s path=%s",
3e5111
+                  virt, reason, vmname, uuidstr, VIR_AUDIT_STR(srcpath));
3e5111
+    } else {
3e5111
+        VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
3e5111
+                  "virt=%s resrc=shmem reason=%s %s uuid=%s size=%llu path=%s",
3e5111
+                  virt, reason, vmname, uuidstr, def->size, VIR_AUDIT_STR(shmpath));
3e5111
+   }
3e5111
 
3e5111
  cleanup:
3e5111
     VIR_FREE(vmname);
3e5111
-    VIR_FREE(src);
3e5111
-    VIR_FREE(size);
3e5111
-    VIR_FREE(shmem);
3e5111
+    VIR_FREE(shmpath);
3e5111
     return;
3e5111
 }
3e5111
-- 
3e5111
2.13.1
3e5111