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. */
| 278 | * The user will not get linked to the Users radix tree. The returned |
| 279 | * user should be released with ACLFreeUser() as usually. */ |
| 280 | user *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. */ |
no test coverage detected