Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keydb.conf: support globbing in include directive #884

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#ifdef __linux__
#include <sys/sysinfo.h>
#endif
#include <glob.h>

const char *KEYDB_SET_VERSION = KEYDB_REAL_VERSION;
size_t g_semiOrderedSetTargetBucketSize = 0; // Its a header only class so nowhere else for this to go
Expand Down Expand Up @@ -593,7 +594,22 @@ void loadServerConfigFromString(char *config) {
fclose(logfp);
}
} else if (!strcasecmp(argv[0],"include") && argc == 2) {
loadServerConfig(argv[1], 0, NULL);
glob_t globbuf;
int ret;
ret = glob(argv[1], GLOB_ERR, NULL, &globbuf);
if (ret != EXIT_SUCCESS && ret != GLOB_NOMATCH) {
strerror(errno);
err = sdscatprintf(sdsempty(),
"Error handling include directive: %s", strerror(errno));
globfree(&globbuf);
goto loaderr;
}

for (size_t i = 0; i < globbuf.gl_pathc; i++) {
loadServerConfig(globbuf.gl_pathv[i], 0, NULL);
}

globfree(&globbuf);
} else if ((!strcasecmp(argv[0],"slaveof") ||
!strcasecmp(argv[0],"replicaof")) && argc == 3) {
slaveof_linenum = linenum;
Expand Down