Skip to content

Commit a321723

Browse files
denisenkomsodabrew
authored andcommitted
Fixed enable_cleartext_plugin mode (#874)
1 parent 7e8f0e1 commit a321723

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

ext/mysql2/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
903903
retval = charval;
904904
break;
905905

906-
#ifdef MYSQL_ENABLE_CLEARTEXT_PLUGIN
906+
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
907907
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
908908
boolval = (value == Qfalse ? 0 : 1);
909909
retval = &boolval;
@@ -1328,7 +1328,7 @@ static VALUE set_init_command(VALUE self, VALUE value) {
13281328
}
13291329

13301330
static VALUE set_enable_cleartext_plugin(VALUE self, VALUE value) {
1331-
#ifdef MYSQL_ENABLE_CLEARTEXT_PLUGIN
1331+
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
13321332
return _mysql_client_options(self, MYSQL_ENABLE_CLEARTEXT_PLUGIN, value);
13331333
#else
13341334
rb_raise(cMysql2Error, "enable-cleartext-plugin is not available, you may need a newer MySQL client library");

ext/mysql2/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def add_ssl_defines(header)
114114
add_ssl_defines(mysql_h)
115115
have_struct_member('MYSQL', 'net.vio', mysql_h)
116116
have_struct_member('MYSQL', 'net.pvio', mysql_h)
117+
have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h)
117118

118119
# This is our wishlist. We use whichever flags work on the host.
119120
# -Wall and -Wextra are included by default.

spec/mysql2/client_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,11 @@ def run_gc
10261026
expect(@client.ping).to eql(false)
10271027
end
10281028

1029+
it "should be able to connect using plaintext password" do
1030+
client = new_client(:enable_cleartext_plugin => true)
1031+
client.query('SELECT 1')
1032+
end
1033+
10291034
unless RUBY_VERSION =~ /1.8/
10301035
it "should respond to #encoding" do
10311036
expect(@client).to respond_to(:encoding)

0 commit comments

Comments
 (0)