diff options
author | Eugene Kosov <claprix@yandex.ru> | 2019-07-09 13:22:22 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2019-07-09 13:22:22 +0300 |
commit | 26c389b7b770a3699ec1fc81df7f379f6084c9e6 (patch) | |
tree | 7f915e858b211834deeb52928dfdf5ab12b24bfe /plugin | |
parent | b9557418ccd9f484806515fba030757274e691f2 (diff) | |
parent | fd08f953222b854428dc259631e8fc707fe34619 (diff) | |
download | mariadb-git-26c389b7b770a3699ec1fc81df7f379f6084c9e6.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/server_audit/server_audit.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index f5277b71167..e21a0aedb85 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -27,8 +27,13 @@ #include <assert.h> #ifndef _WIN32 +#define DO_SYSLOG #include <syslog.h> +static const char out_type_desc[]= "Desired output type. Possible values - 'syslog', 'file'" + " or 'null' as no output."; #else +static const char out_type_desc[]= "Desired output type. Possible values - 'file'" + " or 'null' as no output."; #define syslog(PRIORITY, FORMAT, INFO, MESSAGE_LEN, MESSAGE) do {}while(0) static void closelog() {} #define openlog(IDENT, LOG_NOWAIT, LOG_USER) do {}while(0) @@ -88,6 +93,7 @@ static void closelog() {} #include <typelib.h> #include <mysql/plugin.h> #include <mysql/plugin_audit.h> +#include "../../mysys/mysys_priv.h" #ifndef RTLD_DEFAULT #define RTLD_DEFAULT NULL #endif @@ -385,18 +391,28 @@ static MYSQL_SYSVAR_SET(events, events, PLUGIN_VAR_RQCMDARG, "Specifies the set of events to monitor. Can be CONNECT, QUERY, TABLE," " QUERY_DDL, QUERY_DML, QUERY_DML_NO_SELECT, QUERY_DCL.", NULL, NULL, 0, &events_typelib); +#ifdef DO_SYSLOG #define OUTPUT_SYSLOG 0 #define OUTPUT_FILE 1 +#else +#define OUTPUT_SYSLOG 0xFFFF +#define OUTPUT_FILE 0 +#endif /*DO_SYSLOG*/ + #define OUTPUT_NO 0xFFFF -static const char *output_type_names[]= { "syslog", "file", 0 }; +static const char *output_type_names[]= { +#ifdef DO_SYSLOG + "syslog", +#endif + "file", 0 }; static TYPELIB output_typelib= { array_elements(output_type_names) - 1, "output_typelib", output_type_names, NULL }; static MYSQL_SYSVAR_ENUM(output_type, output_type, PLUGIN_VAR_RQCMDARG, - "Desired output type. Possible values - 'syslog', 'file'" - " or 'null' as no output.", 0, update_output_type, OUTPUT_FILE, + out_type_desc, + 0, update_output_type, OUTPUT_FILE, &output_typelib); static MYSQL_SYSVAR_STR(file_path, file_path, PLUGIN_VAR_RQCMDARG, "Path to the log file.", NULL, update_file_path, default_file_name); @@ -1135,6 +1151,7 @@ static void setup_connection_connect(struct connection_info *cn, #define SAFE_STRLEN(s) (s ? strlen(s) : 0) +#define SAFE_STRLEN_UI(s) ((unsigned int) (s ? strlen(s) : 0)) static char empty_str[1]= { 0 }; @@ -1294,7 +1311,7 @@ exit: static size_t log_header(char *message, size_t message_len, time_t *ts, - const char *serverhost, unsigned int serverhost_len, + const char *serverhost, size_t serverhost_len, const char *username, unsigned int username_len, const char *host, unsigned int host_len, const char *userip, unsigned int userip_len, @@ -1312,7 +1329,7 @@ static size_t log_header(char *message, size_t message_len, if (output_type == OUTPUT_SYSLOG) return my_snprintf(message, message_len, "%.*s,%.*s,%.*s,%d,%lld,%s", - serverhost_len, serverhost, + (unsigned int) serverhost_len, serverhost, username_len, username, host_len, host, connection_id, query_id, operation); @@ -1791,9 +1808,9 @@ static int log_table(const struct connection_info *cn, (void) time(&ctime); csize= log_header(message, sizeof(message)-1, &ctime, servhost, servhost_len, - event->user, (unsigned int)SAFE_STRLEN(event->user), - event->host, (unsigned int)SAFE_STRLEN(event->host), - event->ip, (unsigned int)SAFE_STRLEN(event->ip), + event->user, SAFE_STRLEN_UI(event->user), + event->host, SAFE_STRLEN_UI(event->host), + event->ip, SAFE_STRLEN_UI(event->ip), event->thread_id, cn->query_id, type); csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize, ",%.*s,%.*s,",event->database_length, event->database, @@ -1813,9 +1830,9 @@ static int log_rename(const struct connection_info *cn, (void) time(&ctime); csize= log_header(message, sizeof(message)-1, &ctime, servhost, servhost_len, - event->user, (unsigned int)SAFE_STRLEN(event->user), - event->host, (unsigned int)SAFE_STRLEN(event->host), - event->ip, (unsigned int)SAFE_STRLEN(event->ip), + event->user, SAFE_STRLEN_UI(event->user), + event->host, SAFE_STRLEN_UI(event->host), + event->ip, SAFE_STRLEN_UI(event->ip), event->thread_id, cn->query_id, "RENAME"); csize+= my_snprintf(message+csize, sizeof(message) - 1 - csize, ",%.*s,%.*s|%.*s.%.*s,",event->database_length, event->database, |