MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ACLCreateUnlinkedUser

Function ACLCreateUnlinkedUser

src/acl.cpp:280–291  ·  view source on GitHub ↗

This function should be called when we need an unlinked "fake" user * we can use in order to validate ACL rules or for other similar reasons. * The user will not get linked to the Users radix tree. The returned * user should be released with ACLFreeUser() as usually. */

Source from the content-addressed store, hash-verified

278 * The user will not get linked to the Users radix tree. The returned
279 * user should be released with ACLFreeUser() as usually. */
280user *ACLCreateUnlinkedUser(void) {
281 char username[64];
282 for (int j = 0; ; j++) {
283 snprintf(username,sizeof(username),"__fakeuser:%d__",j);
284 user *fakeuser = ACLCreateUser(username,strlen(username));
285 if (fakeuser == NULL) continue;
286 int retval = raxRemove(Users,(unsigned char*) username,
287 strlen(username),NULL);
288 serverAssert(retval != 0);
289 return fakeuser;
290 }
291}
292
293/* Release the memory used by the user structure. Note that this function
294 * will not remove the user from the Users global radix tree. */

Callers 4

RM_CreateModuleUserFunction · 0.85
ACLAppendUserForLoadingFunction · 0.85
ACLLoadFromFileFunction · 0.85
aclCommandFunction · 0.85

Calls 2

ACLCreateUserFunction · 0.85
raxRemoveFunction · 0.85

Tested by

no test coverage detected