MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ACLCheckPubsubChannelPerm

Function ACLCheckPubsubChannelPerm

src/acl.cpp:1265–1287  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

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. */
1265int 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. */

Callers 2

ACLCheckPubsubPermFunction · 0.85

Calls 5

sdslenFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
sdscmpFunction · 0.85
stringmatchlenFunction · 0.85

Tested by

no test coverage detected