Skip to content

Commit

Permalink
Fixed enable_cleartext_plugin mode (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisenkom authored and sodabrew committed Aug 8, 2017
1 parent 7e8f0e1 commit a321723
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
retval = charval;
break;

#ifdef MYSQL_ENABLE_CLEARTEXT_PLUGIN
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
boolval = (value == Qfalse ? 0 : 1);
retval = &boolval;
Expand Down Expand Up @@ -1328,7 +1328,7 @@ static VALUE set_init_command(VALUE self, VALUE value) {
}

static VALUE set_enable_cleartext_plugin(VALUE self, VALUE value) {
#ifdef MYSQL_ENABLE_CLEARTEXT_PLUGIN
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
return _mysql_client_options(self, MYSQL_ENABLE_CLEARTEXT_PLUGIN, value);
#else
rb_raise(cMysql2Error, "enable-cleartext-plugin is not available, you may need a newer MySQL client library");
Expand Down
1 change: 1 addition & 0 deletions ext/mysql2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def add_ssl_defines(header)
add_ssl_defines(mysql_h)
have_struct_member('MYSQL', 'net.vio', mysql_h)
have_struct_member('MYSQL', 'net.pvio', mysql_h)
have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h)

# This is our wishlist. We use whichever flags work on the host.
# -Wall and -Wextra are included by default.
Expand Down
5 changes: 5 additions & 0 deletions spec/mysql2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,11 @@ def run_gc
expect(@client.ping).to eql(false)
end

it "should be able to connect using plaintext password" do
client = new_client(:enable_cleartext_plugin => true)
client.query('SELECT 1')
end

unless RUBY_VERSION =~ /1.8/
it "should respond to #encoding" do
expect(@client).to respond_to(:encoding)
Expand Down

0 comments on commit a321723

Please sign in to comment.