Skip to content

Commit 883d096

Browse files
author
Anirudh Mangipudi
committed
Bug#16723046 MYSQLDUMP: UNKNOWN OPTION '--SECURE-AUTH'
Problem: Since after 5.6.7 the secure-auth option was by default set to true from false in mysql clients. But the support for this option was added only in mysql client. Other client tools were missing this option and hence were resulting in the error, Unknown option '--secure-auth', when trying to connect to the server Solution: The secure-auth parameter was added to the mysql client utilities which connect to the server i.e., Mysqldump, Mysqladmin, Mysqlcheck, Mysqlbinlog, MysqlImport, Mysqlslap, Mysqlshow, and also mysql_client_fw which now prevents the error.
1 parent 62c1c00 commit 883d096

8 files changed

Lines changed: 62 additions & 12 deletions

File tree

client/mysqladmin.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ ulonglong last_values[MAX_MYSQL_VAR];
4040
static int interval=0;
4141
static my_bool option_force=0,interrupted=0,new_line=0,
4242
opt_compress=0, opt_relative=0, opt_verbose=0, opt_vertical=0,
43-
tty_password= 0, opt_nobeep;
43+
tty_password= 0, opt_nobeep, opt_secure_auth= TRUE;
4444
static my_bool debug_info_flag= 0, debug_check_flag= 0;
4545
static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations;
4646
static uint opt_count_iterations= 0, my_end_arg;
@@ -181,6 +181,9 @@ static struct my_option my_long_options[] =
181181
"Currently only works with extended-status.",
182182
&opt_relative, &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0,
183183
0, 0, 0},
184+
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
185+
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
186+
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
184187
#ifdef HAVE_SMEM
185188
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
186189
"Base name of shared memory.", &shared_memory_base_name, &shared_memory_base_name,
@@ -349,6 +352,8 @@ int main(int argc,char *argv[])
349352

350353
if (opt_bind_addr)
351354
mysql_options(&mysql,MYSQL_OPT_BIND,opt_bind_addr);
355+
if (!opt_secure_auth)
356+
mysql_options(&mysql, MYSQL_SECURE_AUTH,(char*)&opt_secure_auth);
352357
if (opt_compress)
353358
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
354359
if (opt_connect_timeout)

client/mysqlbinlog.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -131,6 +131,7 @@ static int port= 0;
131131
static uint my_end_arg;
132132
static const char* sock= 0;
133133
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
134+
static my_bool opt_secure_auth= TRUE;
134135

135136
#ifdef HAVE_SMEM
136137
static char *shared_memory_base_name= 0;
@@ -1472,6 +1473,9 @@ static struct my_option my_long_options[] =
14721473
"prefix for the file names.",
14731474
&output_file, &output_file, 0, GET_STR, REQUIRED_ARG,
14741475
0, 0, 0, 0, 0, 0},
1476+
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
1477+
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
1478+
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
14751479
{"server-id", OPT_SERVER_ID,
14761480
"Extract only binlog entries created by the server having the given id.",
14771481
&server_id, &server_id, 0, GET_ULONG,
@@ -1833,6 +1837,8 @@ static Exit_status safe_connect()
18331837
mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
18341838
if (opt_bind_addr)
18351839
mysql_options(mysql, MYSQL_OPT_BIND, opt_bind_addr);
1840+
if (!opt_secure_auth)
1841+
mysql_options(mysql, MYSQL_SECURE_AUTH,(char*)&opt_secure_auth);
18361842
#ifdef HAVE_SMEM
18371843
if (shared_memory_base_name)
18381844
mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME,

client/mysqlcheck.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
4141
opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
4242
tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0,
4343
opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0,
44-
opt_write_binlog= 1;
44+
opt_write_binlog= 1, opt_secure_auth=TRUE;
4545
static uint verbose = 0, opt_mysql_port=0;
4646
static int my_end_arg;
4747
static char * opt_mysql_unix_port = 0;
@@ -144,6 +144,9 @@ static struct my_option my_long_options[] =
144144
"when commands should not be sent to replication slaves.",
145145
&opt_write_binlog, &opt_write_binlog, 0, GET_BOOL, NO_ARG,
146146
1, 0, 0, 0, 0, 0},
147+
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
148+
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
149+
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
147150
{"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
148151
0, 0},
149152
{"password", 'p',
@@ -891,6 +894,8 @@ static int dbConnect(char *host, char *user, char *passwd)
891894
mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
892895
if (opt_bind_addr)
893896
mysql_options(&mysql_connection, MYSQL_OPT_BIND, opt_bind_addr);
897+
if (!opt_secure_auth)
898+
mysql_options(&mysql_connection, MYSQL_SECURE_AUTH,(char*)&opt_secure_auth);
894899
#ifdef HAVE_SMEM
895900
if (shared_memory_base_name)
896901
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);

