From f38aa6bfb7a1bc7a3c5b18fadc513da1152bc7b5 Mon Sep 17 00:00:00 2001 From: Slava Koyfman Date: Sun, 2 Apr 2023 16:18:28 +0300 Subject: Disconnect pub-sub subscribers when revoking `allchannels` permission (#11992) The existing logic for killing pub-sub clients did not handle the `allchannels` permission correctly. For example, if you: ACL SETUSER foo allchannels Have a client authenticate as the user `foo` and subscribe to a channel, and then: ACL SETUSER foo resetchannels The subscribed client would not be disconnected, though new clients under that user would be blocked from subscribing to any channels. This was caused by an incomplete optimization in `ACLKillPubsubClientsIfNeeded` checking whether the new channel permissions were a strict superset of the old ones. --- tests/unit/acl.tcl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index 555fb5a34..4d8c77b9f 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -289,6 +289,20 @@ start_server {tags {"acl external:skip"}} { $rd close } {0} + test {Subscribers are killed when revoked of allchannels permission} { + set rd [redis_deferring_client] + r ACL setuser psuser allchannels + $rd AUTH psuser pspass + $rd read + $rd CLIENT SETNAME deathrow + $rd read + $rd PSUBSCRIBE foo + $rd read + r ACL setuser psuser resetchannels + assert_no_match {*deathrow*} [r CLIENT LIST] + $rd close + } {0} + test {Subscribers are pardoned if literal permissions are retained and/or gaining allchannels} { set rd [redis_deferring_client] r ACL setuser psuser resetchannels &foo:1 &bar:* &orders -- cgit v1.2.1