diff options
author | zhugezy <44550833+zhugezy@users.noreply.github.com> | 2022-06-02 13:36:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 08:36:55 +0300 |
commit | cf3323dba473f3849200d294bb0349cd442f2006 (patch) | |
tree | d62c412b3dadfd3cc6289e86cac4499c6251d15c /src/config.c | |
parent | c81b5e5594e7a57753bbfd5e140ba8bf0732b987 (diff) | |
download | redis-cf3323dba473f3849200d294bb0349cd442f2006.tar.gz |
Fix bugs in CONFIG REWRITE, omitting rename-command and include lines, and inserting comments around module and acl configs (#10761)
A regression from #10285 (redis 7.0).
CONFIG REWRITE would put lines with: `include`, `rename-command`,
`user`, `loadmodule`, and any module specific config in a comment.
For ACL `user`, `loadmodule` and module specific configs would be
re-inserted at the end (instead of updating existing lines), so the only
implication is a messy config file full of comments.
But for `rename-command` and `include`, the implication would be that
they're now missing, so a server restart would lose them.
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/config.c b/src/config.c index 24760b030..9856af3c0 100644 --- a/src/config.c +++ b/src/config.c @@ -1142,10 +1142,21 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) { /* Not a comment, split into arguments. */ argv = sdssplitargs(line,&argc); - if (argv == NULL || (!server.sentinel_mode && !lookupConfig(argv[0]))) { - /* Apparently the line is unparsable for some reason, for - * instance it may have unbalanced quotes, or may contain a - * config that doesn't exist anymore. Load it as a comment. */ + + if (argv == NULL || + (!lookupConfig(argv[0]) && + /* The following is a list of config features that are only supported in + * config file parsing and are not recognized by lookupConfig */ + strcasecmp(argv[0],"include") && + strcasecmp(argv[0],"rename-command") && + strcasecmp(argv[0],"user") && + strcasecmp(argv[0],"loadmodule") && + strcasecmp(argv[0],"sentinel"))) + { + /* The line is either unparsable for some reason, for + * instance it may have unbalanced quotes, may contain a + * config that doesn't exist anymore, for instance a module that got + * unloaded. Load it as a comment. */ sds aux = sdsnew("# ??? "); aux = sdscatsds(aux,line); if (argv) sdsfreesplitres(argv, argc); |