Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: unix socket should verify user's authentication #8381

Merged
merged 10 commits into from
Nov 22, 2018

Conversation

jackysp
Copy link
Member

@jackysp jackysp commented Nov 21, 2018

What problem does this PR solve?

Fix #8372 . The connection should verify user's authentication when using unix socket.

What is changed and how it works?

Verify user's authentication when using unix socket.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

This change is Reviewable

@lysu
Copy link
Contributor

lysu commented Nov 21, 2018

/run-sqllogic-test

server/server.go Outdated
@@ -129,7 +129,7 @@ func (s *Server) newConn(conn net.Conn) *clientConn {
return cc
}

func (s *Server) skipAuth() bool {
func (s *Server) isLocal() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name is isLocal and the function implement is c.cfg.Socket ? That seems weird
@jackysp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be isLocalSocket or isUnixSocket? There could be a local tcp connection. We will not support them, but MySQL also supports local named pipe and shm on windows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isUnixSocket sounds good.

server/conn.go Outdated
@@ -391,16 +392,17 @@ func (cc *clientConn) openSessionAndDoAuth(authData []byte) error {
if err != nil {
return errors.Trace(err)
}
if !cc.server.skipAuth() {
// Do Auth.
host := variable.ServerHostname
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems mysql here will got "localhost" and do auth logic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know it. I used to set host to a const string here, due to I have not checked the implementation of MySQL. If it is critical, I'll check when will MySQL set "localhost" and whether there are other cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a const is valid here :-) MySQL has a special handling/meaning of "localhost". Clients that connect to "localhost" will be redirected to a socket etc.

@jackysp
Copy link
Member Author

jackysp commented Nov 21, 2018

/run-all-tests

@iamxy
Copy link
Member

iamxy commented Nov 21, 2018

/run-sqllogic-test

@jackysp
Copy link
Member Author

jackysp commented Nov 22, 2018

/run-integration-ddl-test

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zimulala zimulala added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 22, 2018
@tiancaiamao
Copy link
Contributor

LGTM

tiancaiamao
tiancaiamao previously approved these changes Nov 22, 2018
@jackysp
Copy link
Member Author

jackysp commented Nov 22, 2018

/run-all-tests

@jackysp
Copy link
Member Author

jackysp commented Nov 22, 2018

PTAL @tiancaiamao @lysu @zimulala

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lysu lysu added the status/LGT2 Indicates that a PR has LGTM 2. label Nov 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/server status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants