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

Function ACLCheckPubsubPerm

app/redis-6.2.6/src/acl.c:1342–1364  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1340 * If the user can execute the command ACL_OK is returned, otherwise
1341 * ACL_DENIED_CHANNEL. */
1342int ACLCheckPubsubPerm(client *c, int idx, int count, int literal, int *idxptr) {
1343 user *u = c->user;
1344
1345 /* If there is no associated user, the connection can run anything. */
1346 if (u == NULL) return ACL_OK;
1347
1348 /* Check if the user can access the channels mentioned in the command's
1349 * arguments. */
1350 if (!(c->user->flags & USER_FLAG_ALLCHANNELS)) {
1351 for (int j = idx; j < idx+count; j++) {
1352 if (ACLCheckPubsubChannelPerm(c->argv[j]->ptr,u->channels,literal)
1353 != ACL_OK) {
1354 if (idxptr) *idxptr = j;
1355 return ACL_DENIED_CHANNEL;
1356 }
1357 }
1358 }
1359
1360 /* If we survived all the above checks, the user can execute the
1361 * command. */
1362 return ACL_OK;
1363
1364}
1365
1366/* Check whether the command is ready to be exceuted by ACLCheckCommandPerm.
1367 * If check passes, then check whether pub/sub channels of the command is

Callers 1

ACLCheckAllPermFunction · 0.85

Calls 1

Tested by

no test coverage detected