Skip to content

Commit ea42e88

Browse files
committed
Bug #24557925: MYSQL_CONFIG_EDITOR CAN MAKE SERVER UNBOOTABLE
By default all mysys based programs are sourcing the login file. The server should not be doing this since it's not a client program. Thus added a new global to mysys, that, when set to FALSE disables the sourcing of the login path file. And then changed mysqld to set that variable to FALSE from its mysys default TRUE. Added a test case.
1 parent 632be30 commit ea42e88

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

include/my_default.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern const char *my_defaults_extra_file;
2525
extern const char *my_defaults_group_suffix;
2626
extern const char *my_defaults_file;
2727
extern my_bool my_getopt_use_args_separator;
28+
extern my_bool my_defaults_read_login_file;
2829

2930
/* Define the type of function to be passed to process_default_option_files */
3031
typedef int (*Process_option_func)(void *ctx, const char *group_name,

mysql-test/r/mysql_config_editor.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,10 @@ mysqld is alive
267267
# normally.
268268
mysqld is alive
269269
#### End of test ####
270+
#
271+
# Bug #24557925: MYSQL_CONFIG_EDITOR CAN MAKE SERVER UNBOOTABLE
272+
#
273+
# Restarting the server. Should work
274+
# Cleanup
275+
/home/gkodinov/work/B24557925-5.6/client//mysql_config_editor remove --login-path=mysqld
276+
# End of 5.6 tests

mysql-test/t/mysql_config_editor.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,19 @@ DROP USER test_user1, test_user2;
203203

204204
--echo #### End of test ####
205205

206+
207+
--echo #
208+
--echo # Bug #24557925: MYSQL_CONFIG_EDITOR CAN MAKE SERVER UNBOOTABLE
209+
--echo #
210+
211+
212+
--exec $MYSQL_CONFIG_EDITOR set --login-path=mysqld --host=test_user5
213+
214+
--echo # Restarting the server. Should work
215+
--source include/restart_mysqld.inc
216+
217+
--echo # Cleanup
218+
--echo $MYSQL_CONFIG_EDITOR remove --login-path=mysqld
219+
--remove_file $MYSQL_TEST_LOGIN_FILE
220+
221+
--echo # End of 5.6 tests

mysys_ssl/my_default.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ int load_defaults(const char *conf_file, const char **groups,
578578
return my_load_defaults(conf_file, groups, argc, argv, &default_directories);
579579
}
580580

581+
/** A global to turn off or on reading the mylogin file. On by default */
582+
my_bool my_defaults_read_login_file= TRUE;
581583
/*
582584
Read options from configurations files
583585
@@ -665,16 +667,18 @@ int my_load_defaults(const char *conf_file, const char **groups,
665667
DBUG_RETURN(error);
666668
}
667669

668-
/* Read options from login group. */
669-
if (my_default_get_login_file(my_login_file, sizeof(my_login_file)) &&
670-
(error= my_search_option_files(my_login_file,argc, argv, &args_used,
670+
if (my_defaults_read_login_file)
671+
{
672+
/* Read options from login group. */
673+
if (my_default_get_login_file(my_login_file, sizeof(my_login_file)) &&
674+
(error= my_search_option_files(my_login_file, argc, argv, &args_used,
671675
handle_default_option, (void *) &ctx,
672676
dirs, true, found_no_defaults)))
673-
{
674-
free_root(&alloc,MYF(0));
675-
DBUG_RETURN(error);
677+
{
678+
free_root(&alloc, MYF(0));
679+
DBUG_RETURN(error);
680+
}
676681
}
677-
678682
/*
679683
Here error contains <> 0 only if we have a fully specified conf_file
680684
or a forced default file

sql/mysqld.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5261,6 +5261,7 @@ int mysqld_main(int argc, char **argv)
52615261
orig_argc= argc;
52625262
orig_argv= argv;
52635263
my_getopt_use_args_separator= TRUE;
5264+
my_defaults_read_login_file= FALSE;
52645265
if (load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv))
52655266
return 1;
52665267
my_getopt_use_args_separator= FALSE;

0 commit comments

Comments
 (0)