-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: check visibility for show databases and tables #2934
Conversation
executor/show.go
Outdated
// sort for tables | ||
var tableNames []string | ||
for _, v := range e.is.SchemaTables(e.DBName) { | ||
// TODO: Should consider column privileges, which also make a table visible. | ||
if checker != nil && !checker.RequestVerification(e.DBName.O, v.Meta().Name.O, "", mysql.AllPriv-1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's mean by mysql.AllPriv-1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All privilege bits set to 1, means any kind of privileges would be OK.
privilege/privileges/privileges.go
Outdated
@@ -246,6 +246,31 @@ func (p *UserPrivileges) ConnectionVerification(user, host string, auth, salt [] | |||
return true | |||
} | |||
|
|||
// ShowDatabase implements the Checker interface. | |||
func (p *UserPrivileges) DBVisible(db string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/DBVisible/DBIsVisible
LGTM |
privilege/privileges/cache.go
Outdated
@@ -418,6 +418,43 @@ func (p *MySQLPrivilege) RequestVerification(user, host, db, table, column strin | |||
return false | |||
} | |||
|
|||
// ShowDatabase checks whether the user can see the db. | |||
func (p *MySQLPrivilege) ShowDatabase(user, host, db string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DBIsVisible
LGTM |
show databases
andshow tables
return just those visible to the user,if the user doesn't have privilege, he should not see it.