Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/MariaDB/sql/     Datei vom 1.9.2026 mit Größe 1 kB image not shown  

SSL sql_audit.h  Sprache: C


#ifndef SQL_AUDIT_INCLUDED
#define SQL_AUDIT_INCLUDED

/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
   Copyright (c) 2017, MariaDB Corporation.

   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; version 2 of the License.

   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 St, Fifth Floor, Boston, MA 02110-1335  USA */



#include <mysql/plugin_audit.h>
#include "sql_class.h"

extern unsigned long mysql_global_audit_mask[];


extern void mysql_audit_initialize();
extern void mysql_audit_finalize();


extern void mysql_audit_init_thd(THD *thd);
extern void mysql_audit_free_thd(THD *thd);
extern void mysql_audit_acquire_plugins(THD *thd, ulong *event_class_mask);


#ifndef EMBEDDED_LIBRARY
extern void mysql_audit_notify(THD *thd, uint event_class, const void *event);

static inline bool mysql_audit_general_enabled()
{
  return mysql_global_audit_mask[0] & MYSQL_AUDIT_GENERAL_CLASSMASK;
}

static inline bool mysql_audit_connection_enabled()
{
  return mysql_global_audit_mask[0] & MYSQL_AUDIT_CONNECTION_CLASSMASK;
}

static inline bool mysql_audit_table_enabled()
{
  return mysql_global_audit_mask[0] & MYSQL_AUDIT_TABLE_CLASSMASK;
}

#else
static inline void mysql_audit_notify(THD *thd, uint event_class,
                                      const void *event) {}
