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

Function ACLCreateUser

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

Create a new user with the specified name, store it in the list * of users (the Users global radix tree), and returns a reference to * the structure representing the user. * * If the user with such name already exists NULL is returned. */

Source from the content-addressed store, hash-verified

242 *
243 * If the user with such name already exists NULL is returned. */
244user *ACLCreateUser(const char *name, size_t namelen) {
245 if (raxFind(Users,(unsigned char*)name,namelen) != raxNotFound) return NULL;
246 user *u = zmalloc(sizeof(*u));
247 u->name = sdsnewlen(name,namelen);
248 u->flags = USER_FLAG_DISABLED | server.acl_pubsub_default;
249 u->allowed_subcommands = NULL;
250 u->passwords = listCreate();
251 u->patterns = listCreate();
252 u->channels = listCreate();
253 listSetMatchMethod(u->passwords,ACLListMatchSds);
254 listSetFreeMethod(u->passwords,ACLListFreeSds);
255 listSetDupMethod(u->passwords,ACLListDupSds);
256 listSetMatchMethod(u->patterns,ACLListMatchSds);
257 listSetFreeMethod(u->patterns,ACLListFreeSds);
258 listSetDupMethod(u->patterns,ACLListDupSds);
259 listSetMatchMethod(u->channels,ACLListMatchSds);
260 listSetFreeMethod(u->channels,ACLListFreeSds);
261 listSetDupMethod(u->channels,ACLListDupSds);
262 memset(u->allowed_commands,0,sizeof(u->allowed_commands));
263 raxInsert(Users,(unsigned char*)name,namelen,u,NULL);
264 return u;
265}
266
267/* This function should be called when we need an unlinked "fake" user
268 * we can use in order to validate ACL rules or for other similar reasons.

Callers 5

ACLCreateUnlinkedUserFunction · 0.85
ACLInitDefaultUserFunction · 0.85
ACLLoadConfiguredUsersFunction · 0.85
ACLLoadFromFileFunction · 0.85
aclCommandFunction · 0.85

Calls 6

raxFindFunction · 0.85
zmallocFunction · 0.85
sdsnewlenFunction · 0.85
listCreateFunction · 0.85
memsetFunction · 0.85
raxInsertFunction · 0.85

Tested by

no test coverage detected