[Commits] Rev 4110: MDEV-5681 audit log will not rotate when the file size exceeds global variable setting. in file:///home/hf/wmar/mdev-5681/

holyfoot at askmonty.org holyfoot at askmonty.org
Fri Mar 14 14:43:40 EET 2014


At file:///home/hf/wmar/mdev-5681/

------------------------------------------------------------
revno: 4110
revision-id: holyfoot at askmonty.org-20140314112450-ucom377lu2pfwldw
parent: svoj at mariadb.org-20140213074049-wo2l3qdtgi0s2mjd
committer: Alexey Botchkov <holyfoot at askmonty.org>
branch nick: mdev-5681
timestamp: Fri 2014-03-14 15:24:50 +0400
message:
  MDEV-5681 audit log will not rotate when the file size exceeds global variable setting.
       Notifications about changed variables:
                  server_audit_file_rotate_now
                  server_audit_file_rotations
                  server_audit_file_rotations
       are now handled and one doesn't need to stop/start logging to make them effective.
-------------- next part --------------
=== modified file 'plugin/server_audit/server_audit.c'
--- a/plugin/server_audit/server_audit.c	2014-02-24 19:40:16 +0000
+++ b/plugin/server_audit/server_audit.c	2014-03-14 11:24:50 +0000
@@ -172,6 +172,10 @@ static char default_file_name[DEFAULT_FI
 
 static void update_file_path(MYSQL_THD thd, struct st_mysql_sys_var *var,
                              void *var_ptr, const void *save);
+static void update_file_rotate_size(MYSQL_THD thd, struct st_mysql_sys_var *var,
+                                    void *var_ptr, const void *save);
+static void update_file_rotations(MYSQL_THD thd, struct st_mysql_sys_var *var,
+                                  void *var_ptr, const void *save);
 static void update_incl_users(MYSQL_THD thd, struct st_mysql_sys_var *var,
                               void *var_ptr, const void *save);
 static void update_excl_users(MYSQL_THD thd, struct st_mysql_sys_var *var,
@@ -230,11 +234,11 @@ static MYSQL_SYSVAR_STR(file_path, file_
        "Path to the log file.", NULL, update_file_path, default_file_name);
 static MYSQL_SYSVAR_ULONGLONG(file_rotate_size, file_rotate_size,
        PLUGIN_VAR_RQCMDARG, "Maximum size of the log to start the rotation.",
-       NULL, NULL,
+       NULL, update_file_rotate_size,
        1000000, 100, ((long long) 0x7FFFFFFFFFFFFFFFLL), 1);
 static MYSQL_SYSVAR_UINT(file_rotations, rotations,
        PLUGIN_VAR_RQCMDARG, "Number of rotations before log is removed.",
-       NULL, NULL, 9, 0, 999, 1);
+       NULL, update_file_rotations, 9, 0, 999, 1);
 static MYSQL_SYSVAR_BOOL(file_rotate_now, rotate, PLUGIN_VAR_OPCMDARG,
        "Force log rotation now.", NULL, rotate_log, FALSE);
 static MYSQL_SYSVAR_BOOL(logging, logging,
@@ -1680,6 +1684,41 @@ static void update_file_path(MYSQL_THD t
 }
 
 
+static void update_file_rotations(MYSQL_THD thd  __attribute__((unused)),
+              struct st_mysql_sys_var *var  __attribute__((unused)),
+              void *var_ptr  __attribute__((unused)), const void *save)
+{
+  rotations= *(unsigned int *) save;
+  error_header();
+  fprintf(stderr, "Log file rotations was changed to '%d'.\n", rotations);
+
+  if (!logging || output_type != OUTPUT_FILE)
+    return;
+
+  flogger_mutex_lock(&lock_operations);
+  logfile->rotations= rotations;
+  flogger_mutex_unlock(&lock_operations);
+}
+
+
+static void update_file_rotate_size(MYSQL_THD thd  __attribute__((unused)),
+              struct st_mysql_sys_var *var  __attribute__((unused)),
+              void *var_ptr  __attribute__((unused)), const void *save)
+{
+  file_rotate_size= *(unsigned long long *) save;
+  error_header();
+  fprintf(stderr, "Log file rotate size was changed to '%lld'.\n",
+          file_rotate_size);
+
+  if (!logging || output_type != OUTPUT_FILE)
+    return;
+
+  flogger_mutex_lock(&lock_operations);
+  logfile->size_limit= file_rotate_size;
+  flogger_mutex_unlock(&lock_operations);
+}
+
+
 static void update_incl_users(MYSQL_THD thd,
               struct st_mysql_sys_var *var  __attribute__((unused)),
               void *var_ptr  __attribute__((unused)), const void *save)
@@ -1828,8 +1868,15 @@ static void update_syslog_ident(MYSQL_TH
   strncpy(syslog_ident_buffer, *(const char **) save,
           sizeof(syslog_ident_buffer));
   syslog_ident= syslog_ident_buffer;
+  error_header();
+  fprintf(stderr, "SYSYLOG ident was changed to '%s'\n", syslog_ident);
   flogger_mutex_lock(&lock_operations);
   mark_always_logged(thd);
+  if (logging && output_type == OUTPUT_SYSLOG)
+  {
+    stop_logging();
+    start_logging();
+  }
   flogger_mutex_unlock(&lock_operations);
 }
 



More information about the commits mailing list