Skip to content

Commit

Permalink
Fix sha256_password auth plugin on unix transport (#1246)
Browse files Browse the repository at this point in the history
caching_sha2_password uses cleartext password when
the connection is Unix or sharedmemory protocol.
but sha256_password do not.
  • Loading branch information
santhosh-tekuri committed Aug 24, 2021
1 parent e8f8fcd commit a5bb807
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Reed Allman <rdallman10 at gmail.com>
Richard Wilkes <wilkes at me.com>
Robert Russell <robert at rrbrussell.com>
Runrioter Wung <runrioter at gmail.com>
Santhosh Kumar Tekuri <santhosh.tekuri at gmail.com>
Sho Iizuka <sho.i518 at gmail.com>
Sho Ikeda <suicaicoca at gmail.com>
Shuode Li <elemount at qq.com>
Expand Down
4 changes: 3 additions & 1 deletion auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ func (mc *mysqlConn) auth(authData []byte, plugin string) ([]byte, error) {
if len(mc.cfg.Passwd) == 0 {
return []byte{0}, nil
}
if mc.cfg.tls != nil || mc.cfg.Net == "unix" {
// unlike caching_sha2_password, sha256_password does not accept
// cleartext password on unix transport.
if mc.cfg.tls != nil {
// write cleartext auth packet
return append([]byte(mc.cfg.Passwd), 0), nil
}
Expand Down

0 comments on commit a5bb807

Please sign in to comment.