@@ -431,7 +431,8 @@ static COMMANDS commands[] = {
431
431
" Execute an SQL script file. Takes a file name as an argument." },
432
432
{" status" , ' s' , com_status, false ,
433
433
" Get status information from the server." },
434
- {" system" , ' !' , com_shell, true , " Execute a system shell command." },
434
+ {" system" , ' !' , com_shell, true ,
435
+ " Execute a system shell command, if enabled" },
435
436
{" tee" , ' T' , com_tee, true ,
436
437
" Set outfile [to_outfile]. Append everything into given outfile." },
437
438
{" use" , ' u' , com_use, true ,
@@ -1751,6 +1752,8 @@ void window_resize(int) {
1751
1752
}
1752
1753
#endif
1753
1754
1755
+ static bool opt_system_command = true ;
1756
+
1754
1757
static struct my_option my_long_options[] = {
1755
1758
{" help" , ' ?' , " Display this help and exit." , nullptr , nullptr , nullptr ,
1756
1759
GET_NO_ARG, NO_ARG, 0 , 0 , 0 , nullptr , 0 , nullptr },
@@ -2083,6 +2086,10 @@ static struct my_option my_long_options[] = {
2083
2086
" Specifies factor for which registration needs to be done for." ,
2084
2087
&opt_register_factor, &opt_register_factor, nullptr , GET_STR, REQUIRED_ARG,
2085
2088
0 , 0 , 0 , nullptr , 0 , nullptr },
2089
+ {" system-command" , 0 ,
2090
+ " Enable (by default) or disable the system mysql command." ,
2091
+ &opt_system_command, &opt_system_command, nullptr , GET_BOOL, NO_ARG, 1 , 0 ,
2092
+ 0 , nullptr , 0 , nullptr },
2086
2093
{nullptr , 0 , nullptr , nullptr , nullptr , nullptr , GET_NO_ARG, NO_ARG, 0 , 0 ,
2087
2094
0 , nullptr , 0 , nullptr }};
2088
2095
@@ -4498,6 +4505,13 @@ static int com_shell(String *buffer [[maybe_unused]],
4498
4505
put_info (" Usage: \\ ! shell-command" , INFO_ERROR);
4499
4506
return -1 ;
4500
4507
}
4508
+
4509
+ if (!opt_system_command) {
4510
+ return put_info (
4511
+ " 'system' command received, but the --system-command option is off. "
4512
+ " Skipping." ,
4513
+ INFO_ERROR);
4514
+ }
4501
4515
/*
4502
4516
The output of the shell command does not
4503
4517
get directed to the pager or the outfile
0 commit comments