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. */
| 269 | * The user will not get linked to the Users radix tree. The returned |
| 270 | * user should be released with ACLFreeUser() as usually. */ |
| 271 | user *ACLCreateUnlinkedUser(void) { |
| 272 | char username[64]; |
| 273 | for (int j = 0; ; j++) { |
| 274 | snprintf(username,sizeof(username),"__fakeuser:%d__",j); |
| 275 | user *fakeuser = ACLCreateUser(username,strlen(username)); |
| 276 | if (fakeuser == NULL) continue; |
| 277 | int retval = raxRemove(Users,(unsigned char*) username, |
| 278 | strlen(username),NULL); |
| 279 | serverAssert(retval != 0); |
| 280 | return fakeuser; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | /* Release the memory used by the user structure. Note that this function |
| 285 | * will not remove the user from the Users global radix tree. */ |
no test coverage detected