Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2ce96c0f
Commit
2ce96c0f
authored
Feb 11, 2019
by
zhaozhao.zz
Committed by
antirez
Feb 11, 2019
Browse files
ACL: kill the old users clients after load aclfile
parent
3df1eb85
Changes
1
Show whitespace changes
Inline
Side-by-side
src/acl.c
View file @
2ce96c0f
...
@@ -220,6 +220,30 @@ void ACLFreeUser(user *u) {
...
@@ -220,6 +220,30 @@ void ACLFreeUser(user *u) {
zfree
(
u
);
zfree
(
u
);
}
}
/* When a user is deleted we need to cycle the active
* connections in order to kill all the pending ones that
* are authenticated with such user. */
void
ACLFreeUserAndKillClients
(
user
*
u
)
{
ACLFreeUser
(
u
);
listIter
li
;
listNode
*
ln
;
listRewind
(
server
.
clients
,
&
li
);
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
client
*
c
=
listNodeValue
(
ln
);
if
(
c
->
user
==
u
)
{
/* We'll free the conenction asynchronously, so
* in theory to set a different user is not needed.
* However if there are bugs in Redis, soon or later
* this may result in some security hole: it's much
* more defensive to set the default user and put
* it in non authenticated mode. */
c
->
user
=
DefaultUser
;
c
->
authenticated
=
0
;
freeClientAsync
(
c
);
}
}
}
/* Copy the user ACL rules from the source user 'src' to the destination
/* Copy the user ACL rules from the source user 'src' to the destination
* user 'dst' so that at the end of the process they'll have exactly the
* user 'dst' so that at the end of the process they'll have exactly the
* same rules (but the names will continue to be the original ones). */
* same rules (but the names will continue to be the original ones). */
...
@@ -249,7 +273,7 @@ void ACLCopyUser(user *dst, user *src) {
...
@@ -249,7 +273,7 @@ void ACLCopyUser(user *dst, user *src) {
/* Free all the users registered in the radix tree 'users' and free the
/* Free all the users registered in the radix tree 'users' and free the
* radix tree itself. */
* radix tree itself. */
void
ACLFreeUsersSet
(
rax
*
users
)
{
void
ACLFreeUsersSet
(
rax
*
users
)
{
raxFreeWithCallback
(
users
,(
void
(
*
)(
void
*
))
ACLFreeUser
);
raxFreeWithCallback
(
users
,(
void
(
*
)(
void
*
))
ACLFreeUser
AndKillClients
);
}
}
/* Given a command ID, this function set by reference 'word' and 'bit'
/* Given a command ID, this function set by reference 'word' and 'bit'
...
@@ -1304,27 +1328,7 @@ void aclCommand(client *c) {
...
@@ -1304,27 +1328,7 @@ void aclCommand(client *c) {
sdslen
(
username
),
sdslen
(
username
),
(
void
**
)
&
u
))
(
void
**
)
&
u
))
{
{
/* When a user is deleted we need to cycle the active
ACLFreeUserAndKillClients
(
u
);
* connections in order to kill all the pending ones that
* are authenticated with such user. */
ACLFreeUser
(
u
);
listIter
li
;
listNode
*
ln
;
listRewind
(
server
.
clients
,
&
li
);
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
client
*
c
=
listNodeValue
(
ln
);
if
(
c
->
user
==
u
)
{
/* We'll free the conenction asynchronously, so
* in theory to set a different user is not needed.
* However if there are bugs in Redis, soon or later
* this may result in some security hole: it's much
* more defensive to set the default user and put
* it in non authenticated mode. */
c
->
user
=
DefaultUser
;
c
->
authenticated
=
0
;
freeClientAsync
(
c
);
}
}
deleted
++
;
deleted
++
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment