2015-07-20 18:33:35 +02:00
|
|
|
/* NetworkManager audit support
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2015 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NM_AUDIT_MANAGER_H__
|
|
|
|
|
#define __NM_AUDIT_MANAGER_H__
|
|
|
|
|
|
|
|
|
|
#include "nm-connection.h"
|
2016-11-21 00:43:52 +01:00
|
|
|
#include "devices/nm-device.h"
|
2015-07-20 18:33:35 +02:00
|
|
|
#include "nm-types.h"
|
|
|
|
|
|
|
|
|
|
#define NM_TYPE_AUDIT_MANAGER (nm_audit_manager_get_type ())
|
|
|
|
|
#define NM_AUDIT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AUDIT_MANAGER, NMAuditManager))
|
|
|
|
|
#define NM_AUDIT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_AUDIT_MANAGER, NMAuditManagerClass))
|
|
|
|
|
#define NM_IS_AUDIT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_AUDIT_MANAGER))
|
|
|
|
|
#define NM_IS_AUDIT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AUDIT_MANAGER))
|
|
|
|
|
#define NM_AUDIT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AUDIT_MANAGER, NMAuditManagerClass))
|
|
|
|
|
|
2016-09-29 13:49:01 +02:00
|
|
|
typedef struct _NMAuditManagerClass NMAuditManagerClass;
|
2015-07-20 18:33:35 +02:00
|
|
|
|
|
|
|
|
#define NM_AUDIT_OP_CONN_ADD "connection-add"
|
|
|
|
|
#define NM_AUDIT_OP_CONN_DELETE "connection-delete"
|
|
|
|
|
#define NM_AUDIT_OP_CONN_UPDATE "connection-update"
|
|
|
|
|
#define NM_AUDIT_OP_CONN_ACTIVATE "connection-activate"
|
|
|
|
|
#define NM_AUDIT_OP_CONN_ADD_ACTIVATE "connection-add-activate"
|
|
|
|
|
#define NM_AUDIT_OP_CONN_DEACTIVATE "connection-deactivate"
|
|
|
|
|
#define NM_AUDIT_OP_CONN_CLEAR_SECRETS "connection-clear-secrets"
|
|
|
|
|
|
2019-07-15 09:56:44 +02:00
|
|
|
#define NM_AUDIT_OP_CONNS_RELOAD "connections-reload"
|
|
|
|
|
#define NM_AUDIT_OP_CONNS_LOAD "connections-load"
|
|
|
|
|
|
2016-05-30 15:42:44 +02:00
|
|
|
#define NM_AUDIT_OP_RELOAD "reload"
|
2015-07-20 18:33:35 +02:00
|
|
|
#define NM_AUDIT_OP_SLEEP_CONTROL "sleep-control"
|
|
|
|
|
#define NM_AUDIT_OP_NET_CONTROL "networking-control"
|
|
|
|
|
#define NM_AUDIT_OP_RADIO_CONTROL "radio-control"
|
2016-08-10 11:54:32 +02:00
|
|
|
#define NM_AUDIT_OP_STATISTICS "statistics"
|
2015-07-20 18:33:35 +02:00
|
|
|
|
|
|
|
|
#define NM_AUDIT_OP_DEVICE_AUTOCONNECT "device-autoconnect"
|
|
|
|
|
#define NM_AUDIT_OP_DEVICE_DISCONNECT "device-disconnect"
|
|
|
|
|
#define NM_AUDIT_OP_DEVICE_DELETE "device-delete"
|
2015-09-15 14:27:31 +02:00
|
|
|
#define NM_AUDIT_OP_DEVICE_MANAGED "device-managed"
|
2016-01-07 11:55:44 +01:00
|
|
|
#define NM_AUDIT_OP_DEVICE_REAPPLY "device-reapply"
|
2015-07-20 18:33:35 +02:00
|
|
|
|
2016-08-01 17:19:14 +02:00
|
|
|
#define NM_AUDIT_OP_CHECKPOINT_CREATE "checkpoint-create"
|
|
|
|
|
#define NM_AUDIT_OP_CHECKPOINT_ROLLBACK "checkpoint-rollback"
|
|
|
|
|
#define NM_AUDIT_OP_CHECKPOINT_DESTROY "checkpoint-destroy"
|
checkpoint: allow resetting the rollback timeout via D-Bus
This allows to adjust the timeout of an existing checkpoint.
The main usecase of checkpoints, is to have a fail-safe when
configuring the network remotely. By allowing to reset the timeout,
the user can perform a series of actions, and keep bumping the
timeout. That way, the entire series is still guarded by the same
checkpoint, but the user can start with short timeout, and
re-adjust the timeout as he goes along.
The libnm API only implements the async form (at least for now).
Sync methods are fundamentally wrong with D-Bus, and it's probably
not needed. Also, follow glib convenction, where the async form
doesn't have the _async name suffix. Also, accept a D-Bus path
as argument, not a NMCheckpoint instance. The libnm API should
not be more restricted than the underlying D-Bus API. It would
be cumbersome to require the user to lookup the NMCheckpoint
instance first, especially since libnm doesn't provide an efficient
or convenient lookup-by-path method. On the other hand, retrieving
the path from a NMCheckpoint instance is always possible.
2018-03-28 08:09:56 +02:00
|
|
|
#define NM_AUDIT_OP_CHECKPOINT_ADJUST_ROLLBACK_TIMEOUT "checkpoint-adjust-rollback-timeout"
|
2016-08-01 17:19:14 +02:00
|
|
|
|
2015-07-20 18:33:35 +02:00
|
|
|
GType nm_audit_manager_get_type (void);
|
|
|
|
|
NMAuditManager *nm_audit_manager_get (void);
|
|
|
|
|
gboolean nm_audit_manager_audit_enabled (NMAuditManager *self);
|
|
|
|
|
|
2016-04-20 12:10:55 +02:00
|
|
|
#define nm_audit_log_connection_op(op, connection, result, args, subject_context, reason) \
|
2015-07-20 18:33:35 +02:00
|
|
|
G_STMT_START { \
|
|
|
|
|
NMAuditManager *_audit = nm_audit_manager_get (); \
|
|
|
|
|
\
|
|
|
|
|
if (nm_audit_manager_audit_enabled (_audit)) { \
|
|
|
|
|
_nm_audit_manager_log_connection_op (_audit, __FILE__, __LINE__, G_STRFUNC, \
|
2016-04-20 12:10:55 +02:00
|
|
|
(op), (connection), (result), (args), (subject_context), \
|
2015-07-20 18:33:35 +02:00
|
|
|
(reason)); \
|
|
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
2016-01-07 16:31:19 +01:00
|
|
|
#define nm_audit_log_control_op(op, arg, result, subject_context, reason) \
|
2015-07-20 18:33:35 +02:00
|
|
|
G_STMT_START { \
|
|
|
|
|
NMAuditManager *_audit = nm_audit_manager_get (); \
|
|
|
|
|
\
|
|
|
|
|
if (nm_audit_manager_audit_enabled (_audit)) { \
|
2016-08-01 17:19:14 +02:00
|
|
|
_nm_audit_manager_log_generic_op (_audit, __FILE__, __LINE__, G_STRFUNC, \
|
2016-01-07 16:31:19 +01:00
|
|
|
(op), (arg), (result), (subject_context), (reason)); \
|
2015-07-20 18:33:35 +02:00
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
2017-03-04 00:06:59 +01:00
|
|
|
#define nm_audit_log_device_op(op, device, result, args, subject_context, reason) \
|
2015-07-20 18:33:35 +02:00
|
|
|
G_STMT_START { \
|
|
|
|
|
NMAuditManager *_audit = nm_audit_manager_get (); \
|
|
|
|
|
\
|
|
|
|
|
if (nm_audit_manager_audit_enabled (_audit)) { \
|
|
|
|
|
_nm_audit_manager_log_device_op (_audit, __FILE__, __LINE__, G_STRFUNC, \
|
2017-03-04 00:06:59 +01:00
|
|
|
(op), (device), (result), (args), (subject_context), (reason)); \
|
2015-07-20 18:33:35 +02:00
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
2016-08-01 17:19:14 +02:00
|
|
|
#define nm_audit_log_checkpoint_op(op, arg, result, subject_context, reason) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
NMAuditManager *_audit = nm_audit_manager_get (); \
|
|
|
|
|
\
|
|
|
|
|
if (nm_audit_manager_audit_enabled (_audit)) { \
|
|
|
|
|
_nm_audit_manager_log_generic_op (_audit, __FILE__, __LINE__, G_STRFUNC, \
|
|
|
|
|
(op), (arg), (result), (subject_context), (reason)); \
|
|
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
2015-07-20 18:33:35 +02:00
|
|
|
void _nm_audit_manager_log_connection_op (NMAuditManager *self, const char *file, guint line,
|
2015-07-14 16:53:24 +02:00
|
|
|
const char *func, const char *op, NMSettingsConnection *connection,
|
2016-04-20 12:10:55 +02:00
|
|
|
gboolean result, const char *args, gpointer subject_context,
|
|
|
|
|
const char *reason);
|
2015-07-20 18:33:35 +02:00
|
|
|
|
2016-08-01 17:19:14 +02:00
|
|
|
void _nm_audit_manager_log_generic_op (NMAuditManager *self, const char *file, guint line,
|
2015-07-20 18:33:35 +02:00
|
|
|
const char *func, const char *op, const char *arg,
|
2016-01-07 16:31:19 +01:00
|
|
|
gboolean result, gpointer subject_context, const char *reason);
|
2015-07-20 18:33:35 +02:00
|
|
|
|
|
|
|
|
void _nm_audit_manager_log_device_op (NMAuditManager *self, const char *file, guint line,
|
|
|
|
|
const char *func, const char *op, NMDevice *device,
|
2017-03-04 00:06:59 +01:00
|
|
|
gboolean result, const char *args, gpointer subject_context,
|
|
|
|
|
const char *reason);
|
2016-08-01 17:19:14 +02:00
|
|
|
|
2015-07-20 18:33:35 +02:00
|
|
|
#endif /* __NM_AUDIT_MANAGER_H__ */
|