76 changed files with 934 additions and 435 deletions
-
1.gitignore
-
6client/mysqladmin.cc
-
3extra/CMakeLists.txt
-
77extra/mysqld_safe_helper.c
-
4include/my_sys.h
-
7mysql-test/r/create.result
-
2mysql-test/r/ctype_ucs2_def.result
-
2mysql-test/r/ctype_ucs2_query_cache.result
-
2mysql-test/r/ctype_utf16_def.result
-
13mysql-test/r/events_slowlog.result
-
6mysql-test/r/func_time.result
-
29mysql-test/r/index_merge_innodb.result
-
8mysql-test/r/information_schema_part.result
-
16mysql-test/r/join_cache.result
-
27mysql-test/r/loaddata.result
-
2mysql-test/r/log_slow.result
-
11mysql-test/r/order_by.result
-
11mysql-test/r/subselect.result
-
45mysql-test/r/subselect2.result
-
39mysql-test/r/subselect4.result
-
11mysql-test/r/subselect_no_exists_to_in.result
-
11mysql-test/r/subselect_no_mat.result
-
11mysql-test/r/subselect_no_opts.result
-
11mysql-test/r/subselect_no_scache.result
-
11mysql-test/r/subselect_no_semijoin.result
-
33mysql-test/r/union.result
-
1mysql-test/std_data/bug20683959loaddata.txt
-
1mysql-test/suite/engines/iuds/r/insert_decimal.result
-
1mysql-test/suite/funcs_2/t/innodb_charset.test
-
37mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result
-
2mysql-test/suite/rpl/r/rpl_special_charset.result
-
120mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
-
2mysql-test/suite/rpl/t/rpl_special_charset.test
-
9mysql-test/t/create.test
-
2mysql-test/t/ctype_ucs2_def.test
-
2mysql-test/t/ctype_ucs2_query_cache.test
-
2mysql-test/t/ctype_utf16_def.test
-
28mysql-test/t/events_slowlog.test
-
5mysql-test/t/func_time.test
-
33mysql-test/t/index_merge_innodb.test
-
7mysql-test/t/information_schema_part.test
-
10mysql-test/t/join_cache.test
-
24mysql-test/t/loaddata.test
-
2mysql-test/t/log_slow.test
-
10mysql-test/t/order_by.test
-
10mysql-test/t/subselect.test
-
50mysql-test/t/subselect2.test
-
41mysql-test/t/subselect4.test
-
22mysql-test/t/union.test
-
8mysql-test/valgrind.supp
-
2mysys/CMakeLists.txt
-
82mysys/my_setuser.c
-
1plugin/server_audit/server_audit.c
-
108scripts/mysqld_safe.sh
-
15sql/event_db_repository.cc
-
15sql/field.cc
-
2sql/filesort.cc
-
2sql/handler.cc
-
41sql/item.cc
-
15sql/item_subselect.cc
-
5sql/item_timefunc.cc
-
110sql/mysqld.cc
-
2sql/signal_handler.cc
-
22sql/sp_head.cc
-
13sql/sql_connect.cc
-
6sql/sql_lex.cc
-
14sql/sql_load.cc
-
24sql/sql_parse.cc
-
1sql/sql_parse.h
-
23sql/sql_select.cc
-
5sql/sql_select.h
-
8sql/sql_table.cc
-
6sql/sql_udf.cc
-
8sql/sql_yacc.yy
-
3sql/sys_vars.cc
-
8support-files/mysql.server.sh
@ -0,0 +1,77 @@ |
|||
#include <my_global.h> |
|||
#include <m_string.h> |
|||
#include <my_sys.h> |
|||
#include <my_pthread.h> |
|||
#ifdef HAVE_PWD_H |
|||
#include <pwd.h> |
|||
#endif |
|||
#include <stdlib.h> |
|||
#include <stdio.h> |
|||
|
|||
void my_exit(int c) |
|||
{ |
|||
my_end(0); |
|||
exit(c); |
|||
} |
|||
|
|||
void do_usage() |
|||
{ |
|||
printf("Usage:\n" |
|||
" %s <user> log <filename>\n" |
|||
" %s <user> exec <command> <args>\n", |
|||
my_progname, my_progname); |
|||
my_exit(1); |
|||
} |
|||
|
|||
void do_log(const char *logfile) |
|||
{ |
|||
FILE *f; |
|||
uchar buf[4096]; |
|||
int size; |
|||
|
|||
if (!logfile) |
|||
do_usage(); |
|||
|
|||
f= my_fopen(logfile, O_WRONLY|O_APPEND|O_CREAT, MYF(MY_WME)); |
|||
if (!f) |
|||
my_exit(1); |
|||
|
|||
while ((size= my_fread(stdin, buf, sizeof(buf), MYF(MY_WME))) > 0) |
|||
if ((int)my_fwrite(f, buf, size, MYF(MY_WME)) != size) |
|||
my_exit(1); |
|||
|
|||
my_fclose(f, MYF(0)); |
|||
my_exit(0); |
|||
} |
|||
|
|||
void do_exec(char *args[]) |
|||
{ |
|||
if (!args[0]) |
|||
do_usage(); |
|||
|
|||
my_end(0); |
|||
execvp(args[0], args); |
|||
} |
|||
|
|||
int main(int argc, char *argv[]) |
|||
{ |
|||
struct passwd *user_info; |
|||
MY_INIT(argv[0]); |
|||
|
|||
if (argc < 3) |
|||
do_usage(argv[0]); |
|||
|
|||
user_info= my_check_user(argv[1], MYF(0)); |
|||
if (user_info ? my_set_user(argv[1], user_info, MYF(MY_WME)) |
|||
: my_errno == EINVAL) |
|||
my_exit(1); |
|||
|
|||
if (strcmp(argv[2], "log") == 0) |
|||
do_log(argv[3]); |
|||
|
|||
if (strcmp(argv[2], "exec") == 0) |
|||
do_exec(argv+3); |
|||
|
|||
my_end(0); |
|||
return 1; |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
set @event_scheduler_save= @@global.event_scheduler; |
|||
set @slow_query_log_save= @@global.slow_query_log; |
|||
set global event_scheduler= on; |
|||
set global slow_query_log= on; |
|||
set global long_query_time=0.2; |
|||
create table t1 (i int); |
|||
insert into t1 values (0); |
|||
create event ev on schedule at CURRENT_TIMESTAMP + INTERVAL 1 second do update t1 set i=1+sleep(0.5); |
|||
FOUND /update t1 set i=1/ in mysqld-slow.log |
|||
drop table t1; |
|||
set global event_scheduler= @event_scheduler_save; |
|||
set global slow_query_log= @slow_query_log_save; |
|||
set global long_query_time= @@session.long_query_time; |
|||
@ -1 +0,0 @@ |
|||
Ã"RT @niouzechun: 遘√����繝上ャ繝斐����繧ィ繝ウ繝牙耳縺ェ繧薙□縺代l縺ゥ縲√い繝ウ繝上ャ繝斐����繧ィ繝ウ繝峨d諠ィ蜉����噪縺ェ縺願ゥア繧偵≠縺セ繧顔ゥ肴・オ逧����↓鞫ょ叙縺励↑縺����炊逕ア縺ッ縲∫樟螳溘����莠コ逕溘����蝓コ譛ャ逧����↓縺����∪縺上>縺九↑縺����@荳榊ケウ遲峨□縺礼炊荳榊ース縺�縺苓セ帙> |
|||
@ -0,0 +1,28 @@ |
|||
--source include/not_embedded.inc |
|||
# |
|||
# MDEV-11552 Queries executed by event scheduler are written to slow log incorrectly or not written at all |
|||
# |
|||
set @event_scheduler_save= @@global.event_scheduler; |
|||
set @slow_query_log_save= @@global.slow_query_log; |
|||
|
|||
set global event_scheduler= on; |
|||
set global slow_query_log= on; |
|||
set global long_query_time=0.2; |
|||
|
|||
create table t1 (i int); |
|||
insert into t1 values (0); |
|||
create event ev on schedule at CURRENT_TIMESTAMP + INTERVAL 1 second do update t1 set i=1+sleep(0.5); |
|||
|
|||
--let wait_condition= select i from t1 where i > 0 |
|||
--source include/wait_condition.inc |
|||
|
|||
--let SEARCH_FILE = `SELECT @@slow_query_log_file` |
|||
--let SEARCH_PATTERN= update t1 set i=1 |
|||
--let SEARCH_RANGE= -1000 |
|||
--source include/search_pattern_in_file.inc |
|||
|
|||
drop table t1; |
|||
|
|||
set global event_scheduler= @event_scheduler_save; |
|||
set global slow_query_log= @slow_query_log_save; |
|||
set global long_query_time= @@session.long_query_time; |
|||
@ -0,0 +1,82 @@ |
|||
#include <my_global.h> |
|||
#include <m_string.h> |
|||
#include <my_sys.h> |
|||
#include <my_pthread.h> |
|||
#ifdef HAVE_PWD_H |
|||
#include <pwd.h> |
|||
#endif |
|||
#ifdef HAVE_GRP_H |
|||
#include <grp.h> |
|||
#endif |
|||
|
|||
struct passwd *my_check_user(const char *user, myf MyFlags) |
|||
{ |
|||
struct passwd *user_info; |
|||
uid_t user_id= geteuid(); |
|||
DBUG_ENTER("my_check_user"); |
|||
|
|||
// Don't bother if we aren't superuser |
|||
if (user_id) |
|||
{ |
|||
if (user) |
|||
{ |
|||
/* Don't give a warning, if real user is same as given with --user */ |
|||
user_info= getpwnam(user); |
|||
if (!user_info || user_id != user_info->pw_uid) |
|||
{ |
|||
my_errno= EPERM; |
|||
if (MyFlags & MY_WME) |
|||
my_printf_error(my_errno, "One can only use the --user switch if " |
|||
"running as root", MYF(ME_JUST_WARNING|ME_NOREFRESH)); |
|||
} |
|||
} |
|||
DBUG_RETURN(NULL); |
|||
} |
|||
if (!user) |
|||
{ |
|||
if (MyFlags & MY_FAE) |
|||
{ |
|||
my_errno= EINVAL; |
|||
my_printf_error(my_errno, "Please consult the Knowledge Base to find " |
|||
"out how to run mysqld as root!", MYF(ME_NOREFRESH)); |
|||
} |
|||
DBUG_RETURN(NULL); |
|||
} |
|||
if (!strcmp(user,"root")) |
|||
DBUG_RETURN(NULL); |
|||
|
|||
if (!(user_info= getpwnam(user))) |
|||
{ |
|||
// Allow a numeric uid to be used |
|||
int err= 0; |
|||
user_id= my_strtoll10(user, NULL, &err); |
|||
if (err || !(user_info= getpwuid(user_id))) |
|||
{ |
|||
my_errno= EINVAL; |
|||
my_printf_error(my_errno, "Can't change to run as user '%s'. Please " |
|||
"check that the user exists!", MYF(ME_NOREFRESH), user); |
|||
DBUG_RETURN(NULL); |
|||
} |
|||
} |
|||
DBUG_ASSERT(user_info); |
|||
DBUG_RETURN(user_info); |
|||
} |
|||
|
|||
int my_set_user(const char *user, struct passwd *user_info, myf MyFlags) |
|||
{ |
|||
DBUG_ENTER("my_set_user"); |
|||
|
|||
DBUG_ASSERT(user_info != 0); |
|||
#ifdef HAVE_INITGROUPS |
|||
initgroups(user, user_info->pw_gid); |
|||
#endif |
|||
if (setgid(user_info->pw_gid) == -1 || setuid(user_info->pw_uid) == -1) |
|||
{ |
|||
my_errno= errno; |
|||
if (MyFlags & MY_WME) |
|||
my_printf_error(errno, "Cannot change uid/gid (errno: %d)", MYF(ME_NOREFRESH), |
|||
errno); |
|||
DBUG_RETURN(my_errno); |
|||
} |
|||
DBUG_RETURN(0); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue