Check if the user's existing pub/sub clients violate the ACL pub/sub * permissions specified via the upcoming argument, and kill them if so. */
| 1289 | /* Check if the user's existing pub/sub clients violate the ACL pub/sub |
| 1290 | * permissions specified via the upcoming argument, and kill them if so. */ |
| 1291 | void ACLKillPubsubClientsIfNeeded(user *u, list *upcoming) { |
| 1292 | listIter li, lpi; |
| 1293 | listNode *ln, *lpn; |
| 1294 | robj *o; |
| 1295 | int kill = 0; |
| 1296 | |
| 1297 | /* Nothing to kill when the upcoming are a literal super set of the original |
| 1298 | * permissions. */ |
| 1299 | listRewind(u->channels,&li); |
| 1300 | while (!kill && ((ln = listNext(&li)) != NULL)) { |
| 1301 | sds pattern = (sds)listNodeValue(ln); |
| 1302 | kill = (ACLCheckPubsubChannelPerm(pattern,upcoming,1) == |
| 1303 | ACL_DENIED_CHANNEL); |
| 1304 | } |
| 1305 | if (!kill) return; |
| 1306 | |
| 1307 | /* Scan all connected clients to find the user's pub/subs. */ |
| 1308 | listRewind(g_pserver->clients,&li); |
| 1309 | while ((ln = listNext(&li)) != NULL) { |
| 1310 | client *c = (client*)listNodeValue(ln); |
| 1311 | kill = 0; |
| 1312 | |
| 1313 | if (c->user == u && getClientType(c) == CLIENT_TYPE_PUBSUB) { |
| 1314 | /* Check for pattern violations. */ |
| 1315 | listRewind(c->pubsub_patterns,&lpi); |
| 1316 | while (!kill && ((lpn = listNext(&lpi)) != NULL)) { |
| 1317 | o = (robj*)lpn->value; |
| 1318 | kill = (ACLCheckPubsubChannelPerm(szFromObj(o),upcoming,1) == |
| 1319 | ACL_DENIED_CHANNEL); |
| 1320 | } |
| 1321 | /* Check for channel violations. */ |
| 1322 | if (!kill) { |
| 1323 | dictIterator *di = dictGetIterator(c->pubsub_channels); |
| 1324 | dictEntry *de; |
| 1325 | while (!kill && ((de = dictNext(di)) != NULL)) { |
| 1326 | o = (robj*)dictGetKey(de); |
| 1327 | kill = (ACLCheckPubsubChannelPerm(szFromObj(o),upcoming,0) == |
| 1328 | ACL_DENIED_CHANNEL); |
| 1329 | } |
| 1330 | dictReleaseIterator(di); |
| 1331 | } |
| 1332 | |
| 1333 | /* Kill it. */ |
| 1334 | if (kill) { |
| 1335 | freeClientAsync(c); |
| 1336 | } |
| 1337 | } |
| 1338 | } |
| 1339 | } |
| 1340 | |
| 1341 | /* Check if the pub/sub channels of the command, that's ready to be executed in |
| 1342 | * the client 'c', can be executed by this client according to the ACLs channels |
no test coverage detected