2010-09-15 13:44:11 +00:00
|
|
|
/*
|
2011-07-11 19:42:15 +00:00
|
|
|
* viraudit.h: auditing support
|
2010-09-15 13:44:11 +00:00
|
|
|
*
|
2014-10-28 19:07:09 +00:00
|
|
|
* Copyright (C) 2010-2011, 2014 Red Hat, Inc.
|
2010-09-15 13:44:11 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-09-15 13:44:11 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#pragma once
|
2010-09-15 13:44:11 +00:00
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#include "internal.h"
|
|
|
|
#include "virlog.h"
|
2010-09-15 13:44:11 +00:00
|
|
|
|
2014-04-27 00:15:22 +00:00
|
|
|
typedef enum {
|
2010-09-15 13:44:11 +00:00
|
|
|
VIR_AUDIT_RECORD_MACHINE_CONTROL,
|
|
|
|
VIR_AUDIT_RECORD_MACHINE_ID,
|
|
|
|
VIR_AUDIT_RECORD_RESOURCE,
|
2014-04-27 00:15:22 +00:00
|
|
|
} virAuditRecordType;
|
2010-09-15 13:44:11 +00:00
|
|
|
|
2017-12-13 10:56:13 +00:00
|
|
|
int virAuditOpen(unsigned int audit_level);
|
2010-09-15 13:44:11 +00:00
|
|
|
|
2014-10-28 19:07:09 +00:00
|
|
|
void virAuditLog(bool enabled);
|
2010-09-15 13:44:11 +00:00
|
|
|
|
2014-02-27 17:44:53 +00:00
|
|
|
void virAuditSend(virLogSourcePtr source,
|
|
|
|
const char *filename, size_t linenr, const char *funcname,
|
2010-09-15 13:44:11 +00:00
|
|
|
const char *clienttty, const char *clientaddr,
|
2014-04-27 00:15:22 +00:00
|
|
|
virAuditRecordType type, bool success,
|
2010-10-26 17:02:08 +00:00
|
|
|
const char *fmt, ...)
|
2019-10-15 11:35:07 +00:00
|
|
|
G_GNUC_PRINTF(9, 10);
|
2010-09-15 13:44:11 +00:00
|
|
|
|
2010-10-27 10:53:48 +00:00
|
|
|
char *virAuditEncode(const char *key, const char *value);
|
|
|
|
|
2010-09-15 13:44:11 +00:00
|
|
|
void virAuditClose(void);
|
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#define VIR_AUDIT(type, success, ...) \
|
2017-11-03 12:09:47 +00:00
|
|
|
virAuditSend(&virLogSelf, __FILE__, __LINE__, __func__, \
|
2010-09-15 13:44:11 +00:00
|
|
|
NULL, NULL, type, success, __VA_ARGS__);
|
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#define VIR_AUDIT_USER(type, success, clienttty, clientaddr, ...) \
|
2017-11-03 12:09:47 +00:00
|
|
|
virAuditSend(&virLogSelf, __FILE__, __LINE__, __func__, \
|
2010-09-15 13:44:11 +00:00
|
|
|
clienttty, clientaddr, type, success, __VA_ARGS__);
|
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#define VIR_AUDIT_STR(str) \
|
2010-10-27 10:53:48 +00:00
|
|
|
((str) ? (str) : "?")
|