Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
68f6c229
Commit
68f6c229
authored
Apr 09, 2013
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prefer static inline functions to macros.
avoid unnecessary strlen()'s
parent
775e8263
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
39 deletions
+62
-39
sql/mysqld.cc
sql/mysqld.cc
+1
-1
sql/sql_audit.h
sql/sql_audit.h
+59
-36
sql/sql_connect.cc
sql/sql_connect.cc
+1
-1
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
No files found.
sql/mysqld.cc
View file @
68f6c229
...
...
@@ -2414,7 +2414,7 @@ void close_connection(THD *thd, uint sql_errno)
{
sleep
(
0
);
/* Workaround to avoid tailcall optimisation */
}
MYSQL_AUDIT_NOTIFY_CONNECTION_DISCONNECT
(
thd
,
sql_errno
);
mysql_audit_notify_connection_disconnect
(
thd
,
sql_errno
);
DBUG_VOID_RETURN
;
}
#endif
/* EMBEDDED_LIBRARY */
...
...
sql/sql_audit.h
View file @
68f6c229
...
...
@@ -43,10 +43,16 @@ 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
;
}
#else
static
inline
void
mysql_audit_notify
(
THD
*
thd
,
uint
event_class
,
uint
event_subtype
,
...)
{
}
#define mysql_audit_general_enabled() 0
#define mysql_audit_connection_enabled() 0
#endif
extern
void
mysql_audit_release
(
THD
*
thd
);
...
...
@@ -137,41 +143,58 @@ void mysql_audit_general(THD *thd, uint event_subtype,
}
}
#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)
static
inline
void
mysql_audit_notify_connection_connect
(
THD
*
thd
)
{
if
(
mysql_audit_connection_enabled
())
{
const
Security_context
*
sctx
=
thd
->
security_ctx
;
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
,
sctx
->
user
,
sctx
->
user
?
strlen
(
sctx
->
user
)
:
0
,
sctx
->
priv_user
,
strlen
(
sctx
->
priv_user
),
sctx
->
external_user
,
sctx
->
external_user
?
strlen
(
sctx
->
external_user
)
:
0
,
sctx
->
proxy_user
,
strlen
(
sctx
->
proxy_user
),
sctx
->
host
,
sctx
->
host
?
strlen
(
sctx
->
host
)
:
0
,
sctx
->
ip
,
sctx
->
ip
?
strlen
(
sctx
->
ip
)
:
0
,
thd
->
db
,
thd
->
db
?
strlen
(
thd
->
db
)
:
0
);
}
}
static
inline
void
mysql_audit_notify_connection_disconnect
(
THD
*
thd
,
int
errcode
)
{
if
(
mysql_audit_connection_enabled
())
{
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
);
}
}
static
inline
void
mysql_audit_notify_connection_change_user
(
THD
*
thd
)
{
if
(
mysql_audit_connection_enabled
())
{
const
Security_context
*
sctx
=
thd
->
security_ctx
;
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
,
sctx
->
user
,
sctx
->
user
?
strlen
(
sctx
->
user
)
:
0
,
sctx
->
priv_user
,
strlen
(
sctx
->
priv_user
),
sctx
->
external_user
,
sctx
->
external_user
?
strlen
(
sctx
->
external_user
)
:
0
,
sctx
->
proxy_user
,
strlen
(
sctx
->
proxy_user
),
sctx
->
host
,
sctx
->
host
?
strlen
(
sctx
->
host
)
:
0
,
sctx
->
ip
,
sctx
->
ip
?
strlen
(
sctx
->
ip
)
:
0
,
thd
->
db
,
thd
->
db
?
strlen
(
thd
->
db
)
:
0
);
}
}
#endif
/* SQL_AUDIT_INCLUDED */
sql/sql_connect.cc
View file @
68f6c229
...
...
@@ -1187,7 +1187,7 @@ bool thd_prepare_connection(THD *thd)
bool
rc
;
lex_start
(
thd
);
rc
=
login_connection
(
thd
);
MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT
(
thd
);
mysql_audit_notify_connection_connect
(
thd
);
if
(
rc
)
return
rc
;
...
...
sql/sql_parse.cc
View file @
68f6c229
...
...
@@ -1011,7 +1011,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
else
rc
=
acl_authenticate
(
thd
,
0
,
packet_length
);
MYSQL_AUDIT_NOTIFY_CONNECTION_CHANGE_USER
(
thd
);
mysql_audit_notify_connection_change_user
(
thd
);
if
(
rc
)
{
/* Free user if allocated by acl_authenticate */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment