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

Function ACLLoadConfiguredUsers

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

This function will load the configured users appended to the server * configuration via ACLAppendUserForLoading(). On loading errors it will * log an error and return C_ERR, otherwise C_OK will be returned. */

Source from the content-addressed store, hash-verified

1434 * configuration via ACLAppendUserForLoading(). On loading errors it will
1435 * log an error and return C_ERR, otherwise C_OK will be returned. */
1436int ACLLoadConfiguredUsers(void) {
1437 listIter li;
1438 listNode *ln;
1439 listRewind(UsersToLoad,&li);
1440 while ((ln = listNext(&li)) != NULL) {
1441 sds *aclrules = listNodeValue(ln);
1442 sds username = aclrules[0];
1443
1444 if (ACLStringHasSpaces(aclrules[0],sdslen(aclrules[0]))) {
1445 serverLog(LL_WARNING,"Spaces not allowed in ACL usernames");
1446 return C_ERR;
1447 }
1448
1449 user *u = ACLCreateUser(username,sdslen(username));
1450 if (!u) {
1451 u = ACLGetUserByName(username,sdslen(username));
1452 serverAssert(u != NULL);
1453 ACLSetUser(u,"reset",-1);
1454 }
1455
1456 /* Load every rule defined for this user. */
1457 for (int j = 1; aclrules[j]; j++) {
1458 if (ACLSetUser(u,aclrules[j],sdslen(aclrules[j])) != C_OK) {
1459 const char *errmsg = ACLSetUserStringError();
1460 serverLog(LL_WARNING,"Error loading ACL rule '%s' for "
1461 "the user named '%s': %s",
1462 aclrules[j],aclrules[0],errmsg);
1463 return C_ERR;
1464 }
1465 }
1466
1467 /* Having a disabled user in the configuration may be an error,
1468 * warn about it without returning any error to the caller. */
1469 if (u->flags & USER_FLAG_DISABLED) {
1470 serverLog(LL_NOTICE, "The user '%s' is disabled (there is no "
1471 "'on' modifier in the user description). Make "
1472 "sure this is not a configuration error.",
1473 aclrules[0]);
1474 }
1475 }
1476 return C_OK;
1477}
1478
1479/* This function loads the ACL from the specified filename: every line
1480 * is validated and should be either empty or in the format used to specify

Callers 1

ACLLoadUsersAtStartupFunction · 0.85

Calls 8

listRewindFunction · 0.85
listNextFunction · 0.85
ACLStringHasSpacesFunction · 0.85
sdslenFunction · 0.85
ACLCreateUserFunction · 0.85
ACLGetUserByNameFunction · 0.85
ACLSetUserFunction · 0.85
ACLSetUserStringErrorFunction · 0.85

Tested by

no test coverage detected