Add option --enable-cleartext-plugin to the MariaDB client

For compatibility reasons, add the option to the MariaDB client without
any functional changes besides simply accepting the option and emitting
a warning that it is obsolete.

In MySQL this security related option is compulsory in certain use
cases. When users switch to MariaDB, this client command that used to
work starts failing without a sensible error message. In worst case
users resort to re-installing the mysql client from MySQL.

In MariaDB the option is obsolete and should simply be ignored. Users
however don't have any opportunity to learn that unless the client
program tells them so.

Before:

    mysql --enable-cleartext-plugin ...
    mysql: unknown option '--enable-cleartext-plugin'

    (program terminates)

After:

    mysql --enable-cleartext-plugin ...
    WARNING: option '--enable-cleartext-plugin' is obsolete.

    (program executes)

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
This commit is contained in:
Ting Nian 2022-05-03 17:25:48 +00:00 committed by Daniel Black
parent f85d488ad2
commit 31e30329a3
5 changed files with 38 additions and 1 deletions

View File

@ -102,6 +102,7 @@ enum options_client
OPT_IGNORE_DATA,
OPT_PRINT_ROW_COUNT, OPT_PRINT_ROW_EVENT_POSITIONS,
OPT_CHECK_IF_UPGRADE_NEEDED,
OPT_COMPATIBILTY_CLEARTEXT_PLUGIN,
OPT_MAX_CLIENT_OPTION /* should be always the last */
};

View File

@ -1521,6 +1521,8 @@ static struct my_option my_long_options[] =
&delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"execute", 'e', "Execute command and quit. (Disables --force and history file.)", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"enable-cleartext-plugin", OPT_COMPATIBILTY_CLEARTEXT_PLUGIN, "Obsolete option. Exists only for MySQL compatibility.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"vertical", 'E', "Print the output of a query (rows) vertically.",
&vertical, &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0},
@ -1817,6 +1819,14 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
printf("WARNING: --server-arg option not supported in this configuration.\n");
#endif
break;
case OPT_COMPATIBILTY_CLEARTEXT_PLUGIN:
/*
This option exists in MySQL client but not in MariaDB. Users switching from
MySQL might still have this option in their commands, and it will not work
in MariaDB unless it is handled. Therefore output a warning and continue.
*/
printf("WARNING: option '--enable-cleartext-plugin' is obsolete.\n");
break;
case 'A':
opt_rehash= 0;
break;

View File

@ -507,6 +507,21 @@ the section called \(lqMYSQL COMMANDS\(rq\&.
.sp -1
.IP \(bu 2.3
.\}
.\" mysql: enable cleartext plugin option
.\" enable cleartext plugin option: mysql
\fB\-\-enable\-cleartext\-plugin\fR
.sp
Obsolete option\&. Exists only for MySQL compatibility\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
.\" mysql: execute option
.\" execute option: mysql
\fB\-\-execute=\fR\fB\fIstatement\fR\fR,

View File

@ -629,4 +629,7 @@ drop table t1;
#
# MDEV-15538 '-N' Produce html output wrong
#
<TABLE BORDER=1><TR><TD>1</TD></TR></TABLE>
<TABLE BORDER=1><TR><TD>1</TD></TR></TABLE>
WARNING: option '--enable-cleartext-plugin' is obsolete.
1
1

View File

@ -708,3 +708,11 @@ drop table t1;
--echo # MDEV-15538 '-N' Produce html output wrong
--echo #
--exec $MYSQL -NHe "select 1 as a"
#
# Test obsolete option --enable-cleartext-plugin
# This should proceed with a warning
#
--echo
--exec $MYSQL test --enable-cleartext-plugin -e "select 1"