Changeset 4990
- Timestamp:
- 09/04/06 17:55:28 (3 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/vendor/mysql.rb (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r4981 r4990 1 1 *SVN* 2 3 * Fixed the Ruby/MySQL adapter we ship with Active Record to work with the new authentication handshake that was introduced in MySQL 4.1, along with the other protocol changes made at that time #5723 [jimw@mysql.com] 2 4 3 5 * Deprecation: use :dependent => :delete_all rather than :exclusively_dependent => true. #6024 [Josh Susser] trunk/activerecord/lib/active_record/vendor/mysql.rb
r3274 r4990 7 7 class Mysql 8 8 9 VERSION = "4.0-ruby-0.2. 5"9 VERSION = "4.0-ruby-0.2.6-plus-changes" 10 10 11 11 require "socket" … … 18 18 MYSQL_PORT = 3306 19 19 PROTOCOL_VERSION = 10 20 21 SCRAMBLE_LENGTH = 20 22 SCRAMBLE_LENGTH_323 = 8 20 23 21 24 # Command … … 148 151 end 149 152 write data 150 read 153 pkt = read 154 handle_auth_fallback(pkt, passwd) 151 155 ObjectSpace.define_finalizer(self, Mysql.finalizer(@net)) 152 156 self 153 157 end 154 158 alias :connect :real_connect 159 160 def handle_auth_fallback(pkt, passwd) 161 # A packet like this means that we need to send an old-format password 162 if pkt.size == 1 and pkt[0] == 254 and 163 @server_capabilities & CLIENT_SECURE_CONNECTION != 0 then 164 data = scramble(passwd, @scramble_buff, @protocol_version == 9) 165 write data + "\0" 166 read 167 end 168 end 155 169 156 170 def escape_string(str) … … 209 223 data = user+"\0"+scramble41(passwd, @scramble_buff)+db 210 224 end 211 command COM_CHANGE_USER, data 225 pkt = command COM_CHANGE_USER, data 226 handle_auth_fallback(pkt, passwd) 212 227 @user = user 213 228 @passwd = passwd … … 535 550 raise "old version password is not implemented" if old_ver 536 551 hash_pass = hash_password password 537 hash_message = hash_password message 552 hash_message = hash_password message.slice(0,SCRAMBLE_LENGTH_323) 538 553 rnd = Random::new hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1] 539 554 to = [] 540 1.upto( message.length) do555 1.upto(SCRAMBLE_LENGTH_323) do 541 556 to << ((rnd.rnd*31)+64).floor 542 557 end