summaryrefslogtreecommitdiff
path: root/sql/sql_audit.h
diff options
context:
space:
mode:
authorSergey Vojtovich <sergey.vojtovich@oracle.com>2010-12-14 17:34:23 +0300
committerSergey Vojtovich <sergey.vojtovich@oracle.com>2010-12-14 17:34:23 +0300
commit9a3e46c520e857c9e32eebc612fe00991dcc5fe3 (patch)
treea01ebb52ef2a45d385cf45850e61c8b584256240 /sql/sql_audit.h
parentb7b33fd9d6bfe683d6c3d96742aca57282a20d45 (diff)
downloadmariadb-git-9a3e46c520e857c9e32eebc612fe00991dcc5fe3.tar.gz
WL#5571 - Audit interface: MYSQL_AUDIT_GENERAL_STATUS event
include/mysql/plugin_audit.h: Connection auditing class. include/mysql/plugin_audit.h.pp: Connection auditing class. sql/mysqld.cc: Notify disconnect to auditing. sql/sql_audit.cc: Connection class event dispatcher. sql/sql_audit.h: mysql_audit_notify() is not available in embedded. sql/sql_connect.cc: Notify connect to auditing. sql/sql_parse.cc: Notify user change to auditing.
Diffstat (limited to 'sql/sql_audit.h')
-rw-r--r--sql/sql_audit.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/sql/sql_audit.h b/sql/sql_audit.h
index cbc4c7a7232..d676c3974bc 100644
--- a/sql/sql_audit.h
+++ b/sql/sql_audit.h
@@ -32,8 +32,12 @@ extern void mysql_audit_free_thd(THD *thd);
extern void mysql_audit_acquire_plugins(THD *thd, uint event_class);
+#ifndef EMBEDDED_LIBRARY
extern void mysql_audit_notify(THD *thd, uint event_class,
uint event_subtype, ...);
+#else
+#define mysql_audit_notify(...)
+#endif
extern void mysql_audit_release(THD *thd);
#define MAX_USER_HOST_SIZE 512
@@ -84,6 +88,7 @@ void mysql_audit_general_log(THD *thd, time_t time,
event_subtype should be set to one of:
MYSQL_AUDIT_GENERAL_ERROR
MYSQL_AUDIT_GENERAL_RESULT
+ MYSQL_AUDIT_GENERAL_STATUS
@param[in] thd
@param[in] event_subtype Type of general audit event.
@@ -126,5 +131,41 @@ void mysql_audit_general(THD *thd, uint event_subtype,
#endif
}
+#define MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd) mysql_audit_notify(\
+ (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_CONNECT,\
+ (thd)->stmt_da->is_error() ? (thd)->stmt_da->sql_errno() : 0,\
+ (thd)->thread_id, (thd)->security_ctx->user,\
+ (thd)->security_ctx->user ? strlen((thd)->security_ctx->user) : 0,\
+ (thd)->security_ctx->priv_user, strlen((thd)->security_ctx->priv_user),\
+ (thd)->security_ctx->external_user,\
+ (thd)->security_ctx->external_user ?\
+ strlen((thd)->security_ctx->external_user) : 0,\
+ (thd)->security_ctx->proxy_user, strlen((thd)->security_ctx->proxy_user),\
+ (thd)->security_ctx->host,\
+ (thd)->security_ctx->host ? strlen((thd)->security_ctx->host) : 0,\
+ (thd)->security_ctx->ip,\
+ (thd)->security_ctx->ip ? strlen((thd)->security_ctx->ip) : 0,\
+ (thd)->db, (thd)->db ? strlen((thd)->db) : 0)
+
+#define MYSQL_AUDIT_NOTIFY_CONNECTION_DISCONNECT(thd, errcode)\
+ mysql_audit_notify(\
+ (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_DISCONNECT,\
+ (errcode), (thd)->thread_id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+
+#define MYSQL_AUDIT_NOTIFY_CONNECTION_CHANGE_USER(thd) mysql_audit_notify(\
+ (thd), MYSQL_AUDIT_CONNECTION_CLASS, MYSQL_AUDIT_CONNECTION_CHANGE_USER,\
+ (thd)->stmt_da->is_error() ? (thd)->stmt_da->sql_errno() : 0,\
+ (thd)->thread_id, (thd)->security_ctx->user,\
+ (thd)->security_ctx->user ? strlen((thd)->security_ctx->user) : 0,\
+ (thd)->security_ctx->priv_user, strlen((thd)->security_ctx->priv_user),\
+ (thd)->security_ctx->external_user,\
+ (thd)->security_ctx->external_user ?\
+ strlen((thd)->security_ctx->external_user) : 0,\
+ (thd)->security_ctx->proxy_user, strlen((thd)->security_ctx->proxy_user),\
+ (thd)->security_ctx->host,\
+ (thd)->security_ctx->host ? strlen((thd)->security_ctx->host) : 0,\
+ (thd)->security_ctx->ip,\
+ (thd)->security_ctx->ip ? strlen((thd)->security_ctx->ip) : 0,\
+ (thd)->db, (thd)->db ? strlen((thd)->db) : 0)
#endif /* SQL_AUDIT_INCLUDED */