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

Function ACLAddAllowedSubcommand

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

Add a subcommand to the list of subcommands for the user 'u' and * the command id specified. */

Source from the content-addressed store, hash-verified

710/* Add a subcommand to the list of subcommands for the user 'u' and
711 * the command id specified. */
712void ACLAddAllowedSubcommand(user *u, unsigned long id, const char *sub) {
713 /* If this is the first subcommand to be configured for
714 * this user, we have to allocate the subcommands array. */
715 if (u->allowed_subcommands == NULL) {
716 u->allowed_subcommands = zcalloc(USER_COMMAND_BITS_COUNT *
717 sizeof(sds*));
718 }
719
720 /* We also need to enlarge the allocation pointing to the
721 * null terminated SDS array, to make space for this one.
722 * To start check the current size, and while we are here
723 * make sure the subcommand is not already specified inside. */
724 long items = 0;
725 if (u->allowed_subcommands[id]) {
726 while(u->allowed_subcommands[id][items]) {
727 /* If it's already here do not add it again. */
728 if (!strcasecmp(u->allowed_subcommands[id][items],sub)) return;
729 items++;
730 }
731 }
732
733 /* Now we can make space for the new item (and the null term). */
734 items += 2;
735 u->allowed_subcommands[id] = zrealloc(u->allowed_subcommands[id],
736 sizeof(sds)*items);
737 u->allowed_subcommands[id][items-2] = sdsnew(sub);
738 u->allowed_subcommands[id][items-1] = NULL;
739}
740
741/* Set user properties according to the string "op". The following
742 * is a description of what different strings will do:

Callers 2

ACLCopyUserFunction · 0.85
ACLSetUserFunction · 0.85

Calls 4

strcasecmpFunction · 0.85
zreallocFunction · 0.85
sdsnewFunction · 0.85
zcallocFunction · 0.70

Tested by

no test coverage detected