Check if the pub/sub channels of the command, that's ready to be executed in * the client 'c', can be executed by this client according to the ACLs channels * associated to the client user c->user. * * idx and count are the index and count of channel arguments from the * command. The literal argument controls whether the user's ACL channels are * evaluated as literal values or matched as g
| 1349 | * If the user can execute the command ACL_OK is returned, otherwise |
| 1350 | * ACL_DENIED_CHANNEL. */ |
| 1351 | int ACLCheckPubsubPerm(client *c, int idx, int count, int literal, int *idxptr) { |
| 1352 | user *u = c->user; |
| 1353 | |
| 1354 | /* If there is no associated user, the connection can run anything. */ |
| 1355 | if (u == NULL) return ACL_OK; |
| 1356 | |
| 1357 | /* Check if the user can access the channels mentioned in the command's |
| 1358 | * arguments. */ |
| 1359 | if (!(c->user->flags & USER_FLAG_ALLCHANNELS)) { |
| 1360 | for (int j = idx; j < idx+count; j++) { |
| 1361 | if (ACLCheckPubsubChannelPerm(szFromObj(c->argv[j]),u->channels,literal) |
| 1362 | != ACL_OK) { |
| 1363 | if (idxptr) *idxptr = j; |
| 1364 | return ACL_DENIED_CHANNEL; |
| 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | /* If we survived all the above checks, the user can execute the |
| 1370 | * command. */ |
| 1371 | return ACL_OK; |
| 1372 | |
| 1373 | } |
| 1374 | |
| 1375 | /* Check whether the command is ready to be exceuted by ACLCheckCommandPerm. |
| 1376 | * If check passes, then check whether pub/sub channels of the command is |
no test coverage detected