From 5bd3c73bdff0f26e7045f537ad8102138e25329d Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 3 Jul 2014 12:03:41 +0200 Subject: [PATCH] audit: Audit smartcard devices --- docs/auditlog.html.in | 20 +++++++++++++++++ src/conf/domain_audit.c | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/docs/auditlog.html.in b/docs/auditlog.html.in index 8528b5295e..8a007caf35 100644 --- a/docs/auditlog.html.in +++ b/docs/auditlog.html.in @@ -301,6 +301,26 @@
Updated path of the backing character device for given emulated device
+

smartcard

+

+ The msg field will include the following sub-fields +

+ +
+
reason
+
The reason which caused the resource to be assigned to happen
+
resrc
+
The type of resource assigned. Set to smartcard
+
old-smartcard
+
Original path of the backing character device, certificate store or + "nss-smartcard-device" for host smartcard passthrough. +
+
new-smartcard
+
Updated path of the backing character device, certificate store or + "nss-smartcard-device" for host smartcard passthrough. +
+
+

Redirected device

The msg field will include the following sub-fields diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 23bb4a7e82..a3d6c67a31 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -177,6 +177,51 @@ virDomainAuditChardev(virDomainObjPtr vm, } +static void +virDomainAuditSmartcard(virDomainObjPtr vm, + virDomainSmartcardDefPtr def, + const char *reason, + bool success) +{ + const char *database = VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE; + size_t i; + + if (def) { + switch ((virDomainSmartcardType) def->type) { + case VIR_DOMAIN_SMARTCARD_TYPE_HOST: + virDomainAuditGenericDev(vm, "smartcard", + NULL, "nss-smartcard-device", + reason, success); + break; + + case VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES: + for (i = 0; i < VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES; i++) { + virDomainAuditGenericDev(vm, "smartcard", NULL, + def->data.cert.file[i], + reason, success); + } + + if (def->data.cert.database) + database = def->data.cert.database; + + virDomainAuditGenericDev(vm, "smartcard", + NULL, database, + reason, success); + break; + + case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: + virDomainAuditGenericDev(vm, "smartcard", NULL, + virDomainAuditChardevPath(&def->data.passthru), + reason, success); + break; + + case VIR_DOMAIN_SMARTCARD_TYPE_LAST: + break; + } + } +} + + void virDomainAuditDisk(virDomainObjPtr vm, virStorageSourcePtr oldDef, @@ -814,6 +859,9 @@ virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success) virDomainAuditChardev(vm, NULL, vm->def->consoles[i], "start", true); } + for (i = 0; i < vm->def->nsmartcards; i++) + virDomainAuditSmartcard(vm, vm->def->smartcards[i], "start", true); + if (vm->def->rng) virDomainAuditRNG(vm, NULL, vm->def->rng, "start", true); -- GitLab