MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ACLCheckPubsubChannelPerm

Function ACLCheckPubsubChannelPerm

app/redis-6.2.6/src/acl.c:1256–1278  ·  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

1254 * list. Glob-style pattern matching is employed, unless the literal flag is
1255 * set. Returns ACL_OK if access is granted or ACL_DENIED_CHANNEL otherwise. */
1256int ACLCheckPubsubChannelPerm(sds channel, list *allowed, int literal) {
1257 listIter li;
1258 listNode *ln;
1259 size_t clen = sdslen(channel);
1260 int match = 0;
1261
1262 listRewind(allowed,&li);
1263 while((ln = listNext(&li))) {
1264 sds pattern = listNodeValue(ln);
1265 size_t plen = sdslen(pattern);
1266
1267 if ((literal && !sdscmp(pattern,channel)) ||
1268 (!literal && stringmatchlen(pattern,plen,channel,clen,0)))
1269 {
1270 match = 1;
1271 break;
1272 }
1273 }
1274 if (!match) {
1275 return ACL_DENIED_CHANNEL;
1276 }
1277 return ACL_OK;
1278}
1279
1280/* Check if the user's existing pub/sub clients violate the ACL pub/sub
1281 * 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