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

Function rewriteConfigUserOption

src/config.cpp:1653–1682  ·  view source on GitHub ↗

Rewrite the user option. */

Source from the content-addressed store, hash-verified

1651
1652/* Rewrite the user option. */
1653void rewriteConfigUserOption(struct rewriteConfigState *state) {
1654 /* If there is a user file defined we just mark this configuration
1655 * directive as processed, so that all the lines containing users
1656 * inside the config file gets discarded. */
1657 if (g_pserver->acl_filename[0] != '\0') {
1658 rewriteConfigMarkAsProcessed(state,"user");
1659 return;
1660 }
1661
1662 /* Otherwise scan the list of users and rewrite every line. Note that
1663 * in case the list here is empty, the effect will just be to comment
1664 * all the users directive inside the config file. */
1665 raxIterator ri;
1666 raxStart(&ri,Users);
1667 raxSeek(&ri,"^",NULL,0);
1668 while(raxNext(&ri)) {
1669 user *u = (user*)ri.data;
1670 sds line = sdsnew("user ");
1671 line = sdscatsds(line,u->name);
1672 line = sdscatlen(line," ",1);
1673 sds descr = ACLDescribeUser(u);
1674 line = sdscatsds(line,descr);
1675 sdsfree(descr);
1676 rewriteConfigRewriteLine(state,"user",line,1);
1677 }
1678 raxStop(&ri);
1679
1680 /* Mark "user" as processed in case there are no defined users. */
1681 rewriteConfigMarkAsProcessed(state,"user");
1682}
1683
1684/* Rewrite the dir option, always using absolute paths.*/
1685void rewriteConfigDirOption(struct rewriteConfigState *state) {

Callers 1

rewriteConfigFunction · 0.85

Calls 11

raxStartFunction · 0.85
raxSeekFunction · 0.85
raxNextFunction · 0.85
sdsnewFunction · 0.85
sdscatsdsFunction · 0.85
sdscatlenFunction · 0.85
ACLDescribeUserFunction · 0.85
sdsfreeFunction · 0.85
rewriteConfigRewriteLineFunction · 0.85
raxStopFunction · 0.85

Tested by

no test coverage detected