summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-03-04 00:06:59 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2017-03-04 18:05:12 +0100
commit5b0aa20df2d8462b98d2d630a597782733190027 (patch)
treeadddaf82cea1d51f3a5fb8d818f49699c6ad9f14
parent87eb80361f864ae937a0b2a5f77dea76fbfb58da (diff)
downloadNetworkManager-5b0aa20df2d8462b98d2d630a597782733190027.tar.gz
audit: add @args to device logging functions
-rw-r--r--src/devices/nm-device.c22
-rw-r--r--src/nm-audit-manager.c9
-rw-r--r--src/nm-audit-manager.h7
3 files changed, 22 insertions, 16 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index f27c69fe06..aa3f7c3977 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -8678,7 +8678,7 @@ reapply_cb (NMDevice *self,
}
if (error) {
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, subject, error->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, subject, error->message);
g_dbus_method_invocation_return_gerror (context, error);
return;
}
@@ -8687,11 +8687,11 @@ reapply_cb (NMDevice *self,
connection ? : (NMConnection *) nm_device_get_settings_connection (self),
version_id,
&local)) {
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, subject, local->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, subject, local->message);
g_dbus_method_invocation_take_error (context, local);
local = NULL;
} else {
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, TRUE, subject, NULL);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, TRUE, NULL, subject, NULL);
g_dbus_method_invocation_return_value (context, NULL);
}
}
@@ -8714,7 +8714,7 @@ impl_device_reapply (NMDevice *self,
error = g_error_new_literal (NM_DEVICE_ERROR,
NM_DEVICE_ERROR_FAILED,
"Invalid flags specified");
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, context, error->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, context, error->message);
g_dbus_method_invocation_take_error (context, error);
return;
}
@@ -8723,7 +8723,7 @@ impl_device_reapply (NMDevice *self,
error = g_error_new_literal (NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ACTIVE,
"Device is not activated");
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, context, error->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, context, error->message);
g_dbus_method_invocation_take_error (context, error);
return;
}
@@ -8739,7 +8739,7 @@ impl_device_reapply (NMDevice *self,
&error);
if (!connection) {
g_prefix_error (&error, "The settings specified are invalid: ");
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, context, error->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_REAPPLY, self, FALSE, NULL, context, error->message);
g_dbus_method_invocation_take_error (context, error);
return;
}
@@ -8869,7 +8869,7 @@ disconnect_cb (NMDevice *self,
if (error) {
g_dbus_method_invocation_return_gerror (context, error);
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, FALSE, subject, error->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, FALSE, NULL, subject, error->message);
return;
}
@@ -8878,7 +8878,7 @@ disconnect_cb (NMDevice *self,
local = g_error_new_literal (NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ACTIVE,
"Device is not active");
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, FALSE, subject, local->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, FALSE, NULL, subject, local->message);
g_dbus_method_invocation_take_error (context, local);
} else {
nm_device_set_autoconnect_intern (self, FALSE);
@@ -8887,7 +8887,7 @@ disconnect_cb (NMDevice *self,
NM_DEVICE_STATE_DEACTIVATING,
NM_DEVICE_STATE_REASON_USER_REQUESTED);
g_dbus_method_invocation_return_value (context, NULL);
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, TRUE, subject, NULL);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DISCONNECT, self, TRUE, NULL, subject, NULL);
}
}
@@ -8938,12 +8938,12 @@ delete_cb (NMDevice *self,
if (error) {
g_dbus_method_invocation_return_gerror (context, error);
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DELETE, self, FALSE, subject, error->message);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DELETE, self, FALSE, NULL, subject, error->message);
return;
}
/* Authorized */
- nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DELETE, self, TRUE, subject, NULL);
+ nm_audit_log_device_op (NM_AUDIT_OP_DEVICE_DELETE, self, TRUE, NULL, subject, NULL);
if (nm_device_unrealize (self, TRUE, &local))
g_dbus_method_invocation_return_value (context, NULL);
else
diff --git a/src/nm-audit-manager.c b/src/nm-audit-manager.c
index eeb9d2ba80..a78f066344 100644
--- a/src/nm-audit-manager.c
+++ b/src/nm-audit-manager.c
@@ -302,11 +302,11 @@ _nm_audit_manager_log_generic_op (NMAuditManager *self, const char *file, guint
void
_nm_audit_manager_log_device_op (NMAuditManager *self, const char *file, guint line,
const char *func, const char *op, NMDevice *device,
- gboolean result, gpointer subject_context,
+ gboolean result, const char *args, gpointer subject_context,
const char *reason)
{
gs_unref_ptrarray GPtrArray *fields = NULL;
- AuditField interface_field = { }, ifindex_field = { };
+ AuditField interface_field = { }, ifindex_field = { }, args_field = { };
int ifindex;
g_return_if_fail (op);
@@ -324,6 +324,11 @@ _nm_audit_manager_log_device_op (NMAuditManager *self, const char *file, guint l
g_ptr_array_add (fields, &ifindex_field);
}
+ if (args) {
+ _audit_field_init_string (&args_field, "args", args, FALSE, BACKEND_ALL);
+ g_ptr_array_add (fields, &args_field);
+ }
+
_audit_log_helper (self, fields, file, line, func, op, result, subject_context, reason);
}
diff --git a/src/nm-audit-manager.h b/src/nm-audit-manager.h
index 29bde1a50d..56e26584e5 100644
--- a/src/nm-audit-manager.h
+++ b/src/nm-audit-manager.h
@@ -83,13 +83,13 @@ gboolean nm_audit_manager_audit_enabled (NMAuditManager *self);
} \
} G_STMT_END
-#define nm_audit_log_device_op(op, device, result, subject_context, reason) \
+#define nm_audit_log_device_op(op, device, result, args, subject_context, reason) \
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, \
- (op), (device), (result), (subject_context), (reason)); \
+ (op), (device), (result), (args), (subject_context), (reason)); \
} \
} G_STMT_END
@@ -114,6 +114,7 @@ void _nm_audit_manager_log_generic_op (NMAuditManager *self, const char *file
void _nm_audit_manager_log_device_op (NMAuditManager *self, const char *file, guint line,
const char *func, const char *op, NMDevice *device,
- gboolean result, gpointer subject_context, const char *reason);
+ gboolean result, const char *args, gpointer subject_context,
+ const char *reason);
#endif /* __NM_AUDIT_MANAGER_H__ */