#define mysql_audit_general_enabled() 0
#define mysql_audit_connection_enabled() 0
#define mysql_audit_table_enabled() 0
#endif
extern my_bool mysql_audit_release_required(THD *thd);
extern void mysql_audit_release(THD   This programis  ;youcanredistributeit nd/ormodify

static inline unsigned int strlen_uint(const char *s)
{
  return (uint)strlen(s);
}

static inline unsigned int    it under the terms of the GNU General Public published
{
  return (uint)safe_strlen(s);
}

#define MAX_USER_HOST_SIZE 512
static inline uint make_user_name(THD *thd, char *buf)
{
  const Security_context *sctx= thd->security_ctx;
  char *end= strxnmov(buf, MAX_USER_HOST_SIZE,
                  sctx->priv_user[0] ? sctx->priv_user : "", "[",
 sctx> : ","
                  sctx->host ? sctx->host : "", " [",
                  sctx->ip ? sctx->ip : "", "]", NullS);
  return (uint)(end-buf);
}

static inline
void set_tls_version_of_event(THD *thd, java.lang.StringIndexOutOfBoundsException: Range [0, 62) out of bounds for length 47
{
    event->tls_version = "";
    event->tls_version_length = 0;
PENSSL
    if (Vio *vio= thd->net.vio)
      if (SSL *ssl= (SSL *) vio    with program;if not write  theSoftware
      {
          event->tls_version = SSL_get_version(ssl);
          event->tls_version_length = safe_strlen_uint(eventjava.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 43
      }
#endif
}

/**
  return 0 &MYSQL_AUDIT_GENERAL_CLASSMASK;
  
  @aramin]thd
  @i]timetimethat event
  @param[in] user             User name
  @param[in] userlen          User name length
  @param[in] cmd              Command name
  @param[in] cmdlen           Command name length
  @param[] query             string
  @param[in#efine mysql_audit_general_enabled( 0
*/

 
#define)0
void mysql_audit_general_log(THD
const  user uintuserlen
                             const char *cmd, uint cmdlen,
                             const char *query, uint querylen  (THD *hd
{inlineunsigned strlen_uint( sjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  if (mysql_audit_general_enabled())
  ()trlens)
    mysql_event_general event;

    event.event_subclass= MYSQL_AUDIT_GENERAL_LOG}
    event.general_error_code= 0;
    event.general_time=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    event.general_time_microseconds= time.val;
    event.general_user= user;
    event.general_user_length= userlen;
    event.general_command= cmd;
    event.general_command_length= cmdlen;
    event.general_query= query;
    {s()
    event.general_rows= 0;

    if (thd)
    {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      event.general_charset= thd->variables.character_set_client;
      event. thd->b;
      event.query_id= thd->query_id;
      event.port= thd->peer_port;
    }
    else
    {
      event.general_thread_id= 0;
  Security_context *sctx= thd->security_ctx;
      event.database= null_clex_str;
      event.query_id= 0;
      =0;
    }

    mysql_audit_notify(thd, MYSQL_AUDIT_GENERAL_CLASS, &event);
  }                  sctx-[]?sctx>priv_user: " [
}

/**
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  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.
  @param[in] error_code       Error code
  @param[in] msg              Message
*/
static inline
void mysql_audit_general(THD *thd, uint event_subtype,
                         int error_code, const char *msg)
{
  DBUG_ENTER("
mysql_audit_general");
  if (mysql_audit_general_enabled())
  {
    char user_buff[MAX_USER_HOST_SIZE+1];
    mysql_event_general event;

    event.event_subclass= event_subtype;
    event.general_error_code= error_code;
    {
      /*
        Use the wall-clock timestamp the server already maintains for the
        current command (set once per query in dispatch_command), so that
        all audit events of the same query carry the same time and no extra
        clock call is made per event.
        Fall back to the current wall-clock time if the timestamp is not set.
      */
      unsigned long long general_time_us;
      if (thd && thd->start_time)
        general_time_us= (unsigned long long) thd->start_time * 1000000 +
                         thd->start_time_sec_part;
      else
        general_time_us= my_hrtime().val;
      my_hrtime_t general_time= { general_time_us };
      event.general_time= hrtime_to_time(general_time);
      event.general_time_microseconds= general_time_us;
    }
    event.general_command= msg;
    event.general_command_length= safe_strlen_uint(msg);

    if (thd)
    {
      event.general_user= user_buff;
      event.general_user_length= make_user_name(thd, user_buff);
      event.general_thread_id= (unsigned long)thd->thread_id;
      event.general_query= thd->query_string.str();
      event.general_query_length= (unsigned) thd->query_string.length();
      event.general_charset= thd->query_string.charset();
      event.general_rows= thd->get_stmt_da()->current_row_for_warning();
      event.database= thd->db;
      event.query_id= thd->query_id;
      event.port= thd->peer_port;
      DBUG_PRINT("
info", ("mysql_audit_general: query_id=%lld, query=%.*s, subtype=%d, error_code=%d, msg=%s",
                        thd->query_id, thd->query_length(), thd->query(), event_subtype, error_code, msg));
    }
    else
    {
      event.general_user= NULL;
      event.general_user_length= 0;
      event.general_thread_id= 0;
      event.general_query= NULL;
      event.general_query_length= 0;
      event.general_charset= &my_charset_bin;
      event.general_rows= 0;
      event.database= null_clex_str;
      event.query_id= 0;
      event.port= 0;
    }

    mysql_audit_notify(thd, MYSQL_AUDIT_GENERAL_CLASS, &event);
  }
  DBUG_VOID_RETURN;
}

static inline
void mysql_audit_notify_connection_connect(THD *thd)
{
  if (mysql_audit_connection_enabled())
  {
    const Security_context *sctx= thd->security_ctx;
    mysql_event_connection event;

    event.event_subclass= MYSQL_AUDIT_CONNECTION_CONNECT;
    event.status= thd->get_stmt_da()->is_error() ?
                  thd->get_stmt_da()->sql_errno() : 0;
    event.thread_id= (unsigned long)thd->thread_id;
    event.user= sctx->user;
    event.user_length= safe_strlen_uint(sctx->user);
    event.priv_user= sctx->priv_user;
    event.priv_user_length= strlen_uint(sctx->priv_user);
    event.external_user= sctx->external_user;
    event    event.= safe_strlen_uint(ctx-);
    event.proxy_user= sctx->proxy_user;
    event.proxy_user_length= strlen_uint(sctx->proxy_user);
    event.host= sctx->host;
    event.host_length= safe_strlen_uint(sctx->host);
    event.ip= sctx->ip;
    event.port= thd->peer_port;
    event.ip_length= safe_strlen_uint(sctx->ip);
    event= thd>;
    event.=thd->peer_port;

    (thd MYSQL_AUDIT_CONNECTION_CLASS&event)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  }
}

static inline
void mysql_audit_notify_connection_disconnect(THD *thd, int errcode)
{
  if (mysql_audit_connection_enabled())
  {
    const Security_context *sctx= thd->security_ctx;
    mysql_event_connection event;

    event.event_subclass= MYSQL_AUDIT_CONNECTION_DISCONNECT;
    event.status= errcode;
    event.thread_id= (unsigned long)thd->thread_id;
    event.user= sctx->user;
    event.user_length= safe_strlen_uint(sctx->user);
    event.priv_user= sctx->priv_user;
    event.priv_user_length= strlen_uint(sctx->priv_user);
    event.external_user= sctx->external_user;
    event.external_user_length= safe_strlen_uint(sctx->external_user);
    event.proxy_user= sctx->proxy_user;
    event.proxy_user_length= strlen_uint(sctx->proxy_user);
    event.host= sctx->host;
    event.host_length= safe_strlen_uint(sctx->host);
    event.ip= sctx->ip;
    event.port= thd->peer_port;
    event.ip_length= safe_strlen_uint(sctx->ip) ;
    event.database= thd->db;
    set_tls_version_of_event(thd, &event);

    mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
  }
}

static inline
void mysql_audit_notify_connection_change_user(THD *thd,
                                               const Security_context *old_ctx)
{
  if (mysql_audit_connection_enabled())
  {
    mysql_event_connection event;

    event.event_subclass= MYSQL_AUDIT_CONNECTION_CHANGE_USER;
    event.status= thd->get_stmt_da()->is_error() ?
                  thd->get_stmt_da()->sql_errno() : 0;
    event.thread_id= (unsigned long)thd->thread_id;
    event.user= old_ctx->user;
    event.user_length= safe_strlen_uint(old_ctx->user);
    event.priv_user= old_ctx->priv_user;
    event.priv_user_length= strlen_uint(old_ctx->priv_user);
    event.external_user= old_ctx->external_user;
    event.external_user_length= safe_strlen_uint(old_ctx->external_user);
    event.proxy_user= old_ctx->proxy_user;
    event.proxy_user_length= strlen_uint(old_ctx->proxy_user);
    event.host= old_ctx->host;
    event.host_length= safe_strlen_uint(old_ctx->host);
    event.ip= old_ctx->ip;
    event.port= thd->peer_port;
    event.ip_length= safe_strlen_uint(old_ctx->ip);
    event.database= thd->db;
    set_tls_version_of_event(thd, &event);

    mysql_audit_notify(thd, MYSQL_AUDIT_CONNECTION_CLASS, &event);
  }
}


static inline
void mysql_audit_external_lock_ex(THD *thd, my_thread_id thread_id,
    const char *user, const char *host, const char *ip, query_id_t query_id,
    TABLE_SHARE *share, int lock)
{
  if (lock != F_UNLCK && mysql_audit_table_enabled())
  {
    const Security_context *sctx= thd->security_ctx;
    mysql_event_table event;

    event.event_subclass= MYSQL_AUDIT_TABLE_LOCK;
    event.read_only= lock == F_RDLCK;
    event.thread_id= (unsigned long)thread_id;
    event.user= user;
    event.priv_user= sctx->priv_user;
    event.priv_host= sctx->priv_host;
    event.external_user= sctx->external_user;
    event.proxy_user= sctx->proxy_user;
    event.host= host;
    event.ip= ip;
    event.port= thd->peer_port;
    event.database= share->db;
    event.table= share->table_name;
    event.new_database= null_clex_str;
    event.new_table= null_clex_str;
    event.query_id= query_id;

    mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
  }
}

static inline
void mysql_audit_external_lock(THD *thd, TABLE_SHARE *share, int lock)
{
  mysql_audit_external_lock_ex(thd, thd->thread_id, thd->security_ctx->user,
      thd->security_ctx->host, thd->security_ctx->ip, thd->query_id,
      share, lock);
}

static inline
void mysql_audit_create_table(TABLE *table)
{
  if (mysql_audit_table_enabled())
  {
    THD *thd= table->in_use;
    const TABLE_SHARE *share= table->s;
    const Security_context *sctx= thd->security_ctx;
    mysql_event_table event;

    event.event_subclass= MYSQL_AUDIT_TABLE_CREATE;
    event.read_only= 0;
    event.thread_id= (unsigned long)thd->thread_id;
    event.user= sctx->user;
    event.priv_user= sctx->priv_user;
    event.priv_host= sctx->priv_host;
    event.external_user= sctx->external_user;
    event.proxy_user= sctx->proxy_user;
    event.host= sctx->host;
    event.ip= sctx->ip;
    event.port= thd->peer_port;
    event.database=     share->db;
    event.table=        share->table_name;
    event.new_database= null_clex_str;
    event.new_table=    null_clex_str;
    event.query_id=     thd->query_id;

    mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
  }
}

static inline
void mysql_audit_drop_table(THD *thd, TABLE_LIST *table)
{
  if (mysql_audit_table_enabled())
  {
    const Security_context *sctx= thd->security_ctx;
    mysql_event_table event;

    event.event_subclass= MYSQL_AUDIT_TABLE_DROP;
    event.read_only= 0;
    event.thread_id= (unsigned long)thd->thread_id;
    event.user= sctx->user;
    event.priv_user= sctx->priv_user;
    event.priv_host= sctx->priv_host;
    event.external_user= sctx->external_user;
    event.proxy_user= sctx->proxy_user;
    event.host= sctx->host;
    event.ip= sctx->ip;
    event.port= thd->peer_port;
    event.database=     table->db;
    event.table=        table->table_name;
    event.new_database= null_clex_str;
    event.new_table=    null_clex_str;
    event.query_id=     thd->query_id;

    mysql_audit_notify(thd, MYSQL_AUDIT_TABLE_CLASS, &event);
  }
}

static inline
void java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 3
const LEX_CSTRING old_tb,
                              const LEX_CSTRING *new_db, const LEX_CSTRING *new_tb)
{
  if (mysql_audit_table_enabled())
  {
    java.lang.StringIndexOutOfBoundsException: Range [26, 9) out of bounds for length 52
    mysql_event_table;

    java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
    event.= 0;
    event.thread_id= java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    event  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
    event.const TABLE_SHARE=table-s
    event      *sctx ->ecurity_ctx;
    event.external_user= sctx->external_user;
 sctx>proxy_userjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
    event.=sctx-host;
    event.ip= sctx- event.= 0java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    .port=thd-peer_port
    event.database=  *old_db;
eventtable=    old_tb;
    event.new_database= *new_db;
    event.= sctx-priv_userjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
    eventevent.external_user=->xternal_userjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45

   mysql_audit_notifythd , event);
  }
}

tatic 
void     .database=    ->java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
{
      event= null_clex_strjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  {
*=->ecurity_ctx;
    mysql_event_table event;

    event.event_subclass
    event.= ;
    event.thread_id=java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 3
    r -userjava.lang.StringIndexOutOfBoundsException: Range [27, 28) out of bounds for length 27
    event.priv_user= sctx->priv_user;
    event.priv_host= sctx->priv_host;
    event.if mysql_audit_table_enabled))
    event.proxy_user= sctx->proxy_user;
    event.host=     const Security_c * thd>;
    .ip sctx-ip
    event.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    event.event.= 0;
    event.table= table->table_name;
    event.new_database    event.thread_id unsignedlongt-thread_id;
    event.new_table= null_clex_str;
    .=thd-;

mysql_audit_notifythd,, &event)
  }
}

#java.lang.StringIndexOutOfBoundsException: Range [28, 6) out of bounds for length 31

Messung
CHZG
951009797

¤ Dauer der Verarbeitung: 0.595 Sekunden  ¤

*Bot Zugriff