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

Function ACLSetUser

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

Set user properties according to the string "op". The following * is a description of what different strings will do: * * on Enable the user: it is possible to authenticate as this user. * off Disable the user: it's no longer possible to authenticate * with this user, however the already authenticated connections * will still work. * +

Source from the content-addressed store, hash-verified

823 * EBADMSG: The hash you are trying to add is not a valid hash.
824 */
825int ACLSetUser(user *u, const char *op, ssize_t oplen) {
826 if (oplen == -1) oplen = strlen(op);
827 if (oplen == 0) return C_OK; /* Empty string is a no-operation. */
828 if (!strcasecmp(op,"on")) {
829 u->flags |= USER_FLAG_ENABLED;
830 u->flags &= ~USER_FLAG_DISABLED;
831 } else if (!strcasecmp(op,"off")) {
832 u->flags |= USER_FLAG_DISABLED;
833 u->flags &= ~USER_FLAG_ENABLED;
834 } else if (!strcasecmp(op,"skip-sanitize-payload")) {
835 u->flags |= USER_FLAG_SANITIZE_PAYLOAD_SKIP;
836 u->flags &= ~USER_FLAG_SANITIZE_PAYLOAD;
837 } else if (!strcasecmp(op,"sanitize-payload")) {
838 u->flags &= ~USER_FLAG_SANITIZE_PAYLOAD_SKIP;
839 u->flags |= USER_FLAG_SANITIZE_PAYLOAD;
840 } else if (!strcasecmp(op,"allkeys") ||
841 !strcasecmp(op,"~*"))
842 {
843 u->flags |= USER_FLAG_ALLKEYS;
844 listEmpty(u->patterns);
845 } else if (!strcasecmp(op,"resetkeys")) {
846 u->flags &= ~USER_FLAG_ALLKEYS;
847 listEmpty(u->patterns);
848 } else if (!strcasecmp(op,"allchannels") ||
849 !strcasecmp(op,"&*"))
850 {
851 u->flags |= USER_FLAG_ALLCHANNELS;
852 listEmpty(u->channels);
853 } else if (!strcasecmp(op,"resetchannels")) {
854 u->flags &= ~USER_FLAG_ALLCHANNELS;
855 listEmpty(u->channels);
856 } else if (!strcasecmp(op,"allcommands") ||
857 !strcasecmp(op,"+@all"))
858 {
859 memset(u->allowed_commands,255,sizeof(u->allowed_commands));
860 u->flags |= USER_FLAG_ALLCOMMANDS;
861 ACLResetSubcommands(u);
862 } else if (!strcasecmp(op,"nocommands") ||
863 !strcasecmp(op,"-@all"))
864 {
865 memset(u->allowed_commands,0,sizeof(u->allowed_commands));
866 u->flags &= ~USER_FLAG_ALLCOMMANDS;
867 ACLResetSubcommands(u);
868 } else if (!strcasecmp(op,"nopass")) {
869 u->flags |= USER_FLAG_NOPASS;
870 listEmpty(u->passwords);
871 } else if (!strcasecmp(op,"resetpass")) {
872 u->flags &= ~USER_FLAG_NOPASS;
873 listEmpty(u->passwords);
874 } else if (op[0] == '>' || op[0] == '#') {
875 sds newpass;
876 if (op[0] == '>') {
877 newpass = ACLHashPassword((unsigned char*)op+1,oplen-1);
878 } else {
879 if (ACLCheckPasswordHash((unsigned char*)op+1,oplen-1) == C_ERR) {
880 errno = EBADMSG;
881 return C_ERR;
882 }

Callers 8

ACLInitDefaultUserFunction · 0.85
ACLAppendUserForLoadingFunction · 0.85
ACLLoadConfiguredUsersFunction · 0.85
ACLLoadFromFileFunction · 0.85
aclCommandFunction · 0.85
RM_SetModuleUserACLFunction · 0.85

Calls 15

strcasecmpFunction · 0.85
listEmptyFunction · 0.85
memsetFunction · 0.85
ACLResetSubcommandsFunction · 0.85
ACLHashPasswordFunction · 0.85
ACLCheckPasswordHashFunction · 0.85
sdsnewlenFunction · 0.85
listSearchKeyFunction · 0.85
listAddNodeTailFunction · 0.85
sdsfreeFunction · 0.85
listDelNodeFunction · 0.85
ACLStringHasSpacesFunction · 0.85

Tested by

no test coverage detected