client/mysqldump.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -109,7 +109,8 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
109109
opt_slave_apply= 0,
110110
opt_include_master_host_port= 0,
111111
opt_events= 0, opt_comments_used= 0,
112-
opt_alltspcs=0, opt_notspcs= 0, opt_drop_trigger= 0;
112+
opt_alltspcs=0, opt_notspcs= 0, opt_drop_trigger= 0,
113+
opt_secure_auth= 1;
113114
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
114115
static ulong opt_max_allowed_packet, opt_net_buffer_length;
115116
static MYSQL mysql_connection,*mysql=0;
@@ -508,6 +509,9 @@ static struct my_option my_long_options[] =
508509
{"socket", 'S', "The socket file to use for connection.",
509510
&opt_mysql_unix_port, &opt_mysql_unix_port, 0,
510511
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
512+
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
513+
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
514+
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
511515
#include <sslopt-longopts.h>
512516
{"tab",'T',
513517
"Create tab-separated textfile for each table to given path. (Create .sql "
@@ -1519,6 +1523,8 @@ static int connect_to_db(char *host, char *user,char *passwd)
15191523
mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
15201524
if (opt_bind_addr)
15211525
mysql_options(&mysql_connection,MYSQL_OPT_BIND,opt_bind_addr);
1526+
if (!opt_secure_auth)
1527+
mysql_options(&mysql_connection,MYSQL_SECURE_AUTH,(char*)&opt_secure_auth);
15221528
#ifdef HAVE_SMEM
15231529
if (shared_memory_base_name)
15241530
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);

client/mysqlimport.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ static char *add_load_option(char *ptr,const char *object,
4747

4848
static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
4949
replace=0,silent=0,ignore=0,opt_compress=0,
50-
opt_low_priority= 0, tty_password= 0;
50+
opt_low_priority= 0, tty_password= 0, opt_secure_auth= 1;
5151
static my_bool debug_info_flag= 0, debug_check_flag= 0;
5252
static uint opt_use_threads=0, opt_local_file=0, my_end_arg= 0;
5353
static char *opt_password=0, *current_user=0,
@@ -161,6 +161,9 @@ static struct my_option my_long_options[] =
161161
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
162162
{"replace", 'r', "If duplicate unique key was found, replace old row.",
163163
&replace, &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
164+
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
165+
" uses old (pre-4.1.1) protocol.",
166+
&opt_secure_auth, &opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
164167
#ifdef HAVE_SMEM
165168
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
166169
"Base name of shared memory.", &shared_memory_base_name, &shared_memory_base_name,
@@ -440,6 +443,8 @@ static MYSQL *db_connect(char *host, char *database,
440443
mysql_options(mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
441444
if (opt_bind_addr)
442445
mysql_options(mysql,MYSQL_OPT_BIND,opt_bind_addr);
446+
if (!opt_secure_auth)
447+
mysql_options(mysql, MYSQL_SECURE_AUTH,(char*)&opt_secure_auth);
443448
#ifdef HAVE_SMEM
444449
if (shared_memory_base_name)
445450
mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);

client/mysqlshow.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -38,6 +38,7 @@ static uint my_end_arg= 0;
3838
static uint opt_verbose=0;
3939
static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
4040
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
41+
static my_bool opt_secure_auth= TRUE;
4142

4243
#ifdef HAVE_SMEM
4344
static char *shared_memory_base_name=0;
@@ -132,6 +133,8 @@ int main(int argc, char **argv)
132133
mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
133134
if (opt_bind_addr)
134135
mysql_options(&mysql,MYSQL_OPT_BIND,opt_bind_addr);
136+
if (!opt_secure_auth)
137+
mysql_options(&mysql, MYSQL_SECURE_AUTH,(char*)&opt_secure_auth);
135138
#ifdef HAVE_SMEM
136139
if (shared_memory_base_name)
137140
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
@@ -244,6 +247,9 @@ static struct my_option my_long_options[] =
244247
{"protocol", OPT_MYSQL_PROTOCOL,
245248
"The protocol to use for connection (tcp, socket, pipe, memory).",
246249
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
250+
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
251+
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
252+
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
247253
#ifdef HAVE_SMEM
248254
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
249255
"Base name of shared memory.", &shared_memory_base_name,

client/mysqlslap.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -126,6 +126,7 @@ static char *host= NULL, *opt_password= NULL, *user= NULL,
126126
*post_system= NULL,
127127
*opt_mysql_unix_port= NULL;
128128
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
129+
static my_bool opt_secure_auth= TRUE;
129130
static uint opt_enable_cleartext_plugin= 0;
130131
static my_bool using_opt_enable_cleartext_plugin= 0;
131132

@@ -346,6 +347,8 @@ int main(int argc, char **argv)
346347
#endif
347348
if (opt_protocol)
348349
mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
350+
if (!opt_secure_auth && slap_connect(&mysql))
351+
mysql_options(&mysql, MYSQL_SECURE_AUTH,(char*)&opt_secure_auth);
349352
#ifdef HAVE_SMEM
350353
if (shared_memory_base_name)
351354
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
@@ -684,6 +687,9 @@ static struct my_option my_long_options[] =
684687
{"query", 'q', "Query to run or file containing query to run.",
685688
&user_supplied_query, &user_supplied_query,
686689
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
690+
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
691+
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
692+
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
687693
#ifdef HAVE_SMEM
688694
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
689695
"Base name of shared memory.", &shared_memory_base_name,

tests/mysql_client_fw.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights
2+
* reserved.
23
34
This program is free software; you can redistribute it and/or modify
45
it under the terms of the GNU General Public License as published by
@@ -42,6 +43,7 @@ static char *shared_memory_base_name= 0;
4243
static unsigned int opt_port;
4344
static my_bool tty_password= 0, opt_silent= 0;
4445

46+
static my_bool opt_secure_auth= 1;
4547
static MYSQL *mysql= 0;
4648
static char current_db[]= "client_test_db";
4749
static unsigned int test_count= 0;
@@ -259,6 +261,9 @@ static MYSQL *mysql_client_init(MYSQL* con)
259261

260262
if (opt_default_auth && *opt_default_auth)
261263
mysql_options(res, MYSQL_DEFAULT_AUTH, opt_default_auth);
264+
265+
if (!opt_secure_auth)
266+
mysql_options(res, MYSQL_SECURE_AUTH, (char*)&opt_secure_auth);
262267
return res;
263268
}
264269

@@ -349,6 +354,9 @@ static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect)
349354
if (opt_default_auth && *opt_default_auth)
350355
mysql_options(mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
351356

357+
if (!opt_secure_auth)
358+
mysql_options(mysql, MYSQL_SECURE_AUTH, (char*)&opt_secure_auth);
359+
352360
if (!(mysql_real_connect(mysql, opt_host, opt_user,
353361
opt_password, opt_db ? opt_db:"test", opt_port,
354362
opt_unix_socket, flag)))
@@ -1228,6 +1236,9 @@ static struct my_option client_test_long_options[] =
12281236
{"default_auth", 0, "Default authentication client-side plugin to use.",
12291237
&opt_default_auth, &opt_default_auth, 0,
12301238
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1239+
{"secure-auth", 0, "Refuse client connecting to server if it"
1240+
" uses old (pre-4.1.1) protocol.", &opt_secure_auth,
1241+
&opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
12311242
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
12321243
};
12331244

0 commit comments

Comments
 (0)