Check if the provided channel is whitelisted by the given allowed channels * list. Glob-style pattern matching is employed, unless the literal flag is * set. Returns ACL_OK if access is granted or ACL_DENIED_CHANNEL otherwise. */
| 1263 | * list. Glob-style pattern matching is employed, unless the literal flag is |
| 1264 | * set. Returns ACL_OK if access is granted or ACL_DENIED_CHANNEL otherwise. */ |
| 1265 | int ACLCheckPubsubChannelPerm(sds channel, list *allowed, int literal) { |
| 1266 | listIter li; |
| 1267 | listNode *ln; |
| 1268 | size_t clen = sdslen(channel); |
| 1269 | int match = 0; |
| 1270 | |
| 1271 | listRewind(allowed,&li); |
| 1272 | while((ln = listNext(&li))) { |
| 1273 | sds pattern = (sds)listNodeValue(ln); |
| 1274 | size_t plen = sdslen(pattern); |
| 1275 | |
| 1276 | if ((literal && !sdscmp(pattern,channel)) || |
| 1277 | (!literal && stringmatchlen(pattern,plen,channel,clen,0))) |
| 1278 | { |
| 1279 | match = 1; |
| 1280 | break; |
| 1281 | } |
| 1282 | } |
| 1283 | if (!match) { |
| 1284 | return ACL_DENIED_CHANNEL; |
| 1285 | } |
| 1286 | return ACL_OK; |
| 1287 | } |
| 1288 | |
| 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. */ |
no test coverage detected