-
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
*: kill one's own connection doesn't require SUPER privilege #6954
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -783,8 +783,21 @@ func (b *planBuilder) buildSimple(node ast.StmtNode) Plan { | |
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.CreateUserPriv, "", "", "") | ||
case *ast.GrantStmt: | ||
b.visitInfo = collectVisitInfoFromGrantStmt(b.visitInfo, raw) | ||
case *ast.SetPwdStmt, *ast.RevokeStmt, *ast.KillStmt: | ||
case *ast.SetPwdStmt, *ast.RevokeStmt: | ||
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.SuperPriv, "", "", "") | ||
case *ast.KillStmt: | ||
// If you have the SUPER privilege, you can kill all threads and statements. | ||
// Otherwise, you can kill only your own threads and statements. | ||
sm := b.ctx.GetSessionManager() | ||
if sm != nil { | ||
processList := sm.ShowProcessList() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add an interface for SessionManger like GetProcessByConnID(connID) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the interface There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
if pi, ok := processList[raw.ConnectionID]; ok { | ||
loginUser := b.ctx.GetSessionVars().User | ||
if pi.User != loginUser.Username { | ||
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.SuperPriv, "", "", "") | ||
} | ||
} | ||
} | ||
} | ||
return p | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ type ProcessInfo struct { | |
// SessionManager is an interface for session manage. Show processlist and | ||
// kill statement rely on this interface. | ||
type SessionManager interface { | ||
ShowProcessList() []ProcessInfo | ||
// ShowProcessList returns map[connectionID]ProcessInfo | ||
ShowProcessList() map[uint64]ProcessInfo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment for the return value. |
||
Kill(connectionID uint64, query 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.
Could the
sm
be nil?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.
In the test code