mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
audit: also audit cgroup controller path
Although the cgroup device ACL controller path can be worked out by researching the code, it is more efficient to include that information directly in the audit message. * src/util/cgroup.h (virCgroupPathOfController): New prototype. * src/util/cgroup.c (virCgroupPathOfController): Export. * src/libvirt_private.syms: Likewise. * src/qemu/qemu_audit.c (qemuAuditCgroup): Use it.
This commit is contained in:
parent
d04916faae
commit
f2512684ad
@ -79,6 +79,7 @@ virCgroupKill;
|
||||
virCgroupKillRecursive;
|
||||
virCgroupKillPainfully;
|
||||
virCgroupMounted;
|
||||
virCgroupPathOfController;
|
||||
virCgroupRemove;
|
||||
virCgroupSetBlkioWeight;
|
||||
virCgroupSetCpuShares;
|
||||
|
@ -213,11 +213,13 @@ cleanup:
|
||||
* Log an audit message about an attempted cgroup device ACL change.
|
||||
*/
|
||||
void
|
||||
qemuAuditCgroup(virDomainObjPtr vm, virCgroupPtr cgroup ATTRIBUTE_UNUSED,
|
||||
qemuAuditCgroup(virDomainObjPtr vm, virCgroupPtr cgroup,
|
||||
const char *reason, const char *extra, bool success)
|
||||
{
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
char *vmname;
|
||||
char *controller = NULL;
|
||||
char *detail;
|
||||
|
||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
|
||||
@ -225,11 +227,18 @@ qemuAuditCgroup(virDomainObjPtr vm, virCgroupPtr cgroup ATTRIBUTE_UNUSED,
|
||||
return;
|
||||
}
|
||||
|
||||
virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_DEVICES,
|
||||
NULL, &controller);
|
||||
detail = virAuditEncode("cgroup", VIR_AUDIT_STR(controller));
|
||||
|
||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||
"resrc=cgroup reason=%s %s uuid=%s class=%s",
|
||||
reason, vmname, uuidstr, extra);
|
||||
"resrc=cgroup reason=%s %s uuid=%s %s class=%s",
|
||||
reason, vmname, uuidstr,
|
||||
detail ? detail : "cgroup=?", extra);
|
||||
|
||||
VIR_FREE(vmname);
|
||||
VIR_FREE(controller);
|
||||
VIR_FREE(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,10 +254,10 @@ static int virCgroupDetect(virCgroupPtr group)
|
||||
#endif
|
||||
|
||||
|
||||
static int virCgroupPathOfController(virCgroupPtr group,
|
||||
int controller,
|
||||
const char *key,
|
||||
char **path)
|
||||
int virCgroupPathOfController(virCgroupPtr group,
|
||||
int controller,
|
||||
const char *key,
|
||||
char **path)
|
||||
{
|
||||
if (controller == -1) {
|
||||
int i;
|
||||
|
@ -40,6 +40,11 @@ int virCgroupForDomain(virCgroupPtr driver,
|
||||
virCgroupPtr *group,
|
||||
int create);
|
||||
|
||||
int virCgroupPathOfController(virCgroupPtr group,
|
||||
int controller,
|
||||
const char *key,
|
||||
char **path);
|
||||
|
||||
int virCgroupAddTask(virCgroupPtr group, pid_t pid);
|
||||
|
||||
int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
|
||||
|
Loading…
Reference in New Issue
Block a user